##// END OF EJS Templates
Clear background when there is only pie chart.
Jani Honkonen -
r293:c84fc5fb7b13
parent child
Show More
@@ -28,9 +28,9 int main(int argc, char *argv[])
28
28
29 QChartView* chartView = new QChartView(&window);
29 QChartView* chartView = new QChartView(&window);
30 chartView->setRenderHint(QPainter::Antialiasing);
30 chartView->setRenderHint(QPainter::Antialiasing);
31 chartView->addSeries(series);
32 chartView->setChartTitle("simple piechart");
33 chartView->setChartTheme(QChart::ChartThemeIcy);
31 chartView->setChartTheme(QChart::ChartThemeIcy);
32 chartView->setChartTitle("Simple piechart");
33 chartView->addSeries(series);
34
34
35 window.setCentralWidget(chartView);
35 window.setCentralWidget(chartView);
36 window.resize(600, 600);
36 window.resize(600, 600);
@@ -159,6 +159,21 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
159 PiePresenter* pie = new PiePresenter(m_chart, s);
159 PiePresenter* pie = new PiePresenter(m_chart, s);
160 m_chartTheme->decorate(pie, s, m_chartItems.count());
160 m_chartTheme->decorate(pie, s, m_chartItems.count());
161 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
161 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
162
163 // Hide all from background when there is only piechart
164 // TODO: refactor this ugly code... should be one setting for this
165 if (m_chartItems.count() == 0) {
166 m_chart->axisX()->setAxisVisible(false);
167 m_chart->axisY()->setAxisVisible(false);
168 m_chart->axisX()->setGridVisible(false);
169 m_chart->axisY()->setGridVisible(false);
170 m_chart->axisX()->setLabelsVisible(false);
171 m_chart->axisY()->setLabelsVisible(false);
172 m_chart->axisX()->setShadesVisible(false);
173 m_chart->axisY()->setShadesVisible(false);
174 m_chart->setChartBackgroundBrush(Qt::transparent);
175 }
176
162 m_chartItems.insert(series, pie);
177 m_chartItems.insert(series, pie);
163 break;
178 break;
164 }
179 }
General Comments 0
You need to be logged in to leave comments. Login now