@@ -0,0 +1,36 | |||
|
1 | #include "charttheme_p.h" | |
|
2 | ||
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
4 | ||
|
5 | class ChartThemeLight: public ChartTheme | |
|
6 | { | |
|
7 | public: | |
|
8 | ChartThemeLight() : ChartTheme(QChart::ChartThemeLight) | |
|
9 | { | |
|
10 | // Series colors | |
|
11 | m_seriesColors << QRgb(0x1c9dde); | |
|
12 | m_seriesColors << QRgb(0xf7a015); | |
|
13 | m_seriesColors << QRgb(0x8dc444); | |
|
14 | generateSeriesGradients(); | |
|
15 | ||
|
16 | // Background | |
|
17 | QLinearGradient backgroundGradient; | |
|
18 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); | |
|
19 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); | |
|
20 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
|
21 | m_chartBackgroundGradient = backgroundGradient; | |
|
22 | ||
|
23 | // Axes and other | |
|
24 | m_masterFont = QFont(); | |
|
25 | m_axisLinePen = QPen(QRgb(0x424242)); | |
|
26 | m_axisLinePen.setWidth(1); | |
|
27 | m_axisLabelBrush = QBrush(QRgb(0x424242)); | |
|
28 | m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons | |
|
29 | m_backgroundShadesPen = Qt::NoPen; | |
|
30 | m_backgroundShades = BackgroundShadesNone; | |
|
31 | m_gridLinePen = QPen(QRgb(0x424242)); | |
|
32 | m_gridLinePen.setWidth(1); | |
|
33 | } | |
|
34 | }; | |
|
35 | ||
|
36 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,5 +1,6 | |||
|
1 | 1 | #include "charttheme_p.h" |
|
2 | 2 | #include "qchart.h" |
|
3 | #include "qchartview.h" | |
|
3 | 4 | #include "qlegend.h" |
|
4 | 5 | #include "qchartaxis.h" |
|
5 | 6 | #include <QTime> |
@@ -34,6 +35,7 | |||
|
34 | 35 | #include "chartthemegrayscale_p.h" |
|
35 | 36 | #include "chartthemescientific_p.h" |
|
36 | 37 | #include "chartthemebluecerulean_p.h" |
|
38 | #include "chartthemelight_p.h" | |
|
37 | 39 | |
|
38 | 40 | |
|
39 | 41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -58,6 +60,8 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) | |||
|
58 | 60 | return new ChartThemeScientific(); |
|
59 | 61 | case QChart::ChartThemeBlueCerulean: |
|
60 | 62 | return new ChartThemeBlueCerulean(); |
|
63 | case QChart::ChartThemeLight: | |
|
64 | return new ChartThemeLight(); | |
|
61 | 65 | default: |
|
62 | 66 | return new ChartThemeDefault(); |
|
63 | 67 | } |
@@ -65,16 +69,17 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) | |||
|
65 | 69 | |
|
66 | 70 | void ChartTheme::decorate(QChart* chart) |
|
67 | 71 | { |
|
68 | if (m_backgroundShades == BackgroundShadesNone) | |
|
69 |
chart->setChartBackgroundBrush(m_ |
|
|
70 | else | |
|
72 | if (m_backgroundShades == BackgroundShadesNone) { | |
|
73 | chart->setChartBackgroundBrush(m_chartBackgroundGradient); | |
|
74 | } else { | |
|
71 | 75 | chart->setChartBackgroundBrush(Qt::NoBrush); |
|
76 | } | |
|
72 | 77 | chart->setChartTitleFont(m_masterFont); |
|
73 | 78 | } |
|
74 | 79 | |
|
75 | 80 | void ChartTheme::decorate(QLegend* legend) |
|
76 | 81 | { |
|
77 |
legend->setBackgroundBrush(m_ |
|
|
82 | legend->setBackgroundBrush(m_chartBackgroundGradient); | |
|
78 | 83 | } |
|
79 | 84 | |
|
80 | 85 | void ChartTheme::decorate(QAreaSeries* series, int index) |
@@ -210,7 +215,6 void ChartTheme::decorate(QChartAxis* axis,bool axisX) | |||
|
210 | 215 | if (axis->isAxisVisible()) { |
|
211 | 216 | axis->setLabelsBrush(m_axisLabelBrush); |
|
212 | 217 | axis->setLabelsPen(m_axisLabelPen); |
|
213 | // TODO: check the axis type (x or y) should define whether to show the shades or not | |
|
214 | 218 | if (m_backgroundShades == BackgroundShadesBoth |
|
215 | 219 | || (m_backgroundShades == BackgroundShadesVertical && axisX) |
|
216 | 220 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX)) { |
@@ -64,7 +64,7 protected: | |||
|
64 | 64 | QChart::ChartTheme m_id; |
|
65 | 65 | QList<QColor> m_seriesColors; |
|
66 | 66 | QList<QGradient> m_seriesGradients; |
|
67 |
QLinearGradient m_ |
|
|
67 | QLinearGradient m_chartBackgroundGradient; | |
|
68 | 68 | |
|
69 | 69 | QFont m_masterFont; |
|
70 | 70 | QPen m_axisLinePen; |
@@ -20,6 +20,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
20 | 20 | \value ChartThemeGrayscale |
|
21 | 21 | \value ChartThemeScientific |
|
22 | 22 | \value ChartThemeBlueCerulean |
|
23 | \value ChartThemeLight | |
|
23 | 24 | \value ChartThemeCount Not really a theme; the total count of themes. |
|
24 | 25 | */ |
|
25 | 26 |
@@ -33,6 +33,7 public: | |||
|
33 | 33 | ChartThemeGrayscale, |
|
34 | 34 | ChartThemeScientific, |
|
35 | 35 | ChartThemeBlueCerulean, |
|
36 | ChartThemeLight, | |
|
36 | 37 | ChartThemeCount |
|
37 | 38 | }; |
|
38 | 39 |
@@ -36,12 +36,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
36 | 36 | Constructs a chartView object which is a child of a\a parent. |
|
37 | 37 | */ |
|
38 | 38 | QChartView::QChartView(QWidget *parent) : |
|
39 | QGraphicsView(parent), | |
|
40 | m_scene(new QGraphicsScene(this)), | |
|
41 | m_chart(new QChart()), | |
|
42 | m_rubberBand(0), | |
|
43 | m_verticalRubberBand(false), | |
|
44 | m_horizonalRubberBand(false) | |
|
39 | QGraphicsView(parent), | |
|
40 | m_scene(new QGraphicsScene(this)), | |
|
41 | m_chart(new QChart()), | |
|
42 | m_rubberBand(0), | |
|
43 | m_verticalRubberBand(false), | |
|
44 | m_horizonalRubberBand(false) | |
|
45 | 45 | { |
|
46 | 46 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
47 | 47 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
@@ -328,6 +328,15 void QChartView::keyPressEvent(QKeyEvent *event) | |||
|
328 | 328 | */ |
|
329 | 329 | void QChartView::setChartTheme(QChart::ChartTheme theme) |
|
330 | 330 | { |
|
331 | if (theme == QChart::ChartThemeBlueCerulean) { | |
|
332 | QLinearGradient backgroundGradient; | |
|
333 | backgroundGradient.setColorAt(0.0, QRgb(0x056188)); | |
|
334 | backgroundGradient.setColorAt(1.0, QRgb(0x101a33)); | |
|
335 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
|
336 | setBackgroundBrush(backgroundGradient); | |
|
337 | } else { | |
|
338 | setBackgroundBrush(Qt::NoBrush); | |
|
339 | } | |
|
331 | 340 | m_chart->setChartTheme(theme); |
|
332 | 341 | } |
|
333 | 342 | |
@@ -385,4 +394,6 void QChartView::scroll(int dx,int dy) | |||
|
385 | 394 | m_chart->scroll(dx,dy); |
|
386 | 395 | } |
|
387 | 396 | |
|
397 | #include "moc_qchartview.cpp" | |
|
398 | ||
|
388 | 399 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -16,6 +16,8 class QChart; | |||
|
16 | 16 | |
|
17 | 17 | class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView |
|
18 | 18 | { |
|
19 | Q_OBJECT | |
|
20 | ||
|
19 | 21 | public: |
|
20 | 22 | enum RubberBandPolicy { NoRubberBand, VerticalRubberBand, HorizonalRubberBand, RectangleRubberBand }; |
|
21 | 23 | |
@@ -64,7 +66,6 protected: | |||
|
64 | 66 | void mouseReleaseEvent(QMouseEvent *event); |
|
65 | 67 | void keyPressEvent(QKeyEvent *event); |
|
66 | 68 | |
|
67 | ||
|
68 | 69 | private: |
|
69 | 70 | QGraphicsScene *m_scene; |
|
70 | 71 | QChart* m_chart; |
@@ -73,8 +74,6 private: | |||
|
73 | 74 | bool m_verticalRubberBand; |
|
74 | 75 | bool m_horizonalRubberBand; |
|
75 | 76 | Q_DISABLE_COPY(QChartView) |
|
76 | ||
|
77 | ||
|
78 | 77 | }; |
|
79 | 78 | |
|
80 | 79 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -45,7 +45,9 THEMES += themes/chartthemedefault_p.h \ | |||
|
45 | 45 | themes/chartthemegrayscale_p.h \ |
|
46 | 46 | themes/chartthemescientific_p.h \ |
|
47 | 47 | themes/chartthemevanilla_p.h \ |
|
48 | themes/chartthemebluecerulean_p.h | |
|
48 | themes/chartthemebluecerulean_p.h \ | |
|
49 | themes/chartthemelight_p.h | |
|
50 | ||
|
49 | 51 | HEADERS += $$PUBLIC_HEADERS |
|
50 | 52 | HEADERS += $$PRIVATE_HEADERS |
|
51 | 53 | HEADERS += $$THEMES |
@@ -13,23 +13,19 public: | |||
|
13 | 13 | m_seriesColors << QRgb(0x4fbef3); |
|
14 | 14 | generateSeriesGradients(); |
|
15 | 15 | |
|
16 | // Background | |
|
17 | QLinearGradient backgroundGradient; | |
|
18 | backgroundGradient.setColorAt(0.0, QRgb(0x056188)); | |
|
19 | backgroundGradient.setColorAt(1.0, QRgb(0x101a33)); | |
|
20 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
|
21 | m_backgroundGradient = backgroundGradient; | |
|
16 | // No chart background, chart view specifies a background | |
|
17 | // TODO: what if the chart is drawn on custom graphics scene instead of QChartView? | |
|
22 | 18 | |
|
23 | 19 | // Axes and other |
|
24 | 20 | m_masterFont = QFont(); |
|
25 |
m_axisLinePen = QPen(QRgb(0x |
|
|
21 | m_axisLinePen = QPen(QRgb(0xf7f7ff)); | |
|
26 | 22 | m_axisLinePen.setWidth(2); |
|
27 |
m_axisLabelBrush = QBrush(QRgb(0x |
|
|
23 | m_axisLabelBrush = QBrush(QRgb(0xf7f7ff)); | |
|
28 | 24 | m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons |
|
29 | 25 | m_backgroundShadesPen = Qt::NoPen; |
|
30 | 26 | m_backgroundShades = BackgroundShadesNone; |
|
31 |
m_gridLinePen = QPen(QRgb(0x |
|
|
32 |
m_gridLinePen.setWidth( |
|
|
27 | m_gridLinePen = QPen(QRgb(0xf7f7ff)); | |
|
28 | m_gridLinePen.setWidth(1); | |
|
33 | 29 | } |
|
34 | 30 | }; |
|
35 | 31 |
@@ -110,7 +110,7 public: | |||
|
110 | 110 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); |
|
111 | 111 | backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9)); |
|
112 | 112 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
113 |
m_ |
|
|
113 | m_chartBackgroundGradient = backgroundGradient; | |
|
114 | 114 | |
|
115 | 115 | // Axes and other |
|
116 | 116 | m_masterFont = QFont(); |
@@ -19,7 +19,7 public: | |||
|
19 | 19 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); |
|
20 | 20 | backgroundGradient.setColorAt(1.0, QRgb(0xe0e3e5)); |
|
21 | 21 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
22 |
m_ |
|
|
22 | m_chartBackgroundGradient = backgroundGradient; | |
|
23 | 23 | |
|
24 | 24 | // Axes and other |
|
25 | 25 | m_masterFont = QFont(); |
@@ -28,6 +28,7 public: | |||
|
28 | 28 | m_axisLabelBrush = QBrush(QRgb(0x3f3f3f)); |
|
29 | 29 | m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons |
|
30 | 30 | m_backgroundShadesPen = Qt::NoPen; |
|
31 | m_backgroundShades = BackgroundShadesNone; | |
|
31 | 32 | m_gridLinePen = QPen(QRgb(0x0f0f0f)); |
|
32 | 33 | m_gridLinePen.setWidth(2); |
|
33 | 34 | } |
@@ -19,7 +19,7 public: | |||
|
19 | 19 | backgroundGradient.setColorAt(0.0, QRgb(0xebebeb)); |
|
20 | 20 | backgroundGradient.setColorAt(1.0, QRgb(0xf8f9fb)); |
|
21 | 21 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
22 |
m_ |
|
|
22 | m_chartBackgroundGradient = backgroundGradient; | |
|
23 | 23 | |
|
24 | 24 | // Axes and other |
|
25 | 25 | m_masterFont = QFont(); |
@@ -28,6 +28,7 public: | |||
|
28 | 28 | m_axisLabelBrush = QBrush(QRgb(0x3f3f3f)); |
|
29 | 29 | m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons |
|
30 | 30 | m_backgroundShadesPen = Qt::NoPen; |
|
31 | m_backgroundShades = BackgroundShadesNone; | |
|
31 | 32 | m_gridLinePen = QPen(QRgb(0x0f0f0f)); |
|
32 | 33 | m_gridLinePen.setWidth(2); |
|
33 | 34 | } |
@@ -19,7 +19,7 public: | |||
|
19 | 19 | backgroundGradient.setColorAt(0.0, QRgb(0xfffefc)); |
|
20 | 20 | backgroundGradient.setColorAt(1.0, QRgb(0xfffefc)); |
|
21 | 21 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
22 |
m_ |
|
|
22 | m_chartBackgroundGradient = backgroundGradient; | |
|
23 | 23 | |
|
24 | 24 | // Axes and other |
|
25 | 25 | m_masterFont = QFont(); |
@@ -20,7 +20,7 public: | |||
|
20 | 20 | backgroundGradient.setColorAt(0.0, QRgb(0xfbf9f1)); |
|
21 | 21 | backgroundGradient.setColorAt(1.0, QRgb(0xf5f0dc)); |
|
22 | 22 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
23 |
m_ |
|
|
23 | m_chartBackgroundGradient = backgroundGradient; | |
|
24 | 24 | |
|
25 | 25 | // Axes and other |
|
26 | 26 | m_masterFont = QFont(); |
@@ -29,6 +29,7 public: | |||
|
29 | 29 | m_axisLabelBrush = QBrush(QRgb(0xa0a071)); |
|
30 | 30 | m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons |
|
31 | 31 | m_backgroundShadesPen = Qt::NoPen; |
|
32 | m_backgroundShades = BackgroundShadesNone; | |
|
32 | 33 | m_gridLinePen = QPen(QRgb(0x0f0f0f)); |
|
33 | 34 | m_gridLinePen.setWidth(2); |
|
34 | 35 | } |
General Comments 0
You need to be logged in to leave comments.
Login now