diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-06-18 13:10:30 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-06-18 13:10:30 +0300 |
commit | 166eae80efe685ffbc7097ebdbe3e68d12e7d2e0 (patch) | |
tree | 0f7cc9b0f8937565387831370f92458fd8cf66f0 | |
parent | 75f76f7157af7c9785fdca0825375abc4169300e (diff) |
Force entire chart update when points label clipping changes
Series points labels can be partly outside the plot area.
When they are set to be clipped to plot area, the parts of labels
that are outside the plot area are not cleared unless the whole chart
is updated.
Task-number: QTBUG-60384
Change-Id: I67233b562d9d0e404c09e5b661123819e97fc529
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r-- | src/charts/areachart/areachartitem.cpp | 7 | ||||
-rw-r--r-- | src/charts/linechart/linechartitem.cpp | 8 | ||||
-rw-r--r-- | src/charts/scatterchart/scatterchartitem.cpp | 7 | ||||
-rw-r--r-- | src/charts/splinechart/splinechartitem.cpp | 7 |
4 files changed, 25 insertions, 4 deletions
diff --git a/src/charts/areachart/areachartitem.cpp b/src/charts/areachart/areachartitem.cpp index 58f2c367..bd1c2b5c 100644 --- a/src/charts/areachart/areachartitem.cpp +++ b/src/charts/areachart/areachartitem.cpp @@ -198,8 +198,13 @@ void AreaChartItem::handleUpdated() m_pointLabelsVisible = m_series->pointLabelsVisible(); m_pointLabelsFont = m_series->pointLabelsFont(); m_pointLabelsColor = m_series->pointLabelsColor(); + bool labelClippingChanged = m_pointLabelsClipping != m_series->pointLabelsClipping(); m_pointLabelsClipping = m_series->pointLabelsClipping(); - update(); + // Update whole chart in case label clipping changed as labels can be outside series area + if (labelClippingChanged) + m_series->chart()->update(); + else + update(); } void AreaChartItem::handleDomainUpdated() diff --git a/src/charts/linechart/linechartitem.cpp b/src/charts/linechart/linechartitem.cpp index 8ea5dbb0..99e16d29 100644 --- a/src/charts/linechart/linechartitem.cpp +++ b/src/charts/linechart/linechartitem.cpp @@ -354,12 +354,18 @@ void LineChartItem::handleUpdated() m_pointLabelsVisible = m_series->pointLabelsVisible(); m_pointLabelsFont = m_series->pointLabelsFont(); m_pointLabelsColor = m_series->pointLabelsColor(); + bool labelClippingChanged = m_pointLabelsClipping != m_series->pointLabelsClipping(); m_pointLabelsClipping = m_series->pointLabelsClipping(); if (doGeometryUpdate) updateGeometry(); else if (m_series->useOpenGL() && visibleChanged) refreshGlChart(); - update(); + + // Update whole chart in case label clipping changed as labels can be outside series area + if (labelClippingChanged) + m_series->chart()->update(); + else + update(); } void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) diff --git a/src/charts/scatterchart/scatterchartitem.cpp b/src/charts/scatterchart/scatterchartitem.cpp index 1558cc60..a358e4f2 100644 --- a/src/charts/scatterchart/scatterchartitem.cpp +++ b/src/charts/scatterchart/scatterchartitem.cpp @@ -273,6 +273,7 @@ void ScatterChartItem::handleUpdated() m_pointLabelsVisible = m_series->pointLabelsVisible(); m_pointLabelsFont = m_series->pointLabelsFont(); m_pointLabelsColor = m_series->pointLabelsColor(); + bool labelClippingChanged = m_pointLabelsClipping != m_series->pointLabelsClipping(); m_pointLabelsClipping = m_series->pointLabelsClipping(); if (recreate) { @@ -285,7 +286,11 @@ void ScatterChartItem::handleUpdated() setPen(m_series->pen()); setBrush(m_series->brush()); - update(); + // Update whole chart in case label clipping changed as labels can be outside series area + if (labelClippingChanged) + m_series->chart()->update(); + else + update(); } QT_CHARTS_END_NAMESPACE diff --git a/src/charts/splinechart/splinechartitem.cpp b/src/charts/splinechart/splinechartitem.cpp index f873fd10..776842fd 100644 --- a/src/charts/splinechart/splinechartitem.cpp +++ b/src/charts/splinechart/splinechartitem.cpp @@ -427,8 +427,13 @@ void SplineChartItem::handleUpdated() m_pointLabelsVisible = m_series->pointLabelsVisible(); m_pointLabelsFont = m_series->pointLabelsFont(); m_pointLabelsColor = m_series->pointLabelsColor(); + bool labelClippingChanged = m_pointLabelsClipping != m_series->pointLabelsClipping(); m_pointLabelsClipping = m_series->pointLabelsClipping(); - update(); + // Update whole chart in case label clipping changed as labels can be outside series area + if (labelClippingChanged) + m_series->chart()->update(); + else + update(); } //painter |