From 69ea9f58fd3267c8dd75c162137866e3b60facde Mon Sep 17 00:00:00 2001 From: Tomi Korpipaa Date: Tue, 12 Oct 2021 14:16:38 +0300 Subject: Fix incorrect plotArea before resize If plotArea is set inside ChartView, contentGeometry is updated too early and we end up with incorrect plotArea. Invalidate the layout to correct the geometry. Fixes: QTBUG-95870 Change-Id: I761125633bcbb8297e629b3e98d61e7d95975806 Reviewed-by: Miikka Heikkinen (cherry picked from commit f78e11381f2dedcab4bda44e52b3c75d810766c4) Reviewed-by: Qt Cherry-pick Bot --- src/charts/chartpresenter.cpp | 2 +- src/charts/domain/abstractdomain.cpp | 3 +++ src/charts/layout/abstractchartlayout.cpp | 15 +++++++++------ src/chartsqml2/declarativechart.cpp | 5 +++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/charts/chartpresenter.cpp b/src/charts/chartpresenter.cpp index 98bca1a1..66394900 100644 --- a/src/charts/chartpresenter.cpp +++ b/src/charts/chartpresenter.cpp @@ -98,7 +98,7 @@ void ChartPresenter::setFixedGeometry(const QRectF &rect) void ChartPresenter::setGeometry(const QRectF rect) { - if (m_rect != rect) { + if (rect.isValid() && m_rect != rect) { m_rect = rect; if (!m_fixedRect.isNull()) return; diff --git a/src/charts/domain/abstractdomain.cpp b/src/charts/domain/abstractdomain.cpp index e3255103..1a867616 100644 --- a/src/charts/domain/abstractdomain.cpp +++ b/src/charts/domain/abstractdomain.cpp @@ -58,6 +58,9 @@ AbstractDomain::~AbstractDomain() void AbstractDomain::setSize(const QSizeF &size) { + if (!size.isValid()) + return; + if (m_size != size) { m_size=size; emit updated(); diff --git a/src/charts/layout/abstractchartlayout.cpp b/src/charts/layout/abstractchartlayout.cpp index ae1da176..a6c2d716 100644 --- a/src/charts/layout/abstractchartlayout.cpp +++ b/src/charts/layout/abstractchartlayout.cpp @@ -53,6 +53,7 @@ void AbstractChartLayout::setGeometry(const QRectF &rect) { if (!rect.isValid()) return; + // If the chart has a fixed geometry then don't update visually const bool updateLayout = (!m_presenter->isFixedGeometry() || m_presenter->geometry() == rect); if (m_presenter->chart()->isVisible()) { @@ -73,12 +74,14 @@ void AbstractChartLayout::setGeometry(const QRectF &rect) contentGeometry = calculateAxisGeometry(contentGeometry, axes, updateLayout); - m_presenter->setGeometry(contentGeometry); - if (updateLayout) { - if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) - static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); - else - static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + if (contentGeometry.isValid()) { + m_presenter->setGeometry(contentGeometry); + if (updateLayout) { + if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) + static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + else + static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + } } } diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp index 4b940e10..d7834d31 100644 --- a/src/chartsqml2/declarativechart.cpp +++ b/src/chartsqml2/declarativechart.cpp @@ -61,6 +61,7 @@ #include #include #include +#include QT_CHARTS_BEGIN_NAMESPACE @@ -1496,6 +1497,10 @@ QPointF DeclarativeChart::mapToPosition(const QPointF &value, QAbstractSeries *s void DeclarativeChart::setPlotArea(const QRectF &rect) { m_chart->setPlotArea(rect); + + // If plotArea is set inside ChartView, contentGeometry is updated too early and we end up + // with incorrect plotArea. Invalidate the layout to correct the geometry. + m_chart->layout()->invalidate(); } QT_CHARTS_END_NAMESPACE -- cgit v1.2.3 From ec6cf5ff38a7f65578cdecbd90cc15e2c30f0370 Mon Sep 17 00:00:00 2001 From: Hatem ElKharashy Date: Fri, 15 Oct 2021 13:48:32 +0300 Subject: Fix axes not being removed when shared Switching axes that is shared between multiple series causes them not to be removed. The axis must be detached from the series when removed so that it can be removed in the next iteration. Fixes: QTBUG-81278 Change-Id: Iba9e027333ed924ff985e36184f7e6d49d2124cf Reviewed-by: Miikka Heikkinen (cherry picked from commit 968e128f3379514b476ed21dd92cf2ac8f9f861d) Reviewed-by: Qt Cherry-pick Bot --- src/chartsqml2/declarativechart.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp index d7834d31..2166b84f 100644 --- a/src/chartsqml2/declarativechart.cpp +++ b/src/chartsqml2/declarativechart.cpp @@ -633,9 +633,12 @@ void DeclarativeChart::seriesAxisAttachHelper(QAbstractSeries *series, QAbstract { if (!series->attachedAxes().contains(axis)) { // Remove & delete old axes that are not attached to any other series + // Detach old axis from series so that if it is shared with other series + // It can be deleted. foreach (QAbstractAxis* oldAxis, m_chart->axes(orientation, series)) { bool otherAttachments = false; if (oldAxis != axis) { + series->detachAxis(oldAxis); foreach (QAbstractSeries *oldSeries, m_chart->series()) { if (oldSeries != series && oldSeries->attachedAxes().contains(oldAxis)) { otherAttachments = true; -- cgit v1.2.3 From 1d4ccaedd392e27007dd6383d6b5220c16bc85c5 Mon Sep 17 00:00:00 2001 From: Tarja Sundqvist Date: Mon, 8 Nov 2021 18:29:12 +0200 Subject: Bump version --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 03db297a..560f538f 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) DEFINES += QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST -MODULE_VERSION = 5.15.7 +MODULE_VERSION = 5.15.8 -- cgit v1.2.3 From b8671f5a150a3a27180e0336a7b692746bdbe40f Mon Sep 17 00:00:00 2001 From: Sami Varanka Date: Mon, 29 Nov 2021 12:39:22 +0200 Subject: Fix: QPieSlice docs don't mention HTML formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a note to QPieSlice documentation to mention that the label string can be HTML formatted. Fixes: QTBUG-98282 Change-Id: Ia9bcd478e86d38228d9ff46053eedb13a0b876e1 Reviewed-by: Tomi Korpipää Reviewed-by: Leena Miettinen Reviewed-by: Miikka Heikkinen (cherry picked from commit 50eb5ad6a2854fc5d6acc45279d0bb3ee9b33411) Reviewed-by: Qt Cherry-pick Bot --- src/charts/piechart/qpieslice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/charts/piechart/qpieslice.cpp b/src/charts/piechart/qpieslice.cpp index e41f6e59..d9ee3dbe 100644 --- a/src/charts/piechart/qpieslice.cpp +++ b/src/charts/piechart/qpieslice.cpp @@ -108,11 +108,13 @@ QT_CHARTS_BEGIN_NAMESPACE /*! \property QPieSlice::label \brief The label of the slice. + \note The string can be HTML formatted. \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor */ /*! \qmlproperty string PieSlice::label The label of the slice. + \note The string can be HTML formatted. */ /*! -- cgit v1.2.3