##// END OF EJS Templates
Remove theme setting from StackedBarChart Drilldown example...
Titta Heikkala -
r2762:1774126c17aa
parent child
Show More
@@ -1,111 +1,110
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2014 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.io
6 6 **
7 7 ** This file is part of the Qt Charts module.
8 8 **
9 9 ** Licensees holding valid commercial license for Qt may use this file in
10 10 ** accordance with the Qt License Agreement provided with the Software
11 11 ** or, alternatively, in accordance with the terms contained in a written
12 12 ** agreement between you and Digia.
13 13 **
14 14 ** If you have questions regarding the use of this file, please use
15 15 ** contact form at http://qt.io
16 16 **
17 17 ****************************************************************************/
18 18
19 19 #include <QtWidgets/QApplication>
20 20 #include <QtWidgets/QMainWindow>
21 21 #include <QtCharts/QChartView>
22 22 #include <QtCharts/QBarSet>
23 23 #include <QtCharts/QLegend>
24 24 #include "drilldownseries.h"
25 25 #include "drilldownchart.h"
26 26
27 27 QT_CHARTS_USE_NAMESPACE
28 28
29 29 int main(int argc, char *argv[])
30 30 {
31 31 QApplication a(argc, argv);
32 32 QMainWindow window;
33 33
34 34 //! [1]
35 35 DrilldownChart *drilldownChart = new DrilldownChart();
36 drilldownChart->setTheme(QChart::ChartThemeBlueIcy);
37 36 drilldownChart->setAnimationOptions(QChart::SeriesAnimations);
38 37 //! [1]
39 38
40 39 //! [2]
41 40 // Define categories
42 41 QStringList months;
43 42 months << "May" << "Jun" << "Jul" << "Aug" << "Sep";
44 43 QStringList weeks;
45 44 weeks << "week 1" << "week 2" << "week 3" << "week 4";
46 45 QStringList plants;
47 46 plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo";
48 47 //! [2]
49 48
50 49 //! [3]
51 50 // Create drilldown structure
52 51 DrilldownBarSeries *seasonSeries = new DrilldownBarSeries(months, drilldownChart);
53 52 seasonSeries->setName("Crop by month - Season");
54 53
55 54 // Each month in season series has drilldown series for weekly data
56 55 for (int month = 0; month < months.count(); month++) {
57 56
58 57 // Create drilldown series for every week
59 58 DrilldownBarSeries *weeklySeries = new DrilldownBarSeries(weeks, drilldownChart);
60 59 seasonSeries->mapDrilldownSeries(month, weeklySeries);
61 60
62 61 // Drilling down from weekly data brings us back to season data.
63 62 for (int week = 0; week < weeks.count(); week++) {
64 63 weeklySeries->mapDrilldownSeries(week, seasonSeries);
65 64 weeklySeries->setName(QString("Crop by week - " + months.at(month)));
66 65 }
67 66
68 67 // Use clicked signal to implement drilldown
69 68 QObject::connect(weeklySeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*)));
70 69 }
71 70
72 71 // Enable drilldown from season series using clicked signal
73 72 QObject::connect(seasonSeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*)));
74 73 //! [3]
75 74
76 75 //! [4]
77 76 // Fill monthly and weekly series with data
78 77 foreach (QString plant, plants) {
79 78 QBarSet *monthlyCrop = new QBarSet(plant);
80 79 for (int month = 0; month < months.count(); month++) {
81 80 QBarSet *weeklyCrop = new QBarSet(plant);
82 81 for (int week = 0; week < weeks.count(); week++)
83 82 *weeklyCrop << (qrand() % 20);
84 83 // Get the drilldown series from season series and add crop to it.
85 84 seasonSeries->drilldownSeries(month)->append(weeklyCrop);
86 85 *monthlyCrop << weeklyCrop->sum();
87 86 }
88 87 seasonSeries->append(monthlyCrop);
89 88 }
90 89 //! [4]
91 90
92 91 //! [5]
93 92 // Show season series in initial view
94 93 drilldownChart->changeSeries(seasonSeries);
95 94 drilldownChart->setTitle(seasonSeries->name());
96 95 //! [5]
97 96
98 97 //! [6]
99 98 drilldownChart->axisX()->setGridLineVisible(false);
100 99 drilldownChart->legend()->setVisible(true);
101 100 drilldownChart->legend()->setAlignment(Qt::AlignBottom);
102 101 //! [6]
103 102
104 103 QChartView *chartView = new QChartView(drilldownChart);
105 104 window.setCentralWidget(chartView);
106 105 window.resize(480, 300);
107 106 window.show();
108 107
109 108 return a.exec();
110 109 }
111 110
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now