From ed8e1eccb4b0f26c4626a7c88db05217b9625046 Mon Sep 17 00:00:00 2001 From: fralx Date: Mon, 18 May 2020 22:12:05 +0300 Subject: [PATCH] ChartItem has been fixed --- common.pri | 2 +- limereport/items/charts/lrhorizontalbarchart.cpp | 2 ++ limereport/items/charts/lrlineschart.cpp | 2 ++ limereport/items/charts/lrpiechart.cpp | 4 ++-- limereport/items/charts/lrverticalbarchart.cpp | 6 ++++++ limereport/items/lrchartitem.cpp | 11 +++++++++-- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/common.pri b/common.pri index 558ecc7..a0fcb3b 100644 --- a/common.pri +++ b/common.pri @@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 51 +LIMEREPORT_VERSION_RELEASE = 53 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/items/charts/lrhorizontalbarchart.cpp b/limereport/items/charts/lrhorizontalbarchart.cpp index e2713dd..3d539d9 100644 --- a/limereport/items/charts/lrhorizontalbarchart.cpp +++ b/limereport/items/charts/lrhorizontalbarchart.cpp @@ -28,6 +28,8 @@ void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect) void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect) { + if (seriesCount() == 0) return; + painter->save(); painter->setRenderHint(QPainter::Antialiasing,false); int delta = int(maxValue()-minValue()); diff --git a/limereport/items/charts/lrlineschart.cpp b/limereport/items/charts/lrlineschart.cpp index 30f2949..9ee2b81 100644 --- a/limereport/items/charts/lrlineschart.cpp +++ b/limereport/items/charts/lrlineschart.cpp @@ -65,6 +65,8 @@ void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qre void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) { + if (valuesCount() == 0) return; + painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); int delta = int(maxValue() - minValue()); diff --git a/limereport/items/charts/lrpiechart.cpp b/limereport/items/charts/lrpiechart.cpp index f54e62d..d6afb0c 100644 --- a/limereport/items/charts/lrpiechart.cpp +++ b/limereport/items/charts/lrpiechart.cpp @@ -70,7 +70,7 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect) drawPercent(painter, chartRect, currentDegree, sectorDegree); currentDegree += sectorDegree; } - } else { + } else if (m_chartItem->itemMode() == DesignMode){ painter->setBrush(color_map[0]); painter->drawPie(chartRect,0,260*16); drawPercent(painter, chartRect, 0, 260); @@ -122,7 +122,7 @@ void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect) ); cw += painter->fontMetrics().height(); } - } else { + } else if (m_chartItem->itemMode() == DesignMode){ qreal cw = 0; for (int i=0;iseries().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ int curSeries = 0; foreach (SeriesItem* series, m_chartItem->series()) { @@ -93,6 +97,8 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect) void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect) { + if (valuesCount() == 0 ) return; + painter->save(); painter->setRenderHint(QPainter::Antialiasing,true); int delta = int(maxValue() - minValue()); diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index 5d1ca0e..15f76fa 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -584,7 +584,10 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font) return QSizeF(maxWidth+fm.height()*2,cw); } -bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect){ +bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect) +{ + if (valuesCount() == 0) return false; + qreal hStep = (labelsRect.width() / valuesCount()); QFontMetrics fm = painter->fontMetrics(); foreach(QString label, m_chartItem->labels()){ @@ -597,6 +600,8 @@ bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect){ void AbstractSeriesChart::paintHorizontalLabels(QPainter *painter, QRectF labelsRect) { + if (valuesCount() == 0) return; + painter->save(); qreal hStep = (labelsRect.width() / valuesCount()); if (!m_chartItem->labels().isEmpty()){ @@ -623,6 +628,8 @@ void AbstractSeriesChart::paintHorizontalLabels(QPainter *painter, QRectF labels void AbstractSeriesChart::paintVerticalLabels(QPainter *painter, QRectF labelsRect) { + if (valuesCount() == 0) return; + painter->save(); painter->setFont(adaptLabelsFont(labelsRect.adjusted(0, 0, -hPadding(m_chartItem->rect()), 0), painter->font())); @@ -771,7 +778,7 @@ void AbstractBarChart::paintChartLegend(QPainter *painter, QRectF legendRect) ); cw += painter->fontMetrics().height(); } - } else { + } else if (m_chartItem->itemMode() == DesignMode){ qreal cw = 0; for (int i=0;i