diff --git a/src/layout/abstractchartlayout.cpp b/src/layout/abstractchartlayout.cpp index de7ca55..85995f2 100644 --- a/src/layout/abstractchartlayout.cpp +++ b/src/layout/abstractchartlayout.cpp @@ -46,28 +46,30 @@ void AbstractChartLayout::setGeometry(const QRectF &rect) if (!rect.isValid()) return; - QList axes = m_presenter->axisItems(); - ChartTitle *title = m_presenter->titleElement(); - QLegend *legend = m_presenter->legend(); - ChartBackground *background = m_presenter->backgroundElement(); + if (m_presenter->chart()->isVisible()) { + QList axes = m_presenter->axisItems(); + ChartTitle *title = m_presenter->titleElement(); + QLegend *legend = m_presenter->legend(); + ChartBackground *background = m_presenter->backgroundElement(); - QRectF contentGeometry = calculateBackgroundGeometry(rect, background); + QRectF contentGeometry = calculateBackgroundGeometry(rect, background); - contentGeometry = calculateContentGeometry(contentGeometry); + contentGeometry = calculateContentGeometry(contentGeometry); - if (title && title->isVisible()) - contentGeometry = calculateTitleGeometry(contentGeometry, title); + if (title && title->isVisible()) + contentGeometry = calculateTitleGeometry(contentGeometry, title); - if (legend->isAttachedToChart() && legend->isVisible()) - contentGeometry = calculateLegendGeometry(contentGeometry, legend); + if (legend->isAttachedToChart() && legend->isVisible()) + contentGeometry = calculateLegendGeometry(contentGeometry, legend); - contentGeometry = calculateAxisGeometry(contentGeometry, axes); + contentGeometry = calculateAxisGeometry(contentGeometry, axes); - m_presenter->setGeometry(contentGeometry); - if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) - static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); - else - static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + m_presenter->setGeometry(contentGeometry); + if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian) + static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + else + static_cast(m_presenter->plotAreaElement())->setRect(contentGeometry); + } QGraphicsLayout::setGeometry(rect); } diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index 2faacd3..e5c9549 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -518,7 +518,9 @@ void QLegendPrivate::handleSeriesVisibleChanged() marker->setVisible(series->isVisible()); } } - m_layout->invalidate(); + + if (m_chart->isVisible()) + m_layout->invalidate(); } void QLegendPrivate::handleCountChanged()