##// END OF EJS Templates
Added axis related modifiers to theme
Tero Ahola -
r548:426b0f7a9c96
parent child
Show More
@@ -1,317 +1,332
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qlegend.h"
3 #include "qlegend.h"
4 #include "qchartaxis.h"
4 #include "qchartaxis.h"
5 #include <QTime>
5 #include <QTime>
6
6
7 //series
7 //series
8 #include "qbarset.h"
8 #include "qbarset.h"
9 #include "qbarseries.h"
9 #include "qbarseries.h"
10 #include "qstackedbarseries.h"
10 #include "qstackedbarseries.h"
11 #include "qpercentbarseries.h"
11 #include "qpercentbarseries.h"
12 #include "qlineseries.h"
12 #include "qlineseries.h"
13 #include "qareaseries.h"
13 #include "qareaseries.h"
14 #include "qscatterseries.h"
14 #include "qscatterseries.h"
15 #include "qpieseries.h"
15 #include "qpieseries.h"
16 #include "qpieslice.h"
16 #include "qpieslice.h"
17 #include "qsplineseries.h"
17 #include "qsplineseries.h"
18
18
19 //items
19 //items
20 #include "axisitem_p.h"
20 #include "axisitem_p.h"
21 #include "barpresenter_p.h"
21 #include "barpresenter_p.h"
22 #include "stackedbarpresenter_p.h"
22 #include "stackedbarpresenter_p.h"
23 #include "percentbarpresenter_p.h"
23 #include "percentbarpresenter_p.h"
24 #include "linechartitem_p.h"
24 #include "linechartitem_p.h"
25 #include "areachartitem_p.h"
25 #include "areachartitem_p.h"
26 #include "scatterchartitem_p.h"
26 #include "scatterchartitem_p.h"
27 #include "piepresenter_p.h"
27 #include "piepresenter_p.h"
28 #include "splinechartitem_p.h"
28 #include "splinechartitem_p.h"
29
29
30 //themes
30 //themes
31 #include "chartthemedefault_p.h"
31 #include "chartthemedefault_p.h"
32 #include "chartthemevanilla_p.h"
32 #include "chartthemevanilla_p.h"
33 #include "chartthemeicy_p.h"
33 #include "chartthemeicy_p.h"
34 #include "chartthemegrayscale_p.h"
34 #include "chartthemegrayscale_p.h"
35 #include "chartthemescientific_p.h"
35 #include "chartthemescientific_p.h"
36
36
37
37
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39
39
40 ChartTheme::ChartTheme(QChart::ChartTheme id)
40 ChartTheme::ChartTheme(QChart::ChartTheme id)
41 {
41 {
42 m_id = id;
42 m_id = id;
43 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
43 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
44 }
44 }
45
45
46
46
47 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
47 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
48 {
48 {
49 switch(theme) {
49 switch(theme) {
50 case QChart::ChartThemeVanilla:
50 case QChart::ChartThemeVanilla:
51 return new ChartThemeVanilla();
51 return new ChartThemeVanilla();
52 case QChart::ChartThemeIcy:
52 case QChart::ChartThemeIcy:
53 return new ChartThemeIcy();
53 return new ChartThemeIcy();
54 case QChart::ChartThemeGrayscale:
54 case QChart::ChartThemeGrayscale:
55 return new ChartThemeGrayscale();
55 return new ChartThemeGrayscale();
56 case QChart::ChartThemeScientific:
56 case QChart::ChartThemeScientific:
57 return new ChartThemeScientific();
57 return new ChartThemeScientific();
58 default:
58 default:
59 return new ChartThemeDefault();
59 return new ChartThemeDefault();
60 }
60 }
61 }
61 }
62
62
63 void ChartTheme::decorate(QChart* chart)
63 void ChartTheme::decorate(QChart* chart)
64 {
64 {
65 chart->setChartBackgroundBrush(m_backgroundGradient);
65 chart->setChartBackgroundBrush(m_backgroundGradient);
66 }
66 }
67
67
68 void ChartTheme::decorate(QLegend* legend)
68 void ChartTheme::decorate(QLegend* legend)
69 {
69 {
70 legend->setBackgroundBrush(m_backgroundGradient);
70 legend->setBackgroundBrush(m_backgroundGradient);
71 }
71 }
72
72
73 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
73 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
74 {
74 {
75 QPen pen;
75 QPen pen;
76 QBrush brush;
76 QBrush brush;
77
77
78 if (pen != series->pen()){
78 if (pen != series->pen()){
79 item->setPen(series->pen());
79 item->setPen(series->pen());
80 } else {
80 } else {
81 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
81 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
82 pen.setWidthF(2);
82 pen.setWidthF(2);
83 item->setPen(pen);
83 item->setPen(pen);
84 }
84 }
85
85
86 if (brush != series->brush()) {
86 if (brush != series->brush()) {
87 item->setBrush(series->brush());
87 item->setBrush(series->brush());
88 } else {
88 } else {
89 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
89 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
90 item->setBrush(brush);
90 item->setBrush(brush);
91 }
91 }
92 }
92 }
93
93
94
94
95 void ChartTheme::decorate(LineChartItem* item, QLineSeries* series,int index)
95 void ChartTheme::decorate(LineChartItem* item, QLineSeries* series,int index)
96 {
96 {
97 QPen pen;
97 QPen pen;
98 if(pen != series->pen()){
98 if(pen != series->pen()){
99 series->setPen(series->pen());
99 series->setPen(series->pen());
100 return;
100 return;
101 }else{
101 }else{
102 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
102 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
103 pen.setWidthF(2);
103 pen.setWidthF(2);
104 series->setPen(pen);
104 series->setPen(pen);
105 }
105 }
106 }
106 }
107
107
108 void ChartTheme::decorate(BarPresenter* item, QBarSeries* series,int index)
108 void ChartTheme::decorate(BarPresenter* item, QBarSeries* series,int index)
109 {
109 {
110 QList<QBarSet*> sets = series->barSets();
110 QList<QBarSet*> sets = series->barSets();
111 for (int i=0; i<sets.count(); i++) {
111 for (int i=0; i<sets.count(); i++) {
112 qreal pos = 0.5;
112 qreal pos = 0.5;
113 if (sets.count() > 1)
113 if (sets.count() > 1)
114 pos = (qreal) i / (qreal) (sets.count() - 1);
114 pos = (qreal) i / (qreal) (sets.count() - 1);
115 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
115 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
116 sets.at(i)->setBrush(QBrush(c));
116 sets.at(i)->setBrush(QBrush(c));
117
117
118 // Pick label color as far as possible from bar color (within gradient).
118 // Pick label color as far as possible from bar color (within gradient).
119 // 0.3 is magic number that was picked as value that gave enough contrast with icy theme gradient :)
119 // 0.3 is magic number that was picked as value that gave enough contrast with icy theme gradient :)
120 // TODO: better picking of label color?
120 // TODO: better picking of label color?
121 if (pos < 0.3) {
121 if (pos < 0.3) {
122 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
122 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
123 } else {
123 } else {
124 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
124 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
125 }
125 }
126 sets.at(i)->setFloatingValuePen(QPen(c));
126 sets.at(i)->setFloatingValuePen(QPen(c));
127 }
127 }
128 }
128 }
129
129
130 void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarSeries* series,int index)
130 void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarSeries* series,int index)
131 {
131 {
132 QList<QBarSet*> sets = series->barSets();
132 QList<QBarSet*> sets = series->barSets();
133 for (int i=0; i<sets.count(); i++) {
133 for (int i=0; i<sets.count(); i++) {
134 qreal pos = 0.5;
134 qreal pos = 0.5;
135 if (sets.count() > 1)
135 if (sets.count() > 1)
136 pos = (qreal) i / (qreal) (sets.count() - 1);
136 pos = (qreal) i / (qreal) (sets.count() - 1);
137 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
137 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
138 sets.at(i)->setBrush(QBrush(c));
138 sets.at(i)->setBrush(QBrush(c));
139
139
140 if (pos < 0.3) {
140 if (pos < 0.3) {
141 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
141 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
142 } else {
142 } else {
143 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
143 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
144 }
144 }
145 sets.at(i)->setFloatingValuePen(QPen(c));
145 sets.at(i)->setFloatingValuePen(QPen(c));
146 }
146 }
147 }
147 }
148
148
149 void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarSeries* series,int index)
149 void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarSeries* series,int index)
150 {
150 {
151 QList<QBarSet*> sets = series->barSets();
151 QList<QBarSet*> sets = series->barSets();
152 for (int i=0; i<sets.count(); i++) {
152 for (int i=0; i<sets.count(); i++) {
153 qreal pos = 0.5;
153 qreal pos = 0.5;
154 if (sets.count() > 1)
154 if (sets.count() > 1)
155 pos = (qreal) i / (qreal) (sets.count() - 1);
155 pos = (qreal) i / (qreal) (sets.count() - 1);
156 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
156 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
157 sets.at(i)->setBrush(QBrush(c));
157 sets.at(i)->setBrush(QBrush(c));
158
158
159 if (pos < 0.3) {
159 if (pos < 0.3) {
160 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
160 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
161 } else {
161 } else {
162 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
162 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
163 }
163 }
164 sets.at(i)->setFloatingValuePen(QPen(c));
164 sets.at(i)->setFloatingValuePen(QPen(c));
165 }
165 }
166 }
166 }
167
167
168 void ChartTheme::decorate(ScatterChartItem* item, QScatterSeries* series, int index)
168 void ChartTheme::decorate(ScatterChartItem* item, QScatterSeries* series, int index)
169 {
169 {
170 Q_ASSERT(item);
170 Q_ASSERT(item);
171 Q_ASSERT(series);
171 Q_ASSERT(series);
172
172
173 QPen pen;
173 QPen pen;
174 QBrush brush;
174 QBrush brush;
175
175
176 if (pen == series->pen()) {
176 if (pen == series->pen()) {
177 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
177 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
178 pen.setWidthF(2);
178 pen.setWidthF(2);
179 series->setPen(pen);
179 series->setPen(pen);
180 }
180 }
181
181
182 if (brush == series->brush()) {
182 if (brush == series->brush()) {
183 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
183 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
184 series->setBrush(brush);
184 series->setBrush(brush);
185 }
185 }
186 }
186 }
187
187
188 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int index)
188 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int index)
189 {
189 {
190 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
190 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
191 for (int i(0); i < series->slices().count(); i++) {
191 for (int i(0); i < series->slices().count(); i++) {
192 qreal pos = (qreal) i / (qreal) series->count();
192 qreal pos = (qreal) i / (qreal) series->count();
193 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.1);
193 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.1);
194 series->slices().at(i)->setSlicePen(penColor);
194 series->slices().at(i)->setSlicePen(penColor);
195 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
195 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
196 series->slices().at(i)->setSliceBrush(brushColor);
196 series->slices().at(i)->setSliceBrush(brushColor);
197 }
197 }
198 }
198 }
199
199
200
201 void ChartTheme::decorate(QChartAxis* axis, AxisItem* item)
202 {
203 //TODO: dummy defults for now
204 axis->setLabelsBrush(Qt::black);
205 axis->setLabelsPen(Qt::NoPen);
206 axis->setShadesPen(Qt::NoPen);
207 axis->setShadesOpacity(0.5);
208 }
209
210 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
200 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
211 {
201 {
212 Q_ASSERT(item);
202 Q_ASSERT(item);
213 Q_ASSERT(series);
203 Q_ASSERT(series);
214
204
215 QPen pen;
205 QPen pen;
216
206
217 if(pen != series->pen()){
207 if(pen != series->pen()){
218 item->setLinePen(series->pen());
208 item->setLinePen(series->pen());
219 }else{
209 }else{
220 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
210 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
221 pen.setWidthF(series->pen().widthF());
211 pen.setWidthF(series->pen().widthF());
222 item->setLinePen(series->pen());
212 item->setLinePen(series->pen());
223 }
213 }
224
214
225 // QColor color = m_seriesColors.at(index % m_seriesColors.size());
215 // QColor color = m_seriesColors.at(index % m_seriesColors.size());
226 // TODO: define alpha in the theme? or in the series?
216 // TODO: define alpha in the theme? or in the series?
227 //color.setAlpha(120);
217 //color.setAlpha(120);
228
218
229 // QBrush brush(color, Qt::SolidPattern);
219 // QBrush brush(color, Qt::SolidPattern);
230 // presenter->m_markerBrush = brush;
220 // presenter->m_markerBrush = brush;
231
221
232 // QPen pen(brush, 3);
222 // QPen pen(brush, 3);
233 // pen.setColor(color);
223 // pen.setColor(color);
234 // presenter->m_markerPen = pen;
224 // presenter->m_markerPen = pen;
235 }
225 }
236
226
227 void ChartTheme::decorate(QChartAxis* axis, AxisItem* item)
228 {
229 Q_ASSERT(axis);
230 Q_ASSERT(item);
231
232 if (axis->isAxisVisible()) {
233 axis->setLabelsBrush(m_axisLabelBrush);
234 axis->setLabelsPen(m_axisLabelPen);
235 // TODO: check the axis type (x or y) should define whether to show the shades or not
236 if (m_backgroundShades == BackgroundShadesBoth
237 || m_backgroundShades == BackgroundShadesVertical /*&& x axis ?*/
238 || m_backgroundShades == BackgroundShadesHorizontal /* && y axis*/) {
239 axis->setShadesPen(m_backgroundShadesPen);
240 axis->setShadesBrush(m_backgroundShadesBrush);
241 } else {
242 // The shades not supposed to be shown for this axis, clear possible brush and pen
243 axis->setShadesPen(Qt::NoPen);
244 axis->setShadesBrush(Qt::NoBrush);
245 }
246 axis->setAxisPen(m_axisLinePen);
247 axis->setGridLinePen(m_gridLinePen);
248 axis->setLabelsFont(m_masterFont);
249 }
250 }
251
237 void ChartTheme::generateSeriesGradients()
252 void ChartTheme::generateSeriesGradients()
238 {
253 {
239 // Generate gradients in HSV color space
254 // Generate gradients in HSV color space
240 foreach (QColor color, m_seriesColors) {
255 foreach (QColor color, m_seriesColors) {
241 QLinearGradient g;
256 QLinearGradient g;
242 qreal h = color.hsvHueF();
257 qreal h = color.hsvHueF();
243 qreal s = color.hsvSaturationF();
258 qreal s = color.hsvSaturationF();
244
259
245 // TODO: tune the algorithm to give nice results with most base colors defined in
260 // TODO: tune the algorithm to give nice results with most base colors defined in
246 // most themes. The rest of the gradients we can define manually in theme specific
261 // most themes. The rest of the gradients we can define manually in theme specific
247 // implementation.
262 // implementation.
248 QColor start = color;
263 QColor start = color;
249 start.setHsvF(h, 0.05, 0.95);
264 start.setHsvF(h, 0.05, 0.95);
250 g.setColorAt(0.0, start);
265 g.setColorAt(0.0, start);
251
266
252 g.setColorAt(0.5, color);
267 g.setColorAt(0.5, color);
253
268
254 QColor end = color;
269 QColor end = color;
255 end.setHsvF(h, s, 0.25);
270 end.setHsvF(h, s, 0.25);
256 g.setColorAt(1.0, end);
271 g.setColorAt(1.0, end);
257
272
258 m_seriesGradients << g;
273 m_seriesGradients << g;
259 }
274 }
260 }
275 }
261
276
262
277
263 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
278 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
264 {
279 {
265 Q_ASSERT(pos >=0.0 && pos <= 1.0);
280 Q_ASSERT(pos >=0.0 && pos <= 1.0);
266 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
281 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
267 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
282 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
268 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
283 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
269 QColor c;
284 QColor c;
270 c.setRgbF(r, g, b);
285 c.setRgbF(r, g, b);
271 return c;
286 return c;
272 }
287 }
273
288
274 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
289 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
275 {
290 {
276 Q_ASSERT(pos >=0 && pos <= 1.0);
291 Q_ASSERT(pos >=0 && pos <= 1.0);
277
292
278 // another possibility:
293 // another possibility:
279 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
294 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
280
295
281 QGradientStops stops = gradient.stops();
296 QGradientStops stops = gradient.stops();
282 int count = stops.count();
297 int count = stops.count();
283
298
284 // find previous stop relative to position
299 // find previous stop relative to position
285 QGradientStop prev = stops.first();
300 QGradientStop prev = stops.first();
286 for (int i=0; i<count; i++) {
301 for (int i=0; i<count; i++) {
287 QGradientStop stop = stops.at(i);
302 QGradientStop stop = stops.at(i);
288 if (pos > stop.first)
303 if (pos > stop.first)
289 prev = stop;
304 prev = stop;
290
305
291 // given position is actually a stop position?
306 // given position is actually a stop position?
292 if (pos == stop.first) {
307 if (pos == stop.first) {
293 //qDebug() << "stop color" << pos;
308 //qDebug() << "stop color" << pos;
294 return stop.second;
309 return stop.second;
295 }
310 }
296 }
311 }
297
312
298 // find next stop relative to position
313 // find next stop relative to position
299 QGradientStop next = stops.last();
314 QGradientStop next = stops.last();
300 for (int i=count-1; i>=0; i--) {
315 for (int i=count-1; i>=0; i--) {
301 QGradientStop stop = stops.at(i);
316 QGradientStop stop = stops.at(i);
302 if (pos < stop.first)
317 if (pos < stop.first)
303 next = stop;
318 next = stop;
304 }
319 }
305
320
306 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
321 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
307
322
308 qreal range = next.first - prev.first;
323 qreal range = next.first - prev.first;
309 qreal posDelta = pos - prev.first;
324 qreal posDelta = pos - prev.first;
310 qreal relativePos = posDelta / range;
325 qreal relativePos = posDelta / range;
311
326
312 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
327 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
313
328
314 return colorAt(prev.second, next.second, relativePos);
329 return colorAt(prev.second, next.second, relativePos);
315 }
330 }
316
331
317 QTCOMMERCIALCHART_END_NAMESPACE
332 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,72 +1,81
1 #ifndef CHARTTHEME_H
1 #ifndef CHARTTHEME_H
2 #define CHARTTHEME_H
2 #define CHARTTHEME_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchart.h"
5 #include "qchart.h"
6 #include <QColor>
6 #include <QColor>
7 #include <QGradientStops>
7 #include <QGradientStops>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class ChartItem;
11 class ChartItem;
12 class QSeries;
12 class QSeries;
13 class LineChartItem;
13 class LineChartItem;
14 class QLineSeries;
14 class QLineSeries;
15 class BarPresenter;
15 class BarPresenter;
16 class QBarSeries;
16 class QBarSeries;
17 class StackedBarPresenter;
17 class StackedBarPresenter;
18 class QStackedBarSeries;
18 class QStackedBarSeries;
19 class QPercentBarSeries;
19 class QPercentBarSeries;
20 class PercentBarPresenter;
20 class PercentBarPresenter;
21 class QScatterSeries;
21 class QScatterSeries;
22 class ScatterChartItem;
22 class ScatterChartItem;
23 class PiePresenter;
23 class PiePresenter;
24 class QPieSeries;
24 class QPieSeries;
25 class SplineChartItem;
25 class SplineChartItem;
26 class QSplineSeries;
26 class QSplineSeries;
27 class AreaChartItem;
27 class AreaChartItem;
28 class QAreaSeries;
28 class QAreaSeries;
29
29
30 class ChartTheme
30 class ChartTheme
31 {
31 {
32 public:
33 enum BackgroundShadesMode {
34 BackgroundShadesNone = 0,
35 BackgroundShadesVertical,
36 BackgroundShadesHorizontal,
37 BackgroundShadesBoth
38 };
39
32 protected:
40 protected:
33 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
34 public:
42 public:
35 static ChartTheme* createTheme(QChart::ChartTheme theme);
43 static ChartTheme* createTheme(QChart::ChartTheme theme);
36 QChart::ChartTheme id() const {return m_id;}
44 QChart::ChartTheme id() const {return m_id;}
37 void decorate(QChart* chart);
45 void decorate(QChart* chart);
38 void decorate(QLegend* legend);
46 void decorate(QLegend* legend);
39 //void decorate(ChartItem* item, QSeries* series,int index);
47 //void decorate(ChartItem* item, QSeries* series,int index);
40 void decorate(BarPresenter* item, QBarSeries* series, int index);
48 void decorate(BarPresenter* item, QBarSeries* series, int index);
41 void decorate(StackedBarPresenter* item, QStackedBarSeries* series, int index);
49 void decorate(StackedBarPresenter* item, QStackedBarSeries* series, int index);
42 void decorate(PercentBarPresenter* item, QPercentBarSeries* series, int index);
50 void decorate(PercentBarPresenter* item, QPercentBarSeries* series, int index);
43 void decorate(LineChartItem* item, QLineSeries* series, int index);
51 void decorate(LineChartItem* item, QLineSeries* series, int index);
44 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
52 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
45 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
53 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
46 void decorate(PiePresenter* item, QPieSeries* series, int index);
54 void decorate(PiePresenter* item, QPieSeries* series, int index);
47 void decorate(QChartAxis* axis,AxisItem* item);
48 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
55 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
56 void decorate(QChartAxis* axis, AxisItem* item);
49
57
50 public: // utils
58 public: // utils
51 void generateSeriesGradients();
59 void generateSeriesGradients();
52 static QColor colorAt(const QColor &start, const QColor &end, qreal pos);
60 static QColor colorAt(const QColor &start, const QColor &end, qreal pos);
53 static QColor colorAt(const QGradient &gradient, qreal pos);
61 static QColor colorAt(const QGradient &gradient, qreal pos);
54
62
55 protected:
63 protected:
56 QChart::ChartTheme m_id;
64 QChart::ChartTheme m_id;
57 QList<QColor> m_seriesColors;
65 QList<QColor> m_seriesColors;
58 QList<QGradient> m_seriesGradients;
66 QList<QGradient> m_seriesGradients;
59 QLinearGradient m_backgroundGradient;
67 QLinearGradient m_backgroundGradient;
60
68
61 // TODO: Add something like the following to themes:
69 QFont m_masterFont;
62 // QPen axisLinePen;
70 QPen m_axisLinePen;
63 // QPen backgroundHorizontalGridPen;
71 QBrush m_axisLabelBrush;
64 // QPen backgroundVerticalGridPen;
72 QPen m_axisLabelPen;
65 // // FillAll, FillEverySecondRow, FillEverySecondColumn, FillEverySecondRowAndColumn, FillNone
73 QPen m_backgroundShadesPen;
66 // int backgroundType;
74 QBrush m_backgroundShadesBrush;
67 // QFont masterFont;
75 BackgroundShadesMode m_backgroundShades;
76 QPen m_gridLinePen;
68 };
77 };
69
78
70 QTCOMMERCIALCHART_END_NAMESPACE
79 QTCOMMERCIALCHART_END_NAMESPACE
71
80
72 #endif // CHARTTHEME_H
81 #endif // CHARTTHEME_H
@@ -1,96 +1,154
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #ifdef Q_OS_WIN
2 #ifdef Q_OS_WIN
3 #include <windows.h>
3 #include <windows.h>
4 #include <stdio.h>
4 #include <stdio.h>
5 #endif
5 #endif
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class ChartThemeDefault: public ChartTheme
9 class ChartThemeDefault: public ChartTheme
10 {
10 {
11 public:
11 public:
12 ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault)
12 ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault)
13 {
13 {
14 #ifdef Q_OS_WIN
14 #ifdef Q_OS_WIN
15 // First series base color from COLOR_WINDOWFRAME
15 // TODO: use theme specific window frame color as a series base color (it would give more
16 DWORD colorWindowFrame;
16 // variation to the base colors in addition to the blue and black used now)
17 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
17 // TODO: COLOR_WINDOWTEXT for text color?
18 m_seriesColors.append(QColor(GetRValue(colorWindowFrame), GetGValue(colorWindowFrame),GetBValue(colorWindowFrame)));
18 // TODO: COLOR_INFOTEXT for tooltip text color?
19 // TODO: COLOR_INFOBK for tooltip background color?
19
20
20 // Second series base color from COLOR_HIGHLIGHT
21 // First series base color from COLOR_HIGHLIGHT
21 DWORD colorHighlight;
22 DWORD colorHighlight;
22 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
23 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
23 m_seriesColors.append(QColor(GetRValue(colorHighlight), GetGValue(colorHighlight),GetBValue(colorHighlight)));
24 m_seriesColors.append(QColor(GetRValue(colorHighlight),
25 GetGValue(colorHighlight),
26 GetBValue(colorHighlight)));
27
28 // Second series base color from COLOR_WINDOWFRAME
29 DWORD colorWindowFrame;
30 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
31 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
32 GetGValue(colorWindowFrame),
33 GetBValue(colorWindowFrame)));
24
34
25 // Thirs series base color from the middle of the COLOR_ACTIVECAPTION /
35 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
26 // COLOR_GRADIENTACTIVECAPTION gradient
36 // COLOR_GRADIENTACTIVECAPTION gradient
27 DWORD colorGradientActiveCaptionLeft;
37 DWORD colorGradientActiveCaptionLeft;
28 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
29 DWORD colorGradientActiveCaptionRight;
39 DWORD colorGradientActiveCaptionRight;
30 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
40 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
31 QLinearGradient g;
41 QLinearGradient g;
32 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
42 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
33 GetGValue(colorGradientActiveCaptionLeft),
43 GetGValue(colorGradientActiveCaptionLeft),
34 GetBValue(colorGradientActiveCaptionLeft));
44 GetBValue(colorGradientActiveCaptionLeft));
35 g.setColorAt(0.0, start);
45 g.setColorAt(0.0, start);
36 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
46 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
37 GetGValue(colorGradientActiveCaptionRight),
47 GetGValue(colorGradientActiveCaptionRight),
38 GetBValue(colorGradientActiveCaptionRight));
48 GetBValue(colorGradientActiveCaptionRight));
39 g.setColorAt(1.0, end);
49 g.setColorAt(1.0, end);
40 m_seriesColors.append(colorAt(g, 0.5));
50 m_seriesColors.append(colorAt(g, 0.5));
41
51
42 // Generate gradients from the base colors
52 // Generate gradients from the base colors
43 generateSeriesGradients();
53 generateSeriesGradients();
44
54
45 // Background fill color from COLOR_WINDOW
55 // Background fill color from COLOR_WINDOW
46 QLinearGradient backgroundGradient;
56 QLinearGradient backgroundGradient;
47 DWORD colorWindow;
57 DWORD colorWindow;
48 colorWindow = GetSysColor(COLOR_WINDOW);
58 colorWindow = GetSysColor(COLOR_WINDOW);
49 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
59 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
50 GetGValue(colorWindow),
60 GetGValue(colorWindow),
51 GetBValue(colorWindow)));
61 GetBValue(colorWindow)));
52 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
53 GetGValue(colorWindow),
63 GetGValue(colorWindow),
54 GetBValue(colorWindow)));
64 GetBValue(colorWindow)));
65 // Axes and other
66 m_masterFont = QFont();
67 m_masterFont.setPointSizeF(10.0);
68 m_axisLinePen = QPen(Qt::black);
69 m_axisLinePen.setWidth(2);
70 m_axisLabelBrush = QBrush(Qt::black);
71 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
72 m_backgroundShadesPen = Qt::NoPen;
73 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
74 m_backgroundShades = BackgroundShadesVertical;
55
75
56 // TODO: COLOR_WINDOWTEXT for text color?
57 // TODO: COLOR_INFOTEXT for tooltip text color?
58 // TODO: COLOR_INFOBK for tooltip background color?
59 #elif defined(Q_OS_LINUX)
76 #elif defined(Q_OS_LINUX)
60 // TODO: replace this dummy theme with linux specific theme
77 // TODO: replace this dummy theme with linux specific theme
61 m_seriesColors << QRgb(0xff707070);
78 m_seriesColors << QRgb(0x60a6e6);
62 m_seriesColors << QRgb(0xffA0A0A0);
79 m_seriesColors << QRgb(0x92ca66);
80 m_seriesColors << QRgb(0xeba85f);
81 m_seriesColors << QRgb(0xfc5751);
63 generateSeriesGradients();
82 generateSeriesGradients();
64
83
65 QLinearGradient backgroundGradient;
84 QLinearGradient backgroundGradient;
66 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
85 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
67 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
86 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
68 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
87 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
69 m_backgroundGradient = backgroundGradient;
88 m_backgroundGradient = backgroundGradient;
70 #elif Q_OS_MAC
89
90 // Axes and other
91 m_masterFont = QFont();
92 m_masterFont.setPointSizeF(10.0);
93 m_axisLinePen = QPen(Qt::black);
94 m_axisLinePen.setWidth(2);
95 m_axisLabelBrush = QBrush(Qt::black);
96 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
97 m_backgroundShadesPen = Qt::NoPen;
98 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
99 m_backgroundShades = BackgroundShadesVertical;
100
101 #elif defined(Q_OS_MAC)
71 // TODO: replace this dummy theme with OSX specific theme
102 // TODO: replace this dummy theme with OSX specific theme
72 m_seriesColors << QRgb(0xff707070);
103 m_seriesColors << QRgb(0x60a6e6);
73 m_seriesColors << QRgb(0xffA0A0A0);
104 m_seriesColors << QRgb(0x92ca66);
105 m_seriesColors << QRgb(0xeba85f);
106 m_seriesColors << QRgb(0xfc5751);
74 generateSeriesGradients();
107 generateSeriesGradients();
75
108
76 QLinearGradient backgroundGradient;
109 QLinearGradient backgroundGradient;
77 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
110 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
78 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
111 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
79 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
112 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
80 m_backgroundGradient = backgroundGradient;
113 m_backgroundGradient = backgroundGradient;
114
115 // Axes and other
116 m_masterFont = QFont();
117 m_masterFont.setPointSizeF(10.0);
118 m_axisLinePen = QPen(Qt::black);
119 m_axisLinePen.setWidth(2);
120 m_axisLabelBrush = QBrush(Qt::black);
121 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
122 m_backgroundShadesPen = Qt::NoPen;
123 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
124 m_backgroundShades = BackgroundShadesVertical;
125
81 #else
126 #else
82 // TODO: replace this dummy theme with generic (not OS specific) theme
127 // TODO: replace this dummy theme with generic (not OS specific) theme
83 m_seriesColors << QRgb(0xff707070);
128 m_seriesColors << QRgb(0x60a6e6);
84 m_seriesColors << QRgb(0xffA0A0A0);
129 m_seriesColors << QRgb(0x92ca66);
130 m_seriesColors << QRgb(0xeba85f);
131 m_seriesColors << QRgb(0xfc5751);
85 generateSeriesGradients();
132 generateSeriesGradients();
86
133
87 QLinearGradient backgroundGradient;
134 QLinearGradient backgroundGradient;
88 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
135 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
89 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
136 backgroundGradient.setColorAt(1.0, QRgb(0xafafaf));
90 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
137 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
91 m_backgroundGradient = backgroundGradient;
138 m_backgroundGradient = backgroundGradient;
139
140 // Axes and other
141 m_masterFont = QFont();
142 m_masterFont.setPointSizeF(10.0);
143 m_axisLinePen = QPen(Qt::black);
144 m_axisLinePen.setWidth(2);
145 m_axisLabelBrush = QBrush(Qt::black);
146 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
147 m_backgroundShadesPen = Qt::NoPen;
148 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
149 m_backgroundShades = BackgroundShadesVertical;
92 #endif
150 #endif
93 }
151 }
94 };
152 };
95
153
96 QTCOMMERCIALCHART_END_NAMESPACE
154 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,25 +1,36
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeGrayscale: public ChartTheme
5 class ChartThemeGrayscale: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
9 {
9 {
10 m_seriesColors << QRgb(0xff869299);
10 // Series colors
11 m_seriesColors << QRgb(0xffa5bdcc);
11 m_seriesColors << QRgb(0x869299);
12 m_seriesColors << QRgb(0xffe8fffc);
12 m_seriesColors << QRgb(0xa5bdcc);
13 m_seriesColors << QRgb(0xffccc2c2);
13 m_seriesColors << QRgb(0xe8fffc);
14
14 m_seriesColors << QRgb(0xccc2c2);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
19 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
19 backgroundGradient.setColorAt(1.0, QRgb(0xffe0e3e5));
20 backgroundGradient.setColorAt(1.0, QRgb(0xe0e3e5));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
25 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,25 +1,36
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeIcy: public ChartTheme
5 class ChartThemeIcy: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
9 {
9 {
10 m_seriesColors << QRgb(0xff0d2673);
10 // Series
11 m_seriesColors << QRgb(0xff2685bf);
11 m_seriesColors << QRgb(0x0d2673);
12 m_seriesColors << QRgb(0xff3dadd9);
12 m_seriesColors << QRgb(0x2685bf);
13 m_seriesColors << QRgb(0xff62c3d9);
13 m_seriesColors << QRgb(0x3dadd9);
14
14 m_seriesColors << QRgb(0x62c3d9);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffebebeb));
19 backgroundGradient.setColorAt(0.0, QRgb(0xebebeb));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfff8f9fb));
20 backgroundGradient.setColorAt(1.0, QRgb(0xf8f9fb));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
25 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,25 +1,36
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeScientific: public ChartTheme
5 class ChartThemeScientific: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
9 {
9 {
10 m_seriesColors << QRgb(0xFFFFAD00);
10 // Series
11 m_seriesColors << QRgb(0xFF596A75);
11 m_seriesColors << QRgb(0xFFAD00);
12 m_seriesColors << QRgb(0xFF202020);
12 m_seriesColors << QRgb(0x596A75);
13 m_seriesColors << QRgb(0xFF474747);
13 m_seriesColors << QRgb(0x202020);
14
14 m_seriesColors << QRgb(0x474747);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xfffffefc));
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffefc));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfffffefc));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfffefc));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
25 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,26 +1,37
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeVanilla: public ChartTheme
5 class ChartThemeVanilla: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
9 {
9 {
10 m_seriesColors << QRgb(0xffd9c574);
10 // Series
11 m_seriesColors << QRgb(0xffd6a896);
11 m_seriesColors << QRgb(0xd9c574);
12 m_seriesColors << QRgb(0xffa0a071);
12 m_seriesColors << QRgb(0xd6a896);
13 m_seriesColors << QRgb(0xffd2d234);
13 m_seriesColors << QRgb(0xa0a071);
14 m_seriesColors << QRgb(0xff88723a);
14 m_seriesColors << QRgb(0xd2d234);
15
15 m_seriesColors << QRgb(0x88723a);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffbf9f1));
20 backgroundGradient.setColorAt(0.0, QRgb(0xfbf9f1));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfff5f0dc));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf5f0dc));
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 m_backgroundGradient = backgroundGradient;
23 m_backgroundGradient = backgroundGradient;
24
25 // Axes and other
26 m_masterFont = QFont();
27 m_axisLinePen = QPen(QRgb(0x0f0f0f));
28 m_axisLinePen.setWidth(2);
29 m_axisLabelBrush = QBrush(QRgb(0xa0a071));
30 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
31 m_backgroundShadesPen = Qt::NoPen;
32 m_gridLinePen = QPen(QRgb(0x0f0f0f));
33 m_gridLinePen.setWidth(2);
23 }
34 }
24 };
35 };
25
36
26 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now