@@ -0,0 +1,7 | |||
|
1 | !include( ../demos.pri ) { | |
|
2 | error( "Couldn't find the examples.pri file!" ) | |
|
3 | } | |
|
4 | TARGET = chartthemes | |
|
5 | SOURCES += main.cpp | |
|
6 | ||
|
7 |
@@ -0,0 +1,180 | |||
|
1 | #include <QtGui/QApplication> | |
|
2 | #include <QMainWindow> | |
|
3 | #include <qchartglobal.h> | |
|
4 | #include <qchartview.h> | |
|
5 | #include <qpieseries.h> | |
|
6 | #include <qpieslice.h> | |
|
7 | #include <QGridLayout> | |
|
8 | #include <QFormLayout> | |
|
9 | #include <QComboBox> | |
|
10 | #include <QSpinBox> | |
|
11 | #include <QCheckBox> | |
|
12 | #include <QGroupBox> | |
|
13 | #include <QLabel> | |
|
14 | #include <QTime> | |
|
15 | #include <qlineseries.h> | |
|
16 | #include <qsplineseries.h> | |
|
17 | #include <qscatterseries.h> | |
|
18 | #include <qareaseries.h> | |
|
19 | ||
|
20 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
21 | ||
|
22 | typedef QPair<QPointF, QString> Data; | |
|
23 | typedef QList<Data> DataList; | |
|
24 | typedef QList<DataList> DataTable; | |
|
25 | ||
|
26 | ||
|
27 | class MainWidget : public QWidget | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | ||
|
31 | public: | |
|
32 | explicit MainWidget(QWidget* parent = 0) | |
|
33 | :QWidget(parent) | |
|
34 | { | |
|
35 | // set seed for random stuff | |
|
36 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | |
|
37 | ||
|
38 | // generate random data | |
|
39 | int listCount = 3; | |
|
40 | int valueMax = 100; | |
|
41 | int valueCount = 50; | |
|
42 | for (int i=0; i<listCount; i++) { | |
|
43 | DataList dataList; | |
|
44 | for (int j=0; j<valueCount; j++) { | |
|
45 | QPointF value(qrand() % valueMax, qrand() % valueMax); | |
|
46 | QString label = QString::number(i) + ":" + QString::number(j); | |
|
47 | dataList << Data(value, label); | |
|
48 | } | |
|
49 | m_dataTable << dataList; | |
|
50 | } | |
|
51 | ||
|
52 | // create layout | |
|
53 | QGridLayout* baseLayout = new QGridLayout(); | |
|
54 | ||
|
55 | // theme combo | |
|
56 | m_themeComboBox = new QComboBox(); | |
|
57 | m_themeComboBox->addItem("Default", QChart::ChartThemeDefault); | |
|
58 | m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla); | |
|
59 | m_themeComboBox->addItem("Icy", QChart::ChartThemeIcy); | |
|
60 | m_themeComboBox->addItem("Grayscale", QChart::ChartThemeGrayscale); | |
|
61 | m_themeComboBox->addItem("Scientific", QChart::ChartThemeScientific); | |
|
62 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme())); | |
|
63 | baseLayout->addWidget(new QLabel("Theme:"), 0, 0); | |
|
64 | baseLayout->addWidget(m_themeComboBox, 0, 1); | |
|
65 | ||
|
66 | // area chart | |
|
67 | QChartView *chart = new QChartView(); | |
|
68 | chart->setChartTitle("Area chart"); | |
|
69 | chart->setRenderHint(QPainter::Antialiasing); | |
|
70 | baseLayout->addWidget(chart, 1, 0); | |
|
71 | { | |
|
72 | QLineSeries *series1 = new QLineSeries(chart); | |
|
73 | foreach (Data data, m_dataTable.first()) | |
|
74 | series1->add(data.first); | |
|
75 | QLineSeries *series2 = new QLineSeries(chart); | |
|
76 | foreach (Data data, m_dataTable.last()) | |
|
77 | series2->add(data.first); | |
|
78 | QAreaSeries *series = new QAreaSeries(series1, series2); | |
|
79 | chart->addSeries(series); | |
|
80 | } | |
|
81 | m_charts << chart; | |
|
82 | ||
|
83 | // bar chart | |
|
84 | chart = new QChartView(); | |
|
85 | chart->setChartTitle("bar chart"); | |
|
86 | chart->setRenderHint(QPainter::Antialiasing); | |
|
87 | baseLayout->addWidget(chart, 1, 1); | |
|
88 | m_charts << chart; | |
|
89 | ||
|
90 | // line chart | |
|
91 | chart = new QChartView(); | |
|
92 | chart->setChartTitle("line chart"); | |
|
93 | chart->setRenderHint(QPainter::Antialiasing); | |
|
94 | baseLayout->addWidget(chart, 1, 2); | |
|
95 | foreach (DataList list, m_dataTable) { | |
|
96 | QLineSeries *series = new QLineSeries(chart); | |
|
97 | foreach (Data data, list) | |
|
98 | series->add(data.first); | |
|
99 | chart->addSeries(series); | |
|
100 | } | |
|
101 | m_charts << chart; | |
|
102 | ||
|
103 | // pie chart | |
|
104 | chart = new QChartView(); | |
|
105 | chart->setChartTitle("pie chart"); | |
|
106 | chart->setRenderHint(QPainter::Antialiasing); | |
|
107 | baseLayout->addWidget(chart, 2, 0); | |
|
108 | ||
|
109 | qreal pieSize = 1.0 / m_dataTable.count(); | |
|
110 | for (int i=0; i<m_dataTable.count(); i++) { | |
|
111 | QPieSeries *series = new QPieSeries(chart); | |
|
112 | foreach (Data data, m_dataTable[i]) | |
|
113 | series->add(data.first.x(), data.second); | |
|
114 | qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count()); | |
|
115 | series->setPieSize(pieSize); | |
|
116 | series->setPiePosition(hPos, 0.5); | |
|
117 | chart->addSeries(series); | |
|
118 | } | |
|
119 | m_charts << chart; | |
|
120 | ||
|
121 | // spine chart | |
|
122 | chart = new QChartView(); | |
|
123 | chart->setChartTitle("spline chart"); | |
|
124 | chart->setRenderHint(QPainter::Antialiasing); | |
|
125 | baseLayout->addWidget(chart, 2, 1); | |
|
126 | foreach (DataList list, m_dataTable) { | |
|
127 | QSplineSeries *series = new QSplineSeries(chart); | |
|
128 | foreach (Data data, list) | |
|
129 | series->add(data.first); | |
|
130 | chart->addSeries(series); | |
|
131 | } | |
|
132 | m_charts << chart; | |
|
133 | ||
|
134 | // scatter chart | |
|
135 | chart = new QChartView(); | |
|
136 | chart->setChartTitle("scatter chart"); | |
|
137 | chart->setRenderHint(QPainter::Antialiasing); | |
|
138 | baseLayout->addWidget(chart, 2, 2); | |
|
139 | foreach (DataList list, m_dataTable) { | |
|
140 | QScatterSeries *series = new QScatterSeries(chart); | |
|
141 | foreach (Data data, list) | |
|
142 | series->add(data.first); | |
|
143 | chart->addSeries(series); | |
|
144 | } | |
|
145 | m_charts << chart; | |
|
146 | ||
|
147 | setLayout(baseLayout); | |
|
148 | } | |
|
149 | ||
|
150 | public Q_SLOTS: | |
|
151 | ||
|
152 | void updateTheme() | |
|
153 | { | |
|
154 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); | |
|
155 | foreach (QChartView *chart, m_charts) | |
|
156 | chart->setChartTheme(theme); | |
|
157 | } | |
|
158 | ||
|
159 | private: | |
|
160 | QList<QChartView*> m_charts; | |
|
161 | QComboBox *m_themeComboBox; | |
|
162 | DataTable m_dataTable; | |
|
163 | }; | |
|
164 | ||
|
165 | int main(int argc, char *argv[]) | |
|
166 | { | |
|
167 | QApplication a(argc, argv); | |
|
168 | ||
|
169 | QMainWindow window; | |
|
170 | ||
|
171 | MainWidget* widget = new MainWidget(); | |
|
172 | ||
|
173 | window.setCentralWidget(widget); | |
|
174 | window.resize(900, 600); | |
|
175 | window.show(); | |
|
176 | ||
|
177 | return a.exec(); | |
|
178 | } | |
|
179 | ||
|
180 | #include "main.moc" |
@@ -0,0 +1,16 | |||
|
1 | !include( ../common.pri ) { | |
|
2 | error( "Couldn't find the common.pri file!" ) | |
|
3 | } | |
|
4 | ||
|
5 | !include( ../integrated.pri ) { | |
|
6 | error( "Couldn't find the integrated.pri file !") | |
|
7 | } | |
|
8 | ||
|
9 | DESTDIR = $$CHART_BUILD_BIN_DIR | |
|
10 | OBJECTS_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
|
11 | MOC_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
|
12 | UI_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
|
13 | RCC_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
|
14 | ||
|
15 | TEMPLATE = app | |
|
16 | QT += core gui No newline at end of file |
@@ -0,0 +1,3 | |||
|
1 | TEMPLATE = subdirs | |
|
2 | SUBDIRS += chartthemes \ | |
|
3 | piechartcustomization No newline at end of file |
@@ -1,31 +1,31 | |||
|
1 | 1 | !include(common.pri) { |
|
2 | 2 | error('missing common.pri') |
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TEMPLATE = subdirs |
|
6 | SUBDIRS += src examples test qmlplugin | |
|
6 | SUBDIRS += src examples demos test qmlplugin | |
|
7 | 7 | |
|
8 | 8 | integrated_build:{ |
|
9 | 9 | message('Configured for integrated build') |
|
10 | 10 | } else { |
|
11 | 11 | message('Please build example test and qmlplugin after installing library.') |
|
12 | 12 | } |
|
13 | 13 | |
|
14 | 14 | CONFIG += ordered |
|
15 | 15 | QMAKE_CXXFLAGS += -g -Wall |
|
16 | 16 | unix:QMAKE_DISTCLEAN += -r build bin include lib doc/html |
|
17 | 17 | win32:QMAKE_DISTCLEAN += /Q /s build bin include lib doc\\html |
|
18 | 18 | |
|
19 | 19 | # install feature file |
|
20 | 20 | feature.path = $$[QT_INSTALL_DATA]/mkspecs/features |
|
21 | 21 | feature.files = $$PWD/features/qtcommercialchart.prf |
|
22 | 22 | INSTALLS += feature |
|
23 | 23 | |
|
24 | 24 | doc.target = doc |
|
25 | 25 | win32:{ |
|
26 | 26 | doc.commands = qdoc3 $$CHART_BUILD_DOC_DIR\\qcharts.qdocconf |
|
27 | 27 | }else{ |
|
28 | 28 | doc.commands = qdoc3 $$CHART_BUILD_DOC_DIR/qcharts.qdocconf |
|
29 | 29 | } |
|
30 | 30 | doc.depends = FORCE |
|
31 | 31 | QMAKE_EXTRA_TARGETS += doc |
|
1 | NO CONTENT: file renamed from examples/piechartcustomization/main.cpp to demos/piechartcustomization/main.cpp |
@@ -1,7 +1,7 | |||
|
1 |
!include( ../ |
|
|
1 | !include( ../demos.pri ) { | |
|
2 | 2 | error( "Couldn't find the examples.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | TARGET = piechartcustomization |
|
5 | 5 | SOURCES += main.cpp |
|
6 | 6 | |
|
7 | 7 |
@@ -1,24 +1,23 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | SUBDIRS += linechart \ |
|
3 | 3 | zoomlinechart \ |
|
4 | 4 | colorlinechart \ |
|
5 | 5 | barchart \ |
|
6 | 6 | stackedbarchart \ |
|
7 | 7 | percentbarchart \ |
|
8 | 8 | scatterchart \ |
|
9 | 9 | piechart \ |
|
10 | piechartcustomization \ | |
|
11 | 10 | piechartdrilldown \ |
|
12 | 11 | dynamiclinechart \ |
|
13 | 12 | axischart \ |
|
14 | 13 | multichart \ |
|
15 | 14 | gdpbarchart \ |
|
16 | 15 | presenterchart \ |
|
17 | 16 | chartview \ |
|
18 | 17 | scatterinteractions \ |
|
19 | 18 | splinechart \ |
|
20 | 19 | areachart \ |
|
21 | 20 | stackedbarchartdrilldown \ |
|
22 | 21 | customcolors |
|
23 | 22 | |
|
24 | 23 |
General Comments 0
You need to be logged in to leave comments.
Login now