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