@@ -54,7 +54,7 public: | |||||
54 | // create layout |
|
54 | // create layout | |
55 | QGridLayout* baseLayout = new QGridLayout(); |
|
55 | QGridLayout* baseLayout = new QGridLayout(); | |
56 |
|
56 | |||
57 | // theme combo |
|
57 | // settings layout | |
58 | m_themeComboBox = new QComboBox(); |
|
58 | m_themeComboBox = new QComboBox(); | |
59 | m_themeComboBox->addItem("Default", QChart::ChartThemeDefault); |
|
59 | m_themeComboBox->addItem("Default", QChart::ChartThemeDefault); | |
60 | m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla); |
|
60 | m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla); | |
@@ -64,13 +64,21 public: | |||||
64 | m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); |
|
64 | m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); | |
65 | m_themeComboBox->addItem("Light", QChart::ChartThemeLight); |
|
65 | m_themeComboBox->addItem("Light", QChart::ChartThemeLight); | |
66 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme())); |
|
66 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme())); | |
67 | baseLayout->addWidget(new QLabel("Theme:"), 0, 0); |
|
67 | QCheckBox *antialiasCheckBox = new QCheckBox("Anti aliasing"); | |
68 | baseLayout->addWidget(m_themeComboBox, 0, 1); |
|
68 | connect(antialiasCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAntialiasing(bool))); | |
|
69 | QCheckBox *animatedCheckBox = new QCheckBox("Animated"); | |||
|
70 | connect(animatedCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAnimations(bool))); | |||
|
71 | QHBoxLayout *settingsLayout = new QHBoxLayout(); | |||
|
72 | settingsLayout->addWidget(new QLabel("Theme:")); | |||
|
73 | settingsLayout->addWidget(m_themeComboBox); | |||
|
74 | settingsLayout->addWidget(antialiasCheckBox); | |||
|
75 | settingsLayout->addWidget(animatedCheckBox); | |||
|
76 | settingsLayout->addStretch(); | |||
|
77 | baseLayout->addLayout(settingsLayout, 0, 0, 1, 3); | |||
69 |
|
78 | |||
70 | // area chart |
|
79 | // area chart | |
71 | QChartView *chart = new QChartView(); |
|
80 | QChartView *chart = new QChartView(); | |
72 | chart->setChartTitle("Area chart"); |
|
81 | chart->setChartTitle("Area chart"); | |
73 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
74 | baseLayout->addWidget(chart, 1, 0); |
|
82 | baseLayout->addWidget(chart, 1, 0); | |
75 | { |
|
83 | { | |
76 | for (int i(0); i < m_dataTable.count(); i++) { |
|
84 | for (int i(0); i < m_dataTable.count(); i++) { | |
@@ -89,7 +97,6 public: | |||||
89 | // bar chart |
|
97 | // bar chart | |
90 | chart = new QChartView(); |
|
98 | chart = new QChartView(); | |
91 | chart->setChartTitle("bar chart"); |
|
99 | chart->setChartTitle("bar chart"); | |
92 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
93 | baseLayout->addWidget(chart, 1, 1); |
|
100 | baseLayout->addWidget(chart, 1, 1); | |
94 | { |
|
101 | { | |
95 | QStringList categories; |
|
102 | QStringList categories; | |
@@ -110,7 +117,6 public: | |||||
110 | // line chart |
|
117 | // line chart | |
111 | chart = new QChartView(); |
|
118 | chart = new QChartView(); | |
112 | chart->setChartTitle("line chart"); |
|
119 | chart->setChartTitle("line chart"); | |
113 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
114 | baseLayout->addWidget(chart, 1, 2); |
|
120 | baseLayout->addWidget(chart, 1, 2); | |
115 | foreach (DataList list, m_dataTable) { |
|
121 | foreach (DataList list, m_dataTable) { | |
116 | QLineSeries *series = new QLineSeries(chart); |
|
122 | QLineSeries *series = new QLineSeries(chart); | |
@@ -123,9 +129,7 public: | |||||
123 | // pie chart |
|
129 | // pie chart | |
124 | chart = new QChartView(); |
|
130 | chart = new QChartView(); | |
125 | chart->setChartTitle("pie chart"); |
|
131 | chart->setChartTitle("pie chart"); | |
126 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
127 | baseLayout->addWidget(chart, 2, 0); |
|
132 | baseLayout->addWidget(chart, 2, 0); | |
128 |
|
||||
129 | qreal pieSize = 1.0 / m_dataTable.count(); |
|
133 | qreal pieSize = 1.0 / m_dataTable.count(); | |
130 | for (int i=0; i<m_dataTable.count(); i++) { |
|
134 | for (int i=0; i<m_dataTable.count(); i++) { | |
131 | QPieSeries *series = new QPieSeries(chart); |
|
135 | QPieSeries *series = new QPieSeries(chart); | |
@@ -141,7 +145,6 public: | |||||
141 | // spine chart |
|
145 | // spine chart | |
142 | chart = new QChartView(); |
|
146 | chart = new QChartView(); | |
143 | chart->setChartTitle("spline chart"); |
|
147 | chart->setChartTitle("spline chart"); | |
144 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
145 | baseLayout->addWidget(chart, 2, 1); |
|
148 | baseLayout->addWidget(chart, 2, 1); | |
146 | foreach (DataList list, m_dataTable) { |
|
149 | foreach (DataList list, m_dataTable) { | |
147 | QSplineSeries *series = new QSplineSeries(chart); |
|
150 | QSplineSeries *series = new QSplineSeries(chart); | |
@@ -154,7 +157,6 public: | |||||
154 | // scatter chart |
|
157 | // scatter chart | |
155 | chart = new QChartView(); |
|
158 | chart = new QChartView(); | |
156 | chart->setChartTitle("scatter chart"); |
|
159 | chart->setChartTitle("scatter chart"); | |
157 | chart->setRenderHint(QPainter::Antialiasing); |
|
|||
158 | baseLayout->addWidget(chart, 2, 2); |
|
160 | baseLayout->addWidget(chart, 2, 2); | |
159 | foreach (DataList list, m_dataTable) { |
|
161 | foreach (DataList list, m_dataTable) { | |
160 | QScatterSeries *series = new QScatterSeries(chart); |
|
162 | QScatterSeries *series = new QScatterSeries(chart); | |
@@ -186,6 +188,22 public Q_SLOTS: | |||||
186 | window()->setPalette(pal); |
|
188 | window()->setPalette(pal); | |
187 | } |
|
189 | } | |
188 |
|
190 | |||
|
191 | void updateAntialiasing(bool enabled) | |||
|
192 | { | |||
|
193 | foreach (QChartView *chart, m_charts) | |||
|
194 | chart->setRenderHint(QPainter::Antialiasing, enabled); | |||
|
195 | } | |||
|
196 | ||||
|
197 | void updateAnimations(bool animated) | |||
|
198 | { | |||
|
199 | QChart::AnimationOptions options = QChart::NoAnimation; | |||
|
200 | if (animated) | |||
|
201 | options = QChart::AllAnimations; | |||
|
202 | ||||
|
203 | foreach (QChartView *chart, m_charts) | |||
|
204 | chart->setAnimationOptions(options); | |||
|
205 | } | |||
|
206 | ||||
189 | private: |
|
207 | private: | |
190 | QList<QChartView*> m_charts; |
|
208 | QList<QChartView*> m_charts; | |
191 | QComboBox *m_themeComboBox; |
|
209 | QComboBox *m_themeComboBox; |
General Comments 0
You need to be logged in to leave comments.
Login now