##// END OF EJS Templates
Defined point sizes for fonts
Tero Ahola -
r717:a566cfd317a8
parent child
Show More
@@ -1,379 +1,380
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartview.h"
3 #include "qchartview.h"
4 #include "qlegend.h"
4 #include "qlegend.h"
5 #include "qchartaxis.h"
5 #include "qchartaxis.h"
6 #include <QTime>
6 #include <QTime>
7
7
8 //series
8 //series
9 #include "qbarset.h"
9 #include "qbarset.h"
10 #include "qbarseries.h"
10 #include "qbarseries.h"
11 #include "qstackedbarseries.h"
11 #include "qstackedbarseries.h"
12 #include "qpercentbarseries.h"
12 #include "qpercentbarseries.h"
13 #include "qlineseries.h"
13 #include "qlineseries.h"
14 #include "qareaseries.h"
14 #include "qareaseries.h"
15 #include "qscatterseries.h"
15 #include "qscatterseries.h"
16 #include "qpieseries.h"
16 #include "qpieseries.h"
17 #include "qpieslice.h"
17 #include "qpieslice.h"
18 #include "qsplineseries.h"
18 #include "qsplineseries.h"
19
19
20 //items
20 //items
21 #include "axisitem_p.h"
21 #include "axisitem_p.h"
22 #include "barchartitem_p.h"
22 #include "barchartitem_p.h"
23 #include "stackedbarchartitem_p.h"
23 #include "stackedbarchartitem_p.h"
24 #include "percentbarchartitem_p.h"
24 #include "percentbarchartitem_p.h"
25 #include "linechartitem_p.h"
25 #include "linechartitem_p.h"
26 #include "areachartitem_p.h"
26 #include "areachartitem_p.h"
27 #include "scatterchartitem_p.h"
27 #include "scatterchartitem_p.h"
28 #include "piechartitem_p.h"
28 #include "piechartitem_p.h"
29 #include "splinechartitem_p.h"
29 #include "splinechartitem_p.h"
30
30
31 //themes
31 //themes
32 #include "chartthemedefault_p.h"
32 #include "chartthemedefault_p.h"
33 #include "chartthemelight_p.h"
33 #include "chartthemelight_p.h"
34 #include "chartthemebluecerulean_p.h"
34 #include "chartthemebluecerulean_p.h"
35 #include "chartthemedark_p.h"
35 #include "chartthemedark_p.h"
36 #include "chartthemebrownsand_p.h"
36 #include "chartthemebrownsand_p.h"
37 #include "chartthemebluencs_p.h"
37 #include "chartthemebluencs_p.h"
38 #include "chartthemeicy_p.h"
38 #include "chartthemeicy_p.h"
39 #include "chartthemescientific_p.h"
39 #include "chartthemescientific_p.h"
40
40
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
42
43 ChartTheme::ChartTheme(QChart::ChartTheme id) :
43 ChartTheme::ChartTheme(QChart::ChartTheme id) :
44 m_masterFont(QFont()),
44 m_masterFont(QFont("arial", 12)),
45 m_labelFont(QFont("arial", 10)),
45 m_titleBrush(QColor(QRgb(0x000000))),
46 m_titleBrush(QColor(QRgb(0x000000))),
46 m_axisLinePen(QPen(QRgb(0x000000))),
47 m_axisLinePen(QPen(QRgb(0x000000))),
47 m_axisLabelBrush(QColor(QRgb(0x000000))),
48 m_axisLabelBrush(QColor(QRgb(0x000000))),
48 m_backgroundShadesPen(Qt::NoPen),
49 m_backgroundShadesPen(Qt::NoPen),
49 m_backgroundShadesBrush(Qt::NoBrush),
50 m_backgroundShadesBrush(Qt::NoBrush),
50 m_backgroundShades(BackgroundShadesNone),
51 m_backgroundShades(BackgroundShadesNone),
51 m_gridLinePen(QPen(QRgb(0x000000)))
52 m_gridLinePen(QPen(QRgb(0x000000)))
52 {
53 {
53 m_id = id;
54 m_id = id;
54 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
55 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
55 }
56 }
56
57
57
58
58 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
59 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
59 {
60 {
60 switch(theme) {
61 switch(theme) {
61 case QChart::ChartThemeLight:
62 case QChart::ChartThemeLight:
62 return new ChartThemeLight();
63 return new ChartThemeLight();
63 case QChart::ChartThemeBlueCerulean:
64 case QChart::ChartThemeBlueCerulean:
64 return new ChartThemeBlueCerulean();
65 return new ChartThemeBlueCerulean();
65 case QChart::ChartThemeDark:
66 case QChart::ChartThemeDark:
66 return new ChartThemeDark();
67 return new ChartThemeDark();
67 case QChart::ChartThemeBrownSand:
68 case QChart::ChartThemeBrownSand:
68 return new ChartThemeBrownSand();
69 return new ChartThemeBrownSand();
69 case QChart::ChartThemeBlueNcs:
70 case QChart::ChartThemeBlueNcs:
70 return new ChartThemeBlueNcs();
71 return new ChartThemeBlueNcs();
71 case QChart::ChartThemeIcy:
72 case QChart::ChartThemeIcy:
72 return new ChartThemeIcy();
73 return new ChartThemeIcy();
73 case QChart::ChartThemeScientific:
74 case QChart::ChartThemeScientific:
74 return new ChartThemeScientific();
75 return new ChartThemeScientific();
75 default:
76 default:
76 return new ChartThemeDefault();
77 return new ChartThemeDefault();
77 }
78 }
78 }
79 }
79
80
80 void ChartTheme::decorate(QChart* chart,bool force)
81 void ChartTheme::decorate(QChart* chart,bool force)
81 {
82 {
82 QPen pen;
83 QPen pen;
83 QBrush brush;
84 QBrush brush;
84
85
85 if(brush == chart->backgroundBrush() || force)
86 if(brush == chart->backgroundBrush() || force)
86 {
87 {
87 if (m_backgroundShades == BackgroundShadesNone) {
88 if (m_backgroundShades == BackgroundShadesNone) {
88 chart->setBackgroundBrush(m_chartBackgroundGradient);
89 chart->setBackgroundBrush(m_chartBackgroundGradient);
89 }
90 }
90 else {
91 else {
91 chart->setBackgroundBrush(Qt::NoBrush);
92 chart->setBackgroundBrush(Qt::NoBrush);
92 }
93 }
93 }
94 }
94 chart->setTitleFont(m_masterFont);
95 chart->setTitleFont(m_masterFont);
95 chart->setTitleBrush(m_titleBrush);
96 chart->setTitleBrush(m_titleBrush);
96 }
97 }
97
98
98 void ChartTheme::decorate(QLegend* legend,bool force)
99 void ChartTheme::decorate(QLegend* legend,bool force)
99 {
100 {
100 QPen pen;
101 QPen pen;
101 QBrush brush;
102 QBrush brush;
102
103
103 if (pen == legend->pen() || force){
104 if (pen == legend->pen() || force){
104 //TODO:: legend->setPen();
105 //TODO:: legend->setPen();
105 }
106 }
106
107
107
108
108 if (brush == legend->brush() || force) {
109 if (brush == legend->brush() || force) {
109 legend->setBrush(m_chartBackgroundGradient);
110 legend->setBrush(m_chartBackgroundGradient);
110 }
111 }
111 }
112 }
112
113
113 void ChartTheme::decorate(QAreaSeries* series, int index,bool force)
114 void ChartTheme::decorate(QAreaSeries* series, int index,bool force)
114 {
115 {
115 QPen pen;
116 QPen pen;
116 QBrush brush;
117 QBrush brush;
117
118
118 if (pen == series->pen() || force){
119 if (pen == series->pen() || force){
119 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
120 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
120 pen.setWidthF(2);
121 pen.setWidthF(2);
121 series->setPen(pen);
122 series->setPen(pen);
122 }
123 }
123
124
124 if (brush == series->brush() || force) {
125 if (brush == series->brush() || force) {
125 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
126 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
126 series->setBrush(brush);
127 series->setBrush(brush);
127 }
128 }
128 }
129 }
129
130
130
131
131 void ChartTheme::decorate(QLineSeries* series,int index,bool force)
132 void ChartTheme::decorate(QLineSeries* series,int index,bool force)
132 {
133 {
133 QPen pen;
134 QPen pen;
134 if(pen == series->pen() || force ){
135 if(pen == series->pen() || force ){
135 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
136 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
136 pen.setWidthF(2);
137 pen.setWidthF(2);
137 series->setPen(pen);
138 series->setPen(pen);
138 }
139 }
139 }
140 }
140
141
141 void ChartTheme::decorate(QBarSeries* series, int index, bool force)
142 void ChartTheme::decorate(QBarSeries* series, int index, bool force)
142 {
143 {
143 QBrush brush;
144 QBrush brush;
144 QPen pen;
145 QPen pen;
145 QList<QBarSet*> sets = series->barSets();
146 QList<QBarSet*> sets = series->barSets();
146
147
147 qreal takeAtPos = 0.5;
148 qreal takeAtPos = 0.5;
148 qreal step = 0.2;
149 qreal step = 0.2;
149 if (sets.count() > 1 ) {
150 if (sets.count() > 1 ) {
150 step = 1.0 / (qreal) sets.count();
151 step = 1.0 / (qreal) sets.count();
151 if (sets.count() % m_seriesGradients.count())
152 if (sets.count() % m_seriesGradients.count())
152 step *= m_seriesGradients.count();
153 step *= m_seriesGradients.count();
153 else
154 else
154 step *= (m_seriesGradients.count() - 1);
155 step *= (m_seriesGradients.count() - 1);
155 }
156 }
156
157
157 for (int i(0); i < sets.count(); i++) {
158 for (int i(0); i < sets.count(); i++) {
158 int colorIndex = (index + i) % m_seriesGradients.count();
159 int colorIndex = (index + i) % m_seriesGradients.count();
159 if (i > 0 && i % m_seriesGradients.count() == 0) {
160 if (i > 0 && i % m_seriesGradients.count() == 0) {
160 // There is no dedicated base color for each sets, generate more colors
161 // There is no dedicated base color for each sets, generate more colors
161 takeAtPos += step;
162 takeAtPos += step;
162 if (takeAtPos == 1.0)
163 if (takeAtPos == 1.0)
163 takeAtPos += step;
164 takeAtPos += step;
164 takeAtPos -= (int) takeAtPos;
165 takeAtPos -= (int) takeAtPos;
165 }
166 }
166 qDebug() << "pos:" << takeAtPos;
167 qDebug() << "pos:" << takeAtPos;
167 if (brush == sets.at(i)->brush() || force )
168 if (brush == sets.at(i)->brush() || force )
168 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
169 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
169
170
170 // Pick label color from the opposite end of the gradient.
171 // Pick label color from the opposite end of the gradient.
171 // 0.3 as a boundary seems to work well.
172 // 0.3 as a boundary seems to work well.
172 if (takeAtPos < 0.3)
173 if (takeAtPos < 0.3)
173 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
174 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
174 else
175 else
175 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
176 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
176
177
177 if (pen == sets.at(i)->pen() || force) {
178 if (pen == sets.at(i)->pen() || force) {
178 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
179 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
179 sets.at(i)->setPen(c);
180 sets.at(i)->setPen(c);
180 }
181 }
181 }
182 }
182 }
183 }
183
184
184 void ChartTheme::decorate(QScatterSeries* series, int index,bool force)
185 void ChartTheme::decorate(QScatterSeries* series, int index,bool force)
185 {
186 {
186 QPen pen;
187 QPen pen;
187 QBrush brush;
188 QBrush brush;
188
189
189 if (pen == series->pen() || force) {
190 if (pen == series->pen() || force) {
190 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
191 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
191 pen.setWidthF(2);
192 pen.setWidthF(2);
192 series->setPen(pen);
193 series->setPen(pen);
193 }
194 }
194
195
195 if (brush == series->brush() || force) {
196 if (brush == series->brush() || force) {
196 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
197 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
197 series->setBrush(brush);
198 series->setBrush(brush);
198 }
199 }
199 }
200 }
200
201
201 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
202 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
202 {
203 {
203 for (int i(0); i < series->slices().count(); i++) {
204 for (int i(0); i < series->slices().count(); i++) {
204
205
205 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
206 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
206
207
207 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
208 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
208 qreal pos = (qreal) (i + 1) / (qreal) series->count();
209 qreal pos = (qreal) (i + 1) / (qreal) series->count();
209 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
210 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
210
211
211 QPieSlice::DataPtr s = series->slices().at(i)->data_ptr();
212 QPieSlice::DataPtr s = series->slices().at(i)->data_ptr();
212 PieSliceData data = s->m_data;
213 PieSliceData data = s->m_data;
213
214
214 if (data.m_slicePen.isThemed() || force) {
215 if (data.m_slicePen.isThemed() || force) {
215 data.m_slicePen = penColor;
216 data.m_slicePen = penColor;
216 data.m_slicePen.setThemed(true);
217 data.m_slicePen.setThemed(true);
217 }
218 }
218
219
219 if (data.m_sliceBrush.isThemed() || force) {
220 if (data.m_sliceBrush.isThemed() || force) {
220 data.m_sliceBrush = brushColor;
221 data.m_sliceBrush = brushColor;
221 data.m_sliceBrush.setThemed(true);
222 data.m_sliceBrush.setThemed(true);
222 }
223 }
223
224
224 if (data.m_labelPen.isThemed() || force) {
225 if (data.m_labelPen.isThemed() || force) {
225 data.m_labelPen = QPen(m_titleBrush.color());
226 data.m_labelPen = QPen(m_titleBrush.color());
226 data.m_labelPen.setThemed(true);
227 data.m_labelPen.setThemed(true);
227 }
228 }
228
229
229 if (data.m_labelFont.isThemed() || force) {
230 if (data.m_labelFont.isThemed() || force) {
230 data.m_labelFont = m_masterFont;
231 data.m_labelFont = m_labelFont;
231 data.m_labelFont.setThemed(true);
232 data.m_labelFont.setThemed(true);
232 }
233 }
233
234
234 if (s->m_data != data) {
235 if (s->m_data != data) {
235 s->m_data = data;
236 s->m_data = data;
236 emit s->changed();
237 emit s->changed();
237 }
238 }
238 }
239 }
239 }
240 }
240
241
241 void ChartTheme::decorate(QSplineSeries* series, int index, bool force)
242 void ChartTheme::decorate(QSplineSeries* series, int index, bool force)
242 {
243 {
243 QPen pen;
244 QPen pen;
244 if(pen == series->pen() || force){
245 if(pen == series->pen() || force){
245 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
246 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
246 pen.setWidthF(2);
247 pen.setWidthF(2);
247 series->setPen(pen);
248 series->setPen(pen);
248 }
249 }
249 }
250 }
250
251
251 void ChartTheme::decorate(QChartAxis* axis,bool axisX, bool force)
252 void ChartTheme::decorate(QChartAxis* axis,bool axisX, bool force)
252 {
253 {
253 QPen pen;
254 QPen pen;
254 QBrush brush;
255 QBrush brush;
255 QFont font;
256 QFont font;
256
257
257 if (axis->isAxisVisible()) {
258 if (axis->isAxisVisible()) {
258
259
259 if(brush == axis->labelsBrush() || force){
260 if(brush == axis->labelsBrush() || force){
260 axis->setLabelsBrush(m_axisLabelBrush);
261 axis->setLabelsBrush(m_axisLabelBrush);
261 }
262 }
262 if(pen == axis->labelsPen() || force){
263 if(pen == axis->labelsPen() || force){
263 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
264 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
264 }
265 }
265
266
266
267
267 if (axis->shadesVisible() || force) {
268 if (axis->shadesVisible() || force) {
268
269
269 if(brush == axis->shadesBrush() || force){
270 if(brush == axis->shadesBrush() || force){
270 axis->setShadesBrush(m_backgroundShadesBrush);
271 axis->setShadesBrush(m_backgroundShadesBrush);
271 }
272 }
272
273
273 if(pen == axis->shadesPen() || force){
274 if(pen == axis->shadesPen() || force){
274 axis->setShadesPen(m_backgroundShadesPen);
275 axis->setShadesPen(m_backgroundShadesPen);
275 }
276 }
276
277
277 if(force && (m_backgroundShades == BackgroundShadesBoth
278 if(force && (m_backgroundShades == BackgroundShadesBoth
278 || (m_backgroundShades == BackgroundShadesVertical && axisX)
279 || (m_backgroundShades == BackgroundShadesVertical && axisX)
279 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
280 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
280 axis->setShadesVisible(true);
281 axis->setShadesVisible(true);
281
282
282 }
283 }
283 }
284 }
284
285
285 if(pen == axis->axisPen() || force){
286 if(pen == axis->axisPen() || force){
286 axis->setAxisPen(m_axisLinePen);
287 axis->setAxisPen(m_axisLinePen);
287 }
288 }
288
289
289 if(pen == axis->gridLinePen() || force){
290 if(pen == axis->gridLinePen() || force){
290 axis->setGridLinePen(m_gridLinePen);
291 axis->setGridLinePen(m_gridLinePen);
291 }
292 }
292
293
293 if(font == axis->labelsFont() || force){
294 if(font == axis->labelsFont() || force){
294 axis->setLabelsFont(m_masterFont);
295 axis->setLabelsFont(m_labelFont);
295 }
296 }
296 }
297 }
297 }
298 }
298
299
299 void ChartTheme::generateSeriesGradients()
300 void ChartTheme::generateSeriesGradients()
300 {
301 {
301 // Generate gradients in HSV color space
302 // Generate gradients in HSV color space
302 foreach (QColor color, m_seriesColors) {
303 foreach (QColor color, m_seriesColors) {
303 QLinearGradient g;
304 QLinearGradient g;
304 qreal h = color.hsvHueF();
305 qreal h = color.hsvHueF();
305 qreal s = color.hsvSaturationF();
306 qreal s = color.hsvSaturationF();
306
307
307 // TODO: tune the algorithm to give nice results with most base colors defined in
308 // TODO: tune the algorithm to give nice results with most base colors defined in
308 // most themes. The rest of the gradients we can define manually in theme specific
309 // most themes. The rest of the gradients we can define manually in theme specific
309 // implementation.
310 // implementation.
310 QColor start = color;
311 QColor start = color;
311 start.setHsvF(h, 0.0, 1.0);
312 start.setHsvF(h, 0.0, 1.0);
312 g.setColorAt(0.0, start);
313 g.setColorAt(0.0, start);
313
314
314 g.setColorAt(0.5, color);
315 g.setColorAt(0.5, color);
315
316
316 QColor end = color;
317 QColor end = color;
317 end.setHsvF(h, s, 0.25);
318 end.setHsvF(h, s, 0.25);
318 g.setColorAt(1.0, end);
319 g.setColorAt(1.0, end);
319
320
320 m_seriesGradients << g;
321 m_seriesGradients << g;
321 }
322 }
322 }
323 }
323
324
324
325
325 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
326 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
326 {
327 {
327 Q_ASSERT(pos >=0.0 && pos <= 1.0);
328 Q_ASSERT(pos >=0.0 && pos <= 1.0);
328 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
329 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
329 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
330 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
330 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
331 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
331 QColor c;
332 QColor c;
332 c.setRgbF(r, g, b);
333 c.setRgbF(r, g, b);
333 return c;
334 return c;
334 }
335 }
335
336
336 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
337 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
337 {
338 {
338 Q_ASSERT(pos >=0 && pos <= 1.0);
339 Q_ASSERT(pos >=0 && pos <= 1.0);
339
340
340 // another possibility:
341 // another possibility:
341 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
342 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
342
343
343 QGradientStops stops = gradient.stops();
344 QGradientStops stops = gradient.stops();
344 int count = stops.count();
345 int count = stops.count();
345
346
346 // find previous stop relative to position
347 // find previous stop relative to position
347 QGradientStop prev = stops.first();
348 QGradientStop prev = stops.first();
348 for (int i=0; i<count; i++) {
349 for (int i=0; i<count; i++) {
349 QGradientStop stop = stops.at(i);
350 QGradientStop stop = stops.at(i);
350 if (pos > stop.first)
351 if (pos > stop.first)
351 prev = stop;
352 prev = stop;
352
353
353 // given position is actually a stop position?
354 // given position is actually a stop position?
354 if (pos == stop.first) {
355 if (pos == stop.first) {
355 //qDebug() << "stop color" << pos;
356 //qDebug() << "stop color" << pos;
356 return stop.second;
357 return stop.second;
357 }
358 }
358 }
359 }
359
360
360 // find next stop relative to position
361 // find next stop relative to position
361 QGradientStop next = stops.last();
362 QGradientStop next = stops.last();
362 for (int i=count-1; i>=0; i--) {
363 for (int i=count-1; i>=0; i--) {
363 QGradientStop stop = stops.at(i);
364 QGradientStop stop = stops.at(i);
364 if (pos < stop.first)
365 if (pos < stop.first)
365 next = stop;
366 next = stop;
366 }
367 }
367
368
368 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
369 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
369
370
370 qreal range = next.first - prev.first;
371 qreal range = next.first - prev.first;
371 qreal posDelta = pos - prev.first;
372 qreal posDelta = pos - prev.first;
372 qreal relativePos = posDelta / range;
373 qreal relativePos = posDelta / range;
373
374
374 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
375 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
375
376
376 return colorAt(prev.second, next.second, relativePos);
377 return colorAt(prev.second, next.second, relativePos);
377 }
378 }
378
379
379 QTCOMMERCIALCHART_END_NAMESPACE
380 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,78 +1,79
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 BarChartItem;
15 class BarChartItem;
16 class QBarSeries;
16 class QBarSeries;
17 class StackedBarChartItem;
17 class StackedBarChartItem;
18 class QStackedBarSeries;
18 class QStackedBarSeries;
19 class QPercentBarSeries;
19 class QPercentBarSeries;
20 class PercentBarChartItem;
20 class PercentBarChartItem;
21 class QScatterSeries;
21 class QScatterSeries;
22 class ScatterChartItem;
22 class ScatterChartItem;
23 class PieChartItem;
23 class PieChartItem;
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:
32 public:
33 enum BackgroundShadesMode {
33 enum BackgroundShadesMode {
34 BackgroundShadesNone = 0,
34 BackgroundShadesNone = 0,
35 BackgroundShadesVertical,
35 BackgroundShadesVertical,
36 BackgroundShadesHorizontal,
36 BackgroundShadesHorizontal,
37 BackgroundShadesBoth
37 BackgroundShadesBoth
38 };
38 };
39
39
40 protected:
40 protected:
41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
42 public:
42 public:
43 static ChartTheme* createTheme(QChart::ChartTheme theme);
43 static ChartTheme* createTheme(QChart::ChartTheme theme);
44 QChart::ChartTheme id() const {return m_id;}
44 QChart::ChartTheme id() const {return m_id;}
45 void decorate(QChart* chart,bool force = true);
45 void decorate(QChart* chart,bool force = true);
46 void decorate(QLegend* legend,bool force = true);
46 void decorate(QLegend* legend,bool force = true);
47 void decorate(QBarSeries* series, int index,bool force = true);
47 void decorate(QBarSeries* series, int index,bool force = true);
48 void decorate(QLineSeries* series, int index,bool force = true);
48 void decorate(QLineSeries* series, int index,bool force = true);
49 void decorate(QAreaSeries* series, int index,bool force = true);
49 void decorate(QAreaSeries* series, int index,bool force = true);
50 void decorate(QScatterSeries* series, int index,bool force = true);
50 void decorate(QScatterSeries* series, int index,bool force = true);
51 void decorate(QPieSeries* series, int index,bool force = true);
51 void decorate(QPieSeries* series, int index,bool force = true);
52 void decorate(QSplineSeries* series, int index,bool force = true);
52 void decorate(QSplineSeries* series, int index,bool force = true);
53 void decorate(QChartAxis* axis, bool axisX,bool force = true);
53 void decorate(QChartAxis* axis, bool axisX,bool force = true);
54
54
55 public: // utils
55 public: // utils
56 void generateSeriesGradients();
56 void generateSeriesGradients();
57 static QColor colorAt(const QColor &start, const QColor &end, qreal pos);
57 static QColor colorAt(const QColor &start, const QColor &end, qreal pos);
58 static QColor colorAt(const QGradient &gradient, qreal pos);
58 static QColor colorAt(const QGradient &gradient, qreal pos);
59
59
60 protected:
60 protected:
61 QChart::ChartTheme m_id;
61 QChart::ChartTheme m_id;
62 QList<QColor> m_seriesColors;
62 QList<QColor> m_seriesColors;
63 QList<QGradient> m_seriesGradients;
63 QList<QGradient> m_seriesGradients;
64 QLinearGradient m_chartBackgroundGradient;
64 QLinearGradient m_chartBackgroundGradient;
65
65
66 QFont m_masterFont;
66 QFont m_masterFont;
67 QFont m_labelFont;
67 QBrush m_titleBrush;
68 QBrush m_titleBrush;
68 QPen m_axisLinePen;
69 QPen m_axisLinePen;
69 QBrush m_axisLabelBrush;
70 QBrush m_axisLabelBrush;
70 QPen m_backgroundShadesPen;
71 QPen m_backgroundShadesPen;
71 QBrush m_backgroundShadesBrush;
72 QBrush m_backgroundShadesBrush;
72 BackgroundShadesMode m_backgroundShades;
73 BackgroundShadesMode m_backgroundShades;
73 QPen m_gridLinePen;
74 QPen m_gridLinePen;
74 };
75 };
75
76
76 QTCOMMERCIALCHART_END_NAMESPACE
77 QTCOMMERCIALCHART_END_NAMESPACE
77
78
78 #endif // CHARTTHEME_H
79 #endif // CHARTTHEME_H
@@ -1,37 +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 ChartThemeBlueCerulean: public ChartTheme
5 class ChartThemeBlueCerulean: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean)
8 ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean)
9 {
9 {
10 // Series colors
10 // Series colors
11 m_seriesColors << QRgb(0xc7e85b);
11 m_seriesColors << QRgb(0xc7e85b);
12 m_seriesColors << QRgb(0x1cb54f);
12 m_seriesColors << QRgb(0x1cb54f);
13 m_seriesColors << QRgb(0x5cbf9b);
13 m_seriesColors << QRgb(0x5cbf9b);
14 m_seriesColors << QRgb(0x009fbf);
14 m_seriesColors << QRgb(0x009fbf);
15 m_seriesColors << QRgb(0xee7392);
15 m_seriesColors << QRgb(0xee7392);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
20 backgroundGradient.setColorAt(0.0, QRgb(0x056189));
20 backgroundGradient.setColorAt(0.0, QRgb(0x056189));
21 backgroundGradient.setColorAt(1.0, QRgb(0x101a31));
21 backgroundGradient.setColorAt(1.0, QRgb(0x101a31));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
23 m_chartBackgroundGradient = backgroundGradient;
24
24
25 // Axes and other
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0xffffff));
26 m_titleBrush = QBrush(QRgb(0xffffff));
28 m_axisLinePen = QPen(QRgb(0xd6d6d6));
27 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 m_axisLinePen.setWidth(2);
28 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0xffffff));
29 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 m_gridLinePen = QPen(QRgb(0x84a2b0));
30 m_gridLinePen = QPen(QRgb(0x84a2b0));
32 m_gridLinePen.setWidth(1);
31 m_gridLinePen.setWidth(1);
33 m_backgroundShades = BackgroundShadesNone;
32 m_backgroundShades = BackgroundShadesNone;
34 }
33 }
35 };
34 };
36
35
37 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +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 ChartThemeBlueNcs: public ChartTheme
5 class ChartThemeBlueNcs: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeBlueNcs() : ChartTheme(QChart::ChartThemeBlueNcs)
8 ChartThemeBlueNcs() : ChartTheme(QChart::ChartThemeBlueNcs)
9 {
9 {
10 // Series colors
10 // Series colors
11 m_seriesColors << QRgb(0x1db0da);
11 m_seriesColors << QRgb(0x1db0da);
12 m_seriesColors << QRgb(0x1341a6);
12 m_seriesColors << QRgb(0x1341a6);
13 m_seriesColors << QRgb(0x88d41e);
13 m_seriesColors << QRgb(0x88d41e);
14 m_seriesColors << QRgb(0xff8e1a);
14 m_seriesColors << QRgb(0xff8e1a);
15 m_seriesColors << QRgb(0x398ca3);
15 m_seriesColors << QRgb(0x398ca3);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
23 m_chartBackgroundGradient = backgroundGradient;
24
24
25 // Axes and other
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0x404044));
26 m_titleBrush = QBrush(QRgb(0x404044));
28 m_axisLinePen = QPen(QRgb(0xd6d6d6));
27 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 m_axisLinePen.setWidth(2);
28 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0x404044));
29 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 m_gridLinePen = QPen(QRgb(0xe2e2e2));
30 m_gridLinePen = QPen(QRgb(0xe2e2e2));
32 m_gridLinePen.setWidth(1);
31 m_gridLinePen.setWidth(1);
33 m_backgroundShades = BackgroundShadesNone;
32 m_backgroundShades = BackgroundShadesNone;
34 }
33 }
35 };
34 };
36
35
37 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +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 ChartThemeBrownSand: public ChartTheme
5 class ChartThemeBrownSand: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeBrownSand() : ChartTheme(QChart::ChartThemeBrownSand)
8 ChartThemeBrownSand() : ChartTheme(QChart::ChartThemeBrownSand)
9 {
9 {
10 // Series colors
10 // Series colors
11 m_seriesColors << QRgb(0xb39b72);
11 m_seriesColors << QRgb(0xb39b72);
12 m_seriesColors << QRgb(0xb3b376);
12 m_seriesColors << QRgb(0xb3b376);
13 m_seriesColors << QRgb(0xc35660);
13 m_seriesColors << QRgb(0xc35660);
14 m_seriesColors << QRgb(0x536780);
14 m_seriesColors << QRgb(0x536780);
15 m_seriesColors << QRgb(0x494345);
15 m_seriesColors << QRgb(0x494345);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0xf3ece0));
20 backgroundGradient.setColorAt(0.0, QRgb(0xf3ece0));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf3ece0));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf3ece0));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
23 m_chartBackgroundGradient = backgroundGradient;
24
24
25 // Axes and other
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0x404044));
26 m_titleBrush = QBrush(QRgb(0x404044));
28 m_axisLinePen = QPen(QRgb(0xb5b0a7));
27 m_axisLinePen = QPen(QRgb(0xb5b0a7));
29 m_axisLinePen.setWidth(2);
28 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0x404044));
29 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 m_gridLinePen = QPen(QRgb(0xd4cec3));
30 m_gridLinePen = QPen(QRgb(0xd4cec3));
32 m_gridLinePen.setWidth(1);
31 m_gridLinePen.setWidth(1);
33 m_backgroundShades = BackgroundShadesNone;
32 m_backgroundShades = BackgroundShadesNone;
34 }
33 }
35 };
34 };
36
35
37 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +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 ChartThemeDark : public ChartTheme
5 class ChartThemeDark : public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeDark() : ChartTheme(QChart::ChartThemeDark)
8 ChartThemeDark() : ChartTheme(QChart::ChartThemeDark)
9 {
9 {
10 // Series colors
10 // Series colors
11 m_seriesColors << QRgb(0x38ad6b);
11 m_seriesColors << QRgb(0x38ad6b);
12 m_seriesColors << QRgb(0x3c84a7);
12 m_seriesColors << QRgb(0x3c84a7);
13 m_seriesColors << QRgb(0xeb8817);
13 m_seriesColors << QRgb(0xeb8817);
14 m_seriesColors << QRgb(0x7b7f8c);
14 m_seriesColors << QRgb(0x7b7f8c);
15 m_seriesColors << QRgb(0xbf593e);
15 m_seriesColors << QRgb(0xbf593e);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
20 backgroundGradient.setColorAt(0.0, QRgb(0x2e303a));
20 backgroundGradient.setColorAt(0.0, QRgb(0x2e303a));
21 backgroundGradient.setColorAt(1.0, QRgb(0x121218));
21 backgroundGradient.setColorAt(1.0, QRgb(0x121218));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
23 m_chartBackgroundGradient = backgroundGradient;
24
24
25 // Axes and other
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0xffffff));
26 m_titleBrush = QBrush(QRgb(0xffffff));
28 m_axisLinePen = QPen(QRgb(0x86878c));
27 m_axisLinePen = QPen(QRgb(0x86878c));
29 m_axisLinePen.setWidth(2);
28 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0xffffff));
29 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 m_gridLinePen = QPen(QRgb(0x86878c));
30 m_gridLinePen = QPen(QRgb(0x86878c));
32 m_gridLinePen.setWidth(1);
31 m_gridLinePen.setWidth(1);
33 m_backgroundShades = BackgroundShadesNone;
32 m_backgroundShades = BackgroundShadesNone;
34 }
33 }
35 };
34 };
36
35
37 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,149 +1,145
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 // TODO: use theme specific window frame color as a series base color (it would give more
15 // TODO: use theme specific window frame color as a series base color (it would give more
16 // variation to the base colors in addition to the blue and black used now)
16 // variation to the base colors in addition to the blue and black used now)
17 // TODO: COLOR_WINDOWTEXT for text color?
17 // TODO: COLOR_WINDOWTEXT for text color?
18 // TODO: COLOR_INFOTEXT for tooltip text color?
18 // TODO: COLOR_INFOTEXT for tooltip text color?
19 // TODO: COLOR_INFOBK for tooltip background color?
19 // TODO: COLOR_INFOBK for tooltip background color?
20
20
21 // First series base color from COLOR_HIGHLIGHT
21 // First series base color from COLOR_HIGHLIGHT
22 DWORD colorHighlight;
22 DWORD colorHighlight;
23 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
23 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
24 m_seriesColors.append(QColor(GetRValue(colorHighlight),
24 m_seriesColors.append(QColor(GetRValue(colorHighlight),
25 GetGValue(colorHighlight),
25 GetGValue(colorHighlight),
26 GetBValue(colorHighlight)));
26 GetBValue(colorHighlight)));
27
27
28 // Second series base color from COLOR_WINDOWFRAME
28 // Second series base color from COLOR_WINDOWFRAME
29 DWORD colorWindowFrame;
29 DWORD colorWindowFrame;
30 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
30 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
31 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
31 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
32 GetGValue(colorWindowFrame),
32 GetGValue(colorWindowFrame),
33 GetBValue(colorWindowFrame)));
33 GetBValue(colorWindowFrame)));
34
34
35 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
35 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
36 // COLOR_GRADIENTACTIVECAPTION gradient
36 // COLOR_GRADIENTACTIVECAPTION gradient
37 DWORD colorGradientActiveCaptionLeft;
37 DWORD colorGradientActiveCaptionLeft;
38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
39 DWORD colorGradientActiveCaptionRight;
39 DWORD colorGradientActiveCaptionRight;
40 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
40 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
41 QLinearGradient g;
41 QLinearGradient g;
42 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
42 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
43 GetGValue(colorGradientActiveCaptionLeft),
43 GetGValue(colorGradientActiveCaptionLeft),
44 GetBValue(colorGradientActiveCaptionLeft));
44 GetBValue(colorGradientActiveCaptionLeft));
45 g.setColorAt(0.0, start);
45 g.setColorAt(0.0, start);
46 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
46 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
47 GetGValue(colorGradientActiveCaptionRight),
47 GetGValue(colorGradientActiveCaptionRight),
48 GetBValue(colorGradientActiveCaptionRight));
48 GetBValue(colorGradientActiveCaptionRight));
49 g.setColorAt(1.0, end);
49 g.setColorAt(1.0, end);
50 m_seriesColors.append(colorAt(g, 0.5));
50 m_seriesColors.append(colorAt(g, 0.5));
51
51
52 // Generate gradients from the base colors
52 // Generate gradients from the base colors
53 generateSeriesGradients();
53 generateSeriesGradients();
54
54
55 // Background fill color from COLOR_WINDOW
55 // Background fill color from COLOR_WINDOW
56 QLinearGradient backgroundGradient;
56 QLinearGradient backgroundGradient;
57 DWORD colorWindow;
57 DWORD colorWindow;
58 colorWindow = GetSysColor(COLOR_WINDOW);
58 colorWindow = GetSysColor(COLOR_WINDOW);
59 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
59 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
60 GetGValue(colorWindow),
60 GetGValue(colorWindow),
61 GetBValue(colorWindow)));
61 GetBValue(colorWindow)));
62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
63 GetGValue(colorWindow),
63 GetGValue(colorWindow),
64 GetBValue(colorWindow)));
64 GetBValue(colorWindow)));
65 // Axes and other
65 // Axes and other
66 m_masterFont = QFont("arial");
67 m_axisLinePen = QPen(0xd6d6d6);
66 m_axisLinePen = QPen(0xd6d6d6);
68 m_axisLinePen.setWidth(1);
67 m_axisLinePen.setWidth(1);
69 m_axisLabelBrush = QBrush(QRgb(0x404044));
68 m_axisLabelBrush = QBrush(QRgb(0x404044));
70 m_gridLinePen = QPen(QRgb(0xe2e2e2));
69 m_gridLinePen = QPen(QRgb(0xe2e2e2));
71 m_gridLinePen.setWidth(1);
70 m_gridLinePen.setWidth(1);
72 m_backgroundShades = BackgroundShadesNone;
71 m_backgroundShades = BackgroundShadesNone;
73
72
74 #elif defined(Q_OS_LINUX)
73 #elif defined(Q_OS_LINUX)
75 // TODO: replace this dummy theme with linux specific theme
74 // TODO: replace this dummy theme with linux specific theme
76 m_seriesColors << QRgb(0x60a6e6);
75 m_seriesColors << QRgb(0x60a6e6);
77 m_seriesColors << QRgb(0x92ca66);
76 m_seriesColors << QRgb(0x92ca66);
78 m_seriesColors << QRgb(0xeba85f);
77 m_seriesColors << QRgb(0xeba85f);
79 m_seriesColors << QRgb(0xfc5751);
78 m_seriesColors << QRgb(0xfc5751);
80 generateSeriesGradients();
79 generateSeriesGradients();
81
80
82 // Background
81 // Background
83 QLinearGradient backgroundGradient;
82 QLinearGradient backgroundGradient;
84 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
83 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
85 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
84 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
86 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
85 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
87 m_chartBackgroundGradient = backgroundGradient;
86 m_chartBackgroundGradient = backgroundGradient;
88
87
89 // Axes and other
88 // Axes and other
90 m_masterFont = QFont("arial");
91 m_axisLinePen = QPen(0xd6d6d6);
89 m_axisLinePen = QPen(0xd6d6d6);
92 m_axisLinePen.setWidth(1);
90 m_axisLinePen.setWidth(1);
93 m_axisLabelBrush = QBrush(QRgb(0x404044));
91 m_axisLabelBrush = QBrush(QRgb(0x404044));
94 m_gridLinePen = QPen(QRgb(0xe2e2e2));
92 m_gridLinePen = QPen(QRgb(0xe2e2e2));
95 m_gridLinePen.setWidth(1);
93 m_gridLinePen.setWidth(1);
96 m_backgroundShades = BackgroundShadesNone;
94 m_backgroundShades = BackgroundShadesNone;
97
95
98 #elif defined(Q_OS_MAC)
96 #elif defined(Q_OS_MAC)
99 // TODO: replace this dummy theme with OSX specific theme
97 // TODO: replace this dummy theme with OSX specific theme
100 m_seriesColors << QRgb(0x60a6e6);
98 m_seriesColors << QRgb(0x60a6e6);
101 m_seriesColors << QRgb(0x92ca66);
99 m_seriesColors << QRgb(0x92ca66);
102 m_seriesColors << QRgb(0xeba85f);
100 m_seriesColors << QRgb(0xeba85f);
103 m_seriesColors << QRgb(0xfc5751);
101 m_seriesColors << QRgb(0xfc5751);
104 generateSeriesGradients();
102 generateSeriesGradients();
105
103
106 // Background
104 // Background
107 QLinearGradient backgroundGradient;
105 QLinearGradient backgroundGradient;
108 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
106 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
109 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
107 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
110 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
108 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
111 m_chartBackgroundGradient = backgroundGradient;
109 m_chartBackgroundGradient = backgroundGradient;
112
110
113 // Axes and other
111 // Axes and other
114 m_masterFont = QFont("arial");
115 m_axisLinePen = QPen(0xd6d6d6);
112 m_axisLinePen = QPen(0xd6d6d6);
116 m_axisLinePen.setWidth(1);
113 m_axisLinePen.setWidth(1);
117 m_axisLabelBrush = QBrush(QRgb(0x404044));
114 m_axisLabelBrush = QBrush(QRgb(0x404044));
118 m_gridLinePen = QPen(QRgb(0xe2e2e2));
115 m_gridLinePen = QPen(QRgb(0xe2e2e2));
119 m_gridLinePen.setWidth(1);
116 m_gridLinePen.setWidth(1);
120 m_backgroundShades = BackgroundShadesNone;
117 m_backgroundShades = BackgroundShadesNone;
121
118
122 #else
119 #else
123 // TODO: replace this dummy theme with generic (not OS specific) theme
120 // TODO: replace this dummy theme with generic (not OS specific) theme
124 m_seriesColors << QRgb(0x60a6e6);
121 m_seriesColors << QRgb(0x60a6e6);
125 m_seriesColors << QRgb(0x92ca66);
122 m_seriesColors << QRgb(0x92ca66);
126 m_seriesColors << QRgb(0xeba85f);
123 m_seriesColors << QRgb(0xeba85f);
127 m_seriesColors << QRgb(0xfc5751);
124 m_seriesColors << QRgb(0xfc5751);
128 generateSeriesGradients();
125 generateSeriesGradients();
129
126
130 // Background
127 // Background
131 QLinearGradient backgroundGradient;
128 QLinearGradient backgroundGradient;
132 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
129 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
133 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
130 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
134 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
131 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
135 m_chartBackgroundGradient = backgroundGradient;
132 m_chartBackgroundGradient = backgroundGradient;
136
133
137 // Axes and other
134 // Axes and other
138 m_masterFont = QFont("arial");
139 m_axisLinePen = QPen(0xd6d6d6);
135 m_axisLinePen = QPen(0xd6d6d6);
140 m_axisLinePen.setWidth(1);
136 m_axisLinePen.setWidth(1);
141 m_axisLabelBrush = QBrush(QRgb(0x404044));
137 m_axisLabelBrush = QBrush(QRgb(0x404044));
142 m_gridLinePen = QPen(QRgb(0xe2e2e2));
138 m_gridLinePen = QPen(QRgb(0xe2e2e2));
143 m_gridLinePen.setWidth(1);
139 m_gridLinePen.setWidth(1);
144 m_backgroundShades = BackgroundShadesNone;
140 m_backgroundShades = BackgroundShadesNone;
145 #endif
141 #endif
146 }
142 }
147 };
143 };
148
144
149 QTCOMMERCIALCHART_END_NAMESPACE
145 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,36 +1,35
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeLight: public ChartTheme
5 class ChartThemeLight: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeLight() : ChartTheme(QChart::ChartThemeLight)
8 ChartThemeLight() : ChartTheme(QChart::ChartThemeLight)
9 {
9 {
10 // Series colors
10 // Series colors
11 m_seriesColors << QRgb(0x209fdf);
11 m_seriesColors << QRgb(0x209fdf);
12 m_seriesColors << QRgb(0x99ca53);
12 m_seriesColors << QRgb(0x99ca53);
13 m_seriesColors << QRgb(0xf6a625);
13 m_seriesColors << QRgb(0xf6a625);
14 m_seriesColors << QRgb(0x6d5fd5);
14 m_seriesColors << QRgb(0x6d5fd5);
15 m_seriesColors << QRgb(0xbf593e);
15 m_seriesColors << QRgb(0xbf593e);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
23 m_chartBackgroundGradient = backgroundGradient;
24
24
25 // Axes and other
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_axisLinePen = QPen(0xd6d6d6);
26 m_axisLinePen = QPen(0xd6d6d6);
28 m_axisLinePen.setWidth(1);
27 m_axisLinePen.setWidth(1);
29 m_axisLabelBrush = QBrush(QRgb(0x404044));
28 m_axisLabelBrush = QBrush(QRgb(0x404044));
30 m_gridLinePen = QPen(QRgb(0xe2e2e2));
29 m_gridLinePen = QPen(QRgb(0xe2e2e2));
31 m_gridLinePen.setWidth(1);
30 m_gridLinePen.setWidth(1);
32 m_backgroundShades = BackgroundShadesNone;
31 m_backgroundShades = BackgroundShadesNone;
33 }
32 }
34 };
33 };
35
34
36 QTCOMMERCIALCHART_END_NAMESPACE
35 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now