@@ -1,47 +1,49 | |||
|
1 | 1 | #include <QApplication> |
|
2 | 2 | #include <QMainWindow> |
|
3 | 3 | #include <QStandardItemModel> |
|
4 | 4 | #include <percentbarchartseries.h> |
|
5 | 5 | #include "chartwidget.h" |
|
6 | #include <qbarcategory.h> | |
|
7 | #include <qbarset.h> | |
|
6 | 8 | |
|
7 | 9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | 10 | |
|
9 | 11 | int main(int argc, char *argv[]) |
|
10 | 12 | { |
|
11 | 13 | QApplication a(argc, argv); |
|
12 | 14 | QMainWindow window; |
|
13 | 15 | |
|
14 | PercentBarChartSeries* series0 = new PercentBarChartSeries(); | |
|
16 | QBarCategory category; | |
|
17 | category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec"; | |
|
18 | ||
|
19 | PercentBarChartSeries* series0 = new PercentBarChartSeries(category); | |
|
20 | ||
|
21 | QBarSet barSet0; | |
|
22 | QBarSet barSet1; | |
|
23 | QBarSet barSet2; | |
|
24 | QBarSet barSet3; | |
|
25 | QBarSet barSet4; | |
|
15 | 26 | |
|
16 | 27 | // Create some test data to chart |
|
17 | QList<qreal> data0; | |
|
18 |
|
|
|
19 | QList<qreal> data1; | |
|
20 |
|
|
|
21 | QList<qreal> data2; | |
|
22 | data2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; | |
|
23 | QList<qreal> data3; | |
|
24 | data3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; | |
|
25 | QList<qreal> data4; | |
|
26 | data4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; | |
|
27 | ||
|
28 | series0->addData(data0); | |
|
29 | series0->addData(data1); | |
|
30 | series0->addData(data2); | |
|
31 | series0->addData(data3); | |
|
32 | series0->addData(data4); | |
|
33 | ||
|
34 | QList<QString> labels; | |
|
35 | labels << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec"; | |
|
36 | series0->setLabels(labels); | |
|
28 | barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; | |
|
29 | barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; | |
|
30 | barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; | |
|
31 | barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; | |
|
32 | barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; | |
|
33 | ||
|
34 | series0->addBarSet(barSet0); | |
|
35 | series0->addBarSet(barSet1); | |
|
36 | series0->addBarSet(barSet2); | |
|
37 | series0->addBarSet(barSet3); | |
|
38 | series0->addBarSet(barSet4); | |
|
37 | 39 | |
|
38 | 40 | ChartWidget* chartWidget = new ChartWidget(&window); |
|
39 | 41 | chartWidget->addSeries(series0); |
|
40 | 42 | |
|
41 | 43 | window.setCentralWidget(chartWidget); |
|
42 | 44 | window.resize(400, 300); |
|
43 | 45 | window.show(); |
|
44 | 46 | |
|
45 | 47 | return a.exec(); |
|
46 | 48 | } |
|
47 | 49 |
@@ -1,47 +1,49 | |||
|
1 | 1 | #include <QApplication> |
|
2 | 2 | #include <QMainWindow> |
|
3 | 3 | #include <QStandardItemModel> |
|
4 | 4 | #include <stackedbarchartseries.h> |
|
5 | 5 | #include "chartwidget.h" |
|
6 | #include <qbarset.h> | |
|
7 | #include <qbarcategory.h> | |
|
6 | 8 | |
|
7 | 9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | 10 | |
|
9 | 11 | int main(int argc, char *argv[]) |
|
10 | 12 | { |
|
11 | 13 | QApplication a(argc, argv); |
|
12 | 14 | QMainWindow window; |
|
13 | 15 | |
|
14 | StackedBarChartSeries* series0 = new StackedBarChartSeries(); | |
|
16 | QBarCategory category; | |
|
17 | category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec"; | |
|
18 | ||
|
19 | StackedBarChartSeries* series0 = new StackedBarChartSeries(category); | |
|
20 | ||
|
21 | QBarSet barSet0; | |
|
22 | QBarSet barSet1; | |
|
23 | QBarSet barSet2; | |
|
24 | QBarSet barSet3; | |
|
25 | QBarSet barSet4; | |
|
15 | 26 | |
|
16 | 27 | // Create some test data to chart |
|
17 | QList<qreal> data0; | |
|
18 |
|
|
|
19 | QList<qreal> data1; | |
|
20 |
|
|
|
21 | QList<qreal> data2; | |
|
22 | data2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; | |
|
23 | QList<qreal> data3; | |
|
24 | data3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; | |
|
25 | QList<qreal> data4; | |
|
26 | data4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; | |
|
27 | ||
|
28 | series0->addData(data0); | |
|
29 | series0->addData(data1); | |
|
30 | series0->addData(data2); | |
|
31 | series0->addData(data3); | |
|
32 | series0->addData(data4); | |
|
33 | ||
|
34 | QList<QString> labels; | |
|
35 | labels << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec"; | |
|
36 | series0->setLabels(labels); | |
|
28 | barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; | |
|
29 | barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; | |
|
30 | barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; | |
|
31 | barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; | |
|
32 | barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; | |
|
33 | ||
|
34 | series0->addBarSet(barSet0); | |
|
35 | series0->addBarSet(barSet1); | |
|
36 | series0->addBarSet(barSet2); | |
|
37 | series0->addBarSet(barSet3); | |
|
38 | series0->addBarSet(barSet4); | |
|
37 | 39 | |
|
38 | 40 | ChartWidget* chartWidget = new ChartWidget(&window); |
|
39 | 41 | chartWidget->addSeries(series0); |
|
40 | 42 | |
|
41 | 43 | window.setCentralWidget(chartWidget); |
|
42 | 44 | window.resize(400, 300); |
|
43 | 45 | window.show(); |
|
44 | 46 | |
|
45 | 47 | return a.exec(); |
|
46 | 48 | } |
|
47 | 49 |
General Comments 0
You need to be logged in to leave comments.
Login now