##// END OF EJS Templates
Three more themes
Tero Ahola -
r651:17e2918b5f02
parent child
Show More
@@ -0,0 +1,36
1 #include "charttheme_p.h"
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
5 class ChartThemeBlueNcs: public ChartTheme
6 {
7 public:
8 ChartThemeBlueNcs() : ChartTheme(QChart::ChartThemeBlueNcs)
9 {
10 // Series colors
11 m_seriesColors << QRgb(0x1db0da);
12 m_seriesColors << QRgb(0x1341a6);
13 m_seriesColors << QRgb(0x88d41e);
14 m_seriesColors << QRgb(0xff8e1a);
15 m_seriesColors << QRgb(0x398ca3);
16 generateSeriesGradients();
17
18 // Background
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
24
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0x404044));
28 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 m_gridLinePen = QPen(QRgb(0xe2e2e2));
32 m_gridLinePen.setWidth(1);
33 }
34 };
35
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,36
1 #include "charttheme_p.h"
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
5 class ChartThemeBrownSand: public ChartTheme
6 {
7 public:
8 ChartThemeBrownSand() : ChartTheme(QChart::ChartThemeBrownSand)
9 {
10 // Series colors
11 m_seriesColors << QRgb(0xb39b72);
12 m_seriesColors << QRgb(0xb3b376);
13 m_seriesColors << QRgb(0xc35660);
14 m_seriesColors << QRgb(0x536780);
15 m_seriesColors << QRgb(0x494345);
16 generateSeriesGradients();
17
18 // Background
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0xf3ece0));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf3ece0));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
24
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0x404044));
28 m_axisLinePen = QPen(QRgb(0xb5b0a7));
29 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 m_gridLinePen = QPen(QRgb(0xd4cec3));
32 m_gridLinePen.setWidth(1);
33 }
34 };
35
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,36
1 #include "charttheme_p.h"
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
5 class ChartThemeDark : public ChartTheme
6 {
7 public:
8 ChartThemeDark() : ChartTheme(QChart::ChartThemeDark)
9 {
10 // Series colors
11 m_seriesColors << QRgb(0x38ad6b);
12 m_seriesColors << QRgb(0x3c84a7);
13 m_seriesColors << QRgb(0xeb8817);
14 m_seriesColors << QRgb(0x7b7f8c);
15 m_seriesColors << QRgb(0xbf593e);
16 generateSeriesGradients();
17
18 // Background
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0x2e303a));
21 backgroundGradient.setColorAt(1.0, QRgb(0x121218));
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 m_chartBackgroundGradient = backgroundGradient;
24
25 // Axes and other
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0xffffff));
28 m_axisLinePen = QPen(QRgb(0x86878c));
29 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 m_gridLinePen = QPen(QRgb(0x86878c));
32 m_gridLinePen.setWidth(1);
33 }
34 };
35
36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,228 +1,243
1 #include <QtGui/QApplication>
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qpieseries.h>
5 #include <qpieseries.h>
6 #include <qpieslice.h>
6 #include <qpieslice.h>
7 #include <qpercentbarseries.h>
7 #include <qpercentbarseries.h>
8 #include <qbarset.h>
8 #include <qbarset.h>
9 #include <QGridLayout>
9 #include <QGridLayout>
10 #include <QFormLayout>
10 #include <QFormLayout>
11 #include <QComboBox>
11 #include <QComboBox>
12 #include <QSpinBox>
12 #include <QSpinBox>
13 #include <QCheckBox>
13 #include <QCheckBox>
14 #include <QGroupBox>
14 #include <QGroupBox>
15 #include <QLabel>
15 #include <QLabel>
16 #include <QTime>
16 #include <QTime>
17 #include <qlineseries.h>
17 #include <qlineseries.h>
18 #include <qsplineseries.h>
18 #include <qsplineseries.h>
19 #include <qscatterseries.h>
19 #include <qscatterseries.h>
20 #include <qareaseries.h>
20 #include <qareaseries.h>
21
21
22 QTCOMMERCIALCHART_USE_NAMESPACE
22 QTCOMMERCIALCHART_USE_NAMESPACE
23
23
24 typedef QPair<QPointF, QString> Data;
24 typedef QPair<QPointF, QString> Data;
25 typedef QList<Data> DataList;
25 typedef QList<Data> DataList;
26 typedef QList<DataList> DataTable;
26 typedef QList<DataList> DataTable;
27
27
28
28
29 class MainWidget : public QWidget
29 class MainWidget : public QWidget
30 {
30 {
31 Q_OBJECT
31 Q_OBJECT
32
32
33 public:
33 public:
34 explicit MainWidget(QWidget* parent = 0)
34 explicit MainWidget(QWidget* parent = 0)
35 :QWidget(parent)
35 :QWidget(parent)
36 {
36 {
37 // set seed for random stuff
37 // set seed for random stuff
38 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
38 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
39
39
40 // generate random data
40 // generate random data
41 int listCount = 3;
41 int listCount = 3;
42 int valueMax = 100;
42 int valueMax = 100;
43 int valueCount = 11;
43 int valueCount = 11;
44 for (int i(0); i < listCount; i++) {
44 for (int i(0); i < listCount; i++) {
45 DataList dataList;
45 DataList dataList;
46 for (int j(0); j < valueCount; j++) {
46 for (int j(0); j < valueCount; j++) {
47 QPointF value(j + (qreal) rand() / (qreal) RAND_MAX, qrand() % valueMax);
47 QPointF value(j + (qreal) rand() / (qreal) RAND_MAX, qrand() % valueMax);
48 QString label = QString::number(i) + ":" + QString::number(j);
48 QString label = QString::number(i) + ":" + QString::number(j);
49 dataList << Data(value, label);
49 dataList << Data(value, label);
50 }
50 }
51 m_dataTable << dataList;
51 m_dataTable << dataList;
52 }
52 }
53
53
54 // create layout
54 // create layout
55 QGridLayout* baseLayout = new QGridLayout();
55 QGridLayout* baseLayout = new QGridLayout();
56
56
57 // settings layout
57 // settings layout
58 m_themeComboBox = new QComboBox();
58 m_themeComboBox = new QComboBox();
59 m_themeComboBox->addItem("Default", QChart::ChartThemeDefault);
59 m_themeComboBox->addItem("Default", QChart::ChartThemeDefault);
60 m_themeComboBox->addItem("Light", QChart::ChartThemeLight);
61 m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
62 m_themeComboBox->addItem("Dark", QChart::ChartThemeDark);
63 m_themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
64 m_themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
60 m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla);
65 m_themeComboBox->addItem("Vanilla", QChart::ChartThemeVanilla);
61 m_themeComboBox->addItem("Icy", QChart::ChartThemeIcy);
66 m_themeComboBox->addItem("Icy", QChart::ChartThemeIcy);
62 m_themeComboBox->addItem("Grayscale", QChart::ChartThemeGrayscale);
67 m_themeComboBox->addItem("Grayscale", QChart::ChartThemeGrayscale);
63 m_themeComboBox->addItem("Scientific", QChart::ChartThemeScientific);
68 m_themeComboBox->addItem("Scientific", QChart::ChartThemeScientific);
64 m_themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
65 m_themeComboBox->addItem("Light", QChart::ChartThemeLight);
66 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme()));
69 connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateTheme()));
67 QCheckBox *antialiasCheckBox = new QCheckBox("Anti aliasing");
70 QCheckBox *antialiasCheckBox = new QCheckBox("Anti aliasing");
68 connect(antialiasCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAntialiasing(bool)));
71 connect(antialiasCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAntialiasing(bool)));
69 QCheckBox *animatedCheckBox = new QCheckBox("Animated");
72 QCheckBox *animatedCheckBox = new QCheckBox("Animated");
70 connect(animatedCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAnimations(bool)));
73 connect(animatedCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateAnimations(bool)));
71 QHBoxLayout *settingsLayout = new QHBoxLayout();
74 QHBoxLayout *settingsLayout = new QHBoxLayout();
72 settingsLayout->addWidget(new QLabel("Theme:"));
75 settingsLayout->addWidget(new QLabel("Theme:"));
73 settingsLayout->addWidget(m_themeComboBox);
76 settingsLayout->addWidget(m_themeComboBox);
74 settingsLayout->addWidget(antialiasCheckBox);
77 settingsLayout->addWidget(antialiasCheckBox);
75 settingsLayout->addWidget(animatedCheckBox);
78 settingsLayout->addWidget(animatedCheckBox);
76 settingsLayout->addStretch();
79 settingsLayout->addStretch();
77 baseLayout->addLayout(settingsLayout, 0, 0, 1, 3);
80 baseLayout->addLayout(settingsLayout, 0, 0, 1, 3);
78
81
79 // area chart
82 // area chart
80 QChartView *chart = new QChartView();
83 QChartView *chart = new QChartView();
81 chart->setChartTitle("Area chart");
84 chart->setChartTitle("Area chart");
82 baseLayout->addWidget(chart, 1, 0);
85 baseLayout->addWidget(chart, 1, 0);
83 {
86 {
84 for (int i(0); i < m_dataTable.count(); i++) {
87 for (int i(0); i < m_dataTable.count(); i++) {
85 QLineSeries *series1 = new QLineSeries(chart);
88 QLineSeries *series1 = new QLineSeries(chart);
86 QLineSeries *series2 = new QLineSeries(chart);
89 QLineSeries *series2 = new QLineSeries(chart);
87 foreach (Data data, m_dataTable[i]) {
90 foreach (Data data, m_dataTable[i]) {
88 series1->add(data.first);
91 series1->add(data.first);
89 series2->add(QPointF(data.first.x(), 0.0));
92 series2->add(QPointF(data.first.x(), 0.0));
90 }
93 }
91 QAreaSeries *area = new QAreaSeries(series1, series2);
94 QAreaSeries *area = new QAreaSeries(series1, series2);
92 chart->addSeries(area);
95 chart->addSeries(area);
93 }
96 }
94 }
97 }
95 m_charts << chart;
98 m_charts << chart;
96
99
97 // bar chart
100 // bar chart
98 chart = new QChartView();
101 chart = new QChartView();
99 chart->setChartTitle("bar chart");
102 chart->setChartTitle("bar chart");
100 baseLayout->addWidget(chart, 1, 1);
103 baseLayout->addWidget(chart, 1, 1);
101 {
104 {
102 QStringList categories;
105 QStringList categories;
103 // TODO: categories
106 // TODO: categories
104 for (int i(0); i < valueCount; i++)
107 for (int i(0); i < valueCount; i++)
105 categories << QString::number(i);
108 categories << QString::number(i);
106 QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
109 QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
107 for (int i(0); i < m_dataTable.count(); i++) {
110 for (int i(0); i < m_dataTable.count(); i++) {
108 QBarSet *set = new QBarSet("Set" + QString::number(i));
111 QBarSet *set = new QBarSet("Set" + QString::number(i));
109 foreach (Data data, m_dataTable[i])
112 foreach (Data data, m_dataTable[i])
110 *set << data.first.y();
113 *set << data.first.y();
111 series->addBarSet(set);
114 series->addBarSet(set);
112 }
115 }
113 chart->addSeries(series);
116 chart->addSeries(series);
114 }
117 }
115 m_charts << chart;
118 m_charts << chart;
116
119
117 // line chart
120 // line chart
118 chart = new QChartView();
121 chart = new QChartView();
119 chart->setChartTitle("line chart");
122 chart->setChartTitle("line chart");
120 baseLayout->addWidget(chart, 1, 2);
123 baseLayout->addWidget(chart, 1, 2);
121 foreach (DataList list, m_dataTable) {
124 foreach (DataList list, m_dataTable) {
122 QLineSeries *series = new QLineSeries(chart);
125 QLineSeries *series = new QLineSeries(chart);
123 foreach (Data data, list)
126 foreach (Data data, list)
124 series->add(data.first);
127 series->add(data.first);
125 chart->addSeries(series);
128 chart->addSeries(series);
126 }
129 }
127 m_charts << chart;
130 m_charts << chart;
128
131
129 // pie chart
132 // pie chart
130 chart = new QChartView();
133 chart = new QChartView();
131 chart->setChartTitle("pie chart");
134 chart->setChartTitle("pie chart");
132 baseLayout->addWidget(chart, 2, 0);
135 baseLayout->addWidget(chart, 2, 0);
133 qreal pieSize = 1.0 / m_dataTable.count();
136 qreal pieSize = 1.0 / m_dataTable.count();
134 for (int i=0; i<m_dataTable.count(); i++) {
137 for (int i=0; i<m_dataTable.count(); i++) {
135 QPieSeries *series = new QPieSeries(chart);
138 QPieSeries *series = new QPieSeries(chart);
136 foreach (Data data, m_dataTable[i])
139 foreach (Data data, m_dataTable[i])
137 series->add(data.first.y(), data.second);
140 series->add(data.first.y(), data.second);
138 qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count());
141 qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count());
139 series->setPieSize(pieSize);
142 series->setPieSize(pieSize);
140 series->setPiePosition(hPos, 0.5);
143 series->setPiePosition(hPos, 0.5);
141 chart->addSeries(series);
144 chart->addSeries(series);
142 }
145 }
143 m_charts << chart;
146 m_charts << chart;
144
147
145 // spine chart
148 // spine chart
146 chart = new QChartView();
149 chart = new QChartView();
147 chart->setChartTitle("spline chart");
150 chart->setChartTitle("spline chart");
148 baseLayout->addWidget(chart, 2, 1);
151 baseLayout->addWidget(chart, 2, 1);
149 foreach (DataList list, m_dataTable) {
152 foreach (DataList list, m_dataTable) {
150 QSplineSeries *series = new QSplineSeries(chart);
153 QSplineSeries *series = new QSplineSeries(chart);
151 foreach (Data data, list)
154 foreach (Data data, list)
152 series->add(data.first);
155 series->add(data.first);
153 chart->addSeries(series);
156 chart->addSeries(series);
154 }
157 }
155 m_charts << chart;
158 m_charts << chart;
156
159
157 // scatter chart
160 // scatter chart
158 chart = new QChartView();
161 chart = new QChartView();
159 chart->setChartTitle("scatter chart");
162 chart->setChartTitle("scatter chart");
160 baseLayout->addWidget(chart, 2, 2);
163 baseLayout->addWidget(chart, 2, 2);
161 foreach (DataList list, m_dataTable) {
164 foreach (DataList list, m_dataTable) {
162 QScatterSeries *series = new QScatterSeries(chart);
165 QScatterSeries *series = new QScatterSeries(chart);
163 foreach (Data data, list)
166 foreach (Data data, list)
164 series->add(data.first);
167 series->add(data.first);
165 chart->addSeries(series);
168 chart->addSeries(series);
166 }
169 }
167 m_charts << chart;
170 m_charts << chart;
168
171
169 setLayout(baseLayout);
172 setLayout(baseLayout);
170 }
173 }
171
174
172 public Q_SLOTS:
175 public Q_SLOTS:
173
176
174 void updateTheme()
177 void updateTheme()
175 {
178 {
176 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
179 QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
177 foreach (QChartView *chart, m_charts)
180 foreach (QChartView *chart, m_charts)
178 chart->setChartTheme(theme);
181 chart->setChartTheme(theme);
179
182
180 QPalette pal = window()->palette();
183 QPalette pal = window()->palette();
181 if (theme == QChart::ChartThemeBlueCerulean) {
184 if (theme == QChart::ChartThemeLight) {
185 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
186 pal.setColor(QPalette::WindowText, QRgb(0x404044));
187 } else if (theme == QChart::ChartThemeDark) {
182 pal.setColor(QPalette::Window, QRgb(0x121218));
188 pal.setColor(QPalette::Window, QRgb(0x121218));
183 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
189 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
190 } else if (theme == QChart::ChartThemeBlueCerulean) {
191 pal.setColor(QPalette::Window, QRgb(0x40434a));
192 pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
193 } else if (theme == QChart::ChartThemeBrownSand) {
194 pal.setColor(QPalette::Window, QRgb(0x9e8965));
195 pal.setColor(QPalette::WindowText, QRgb(0x404044));
196 } else if (theme == QChart::ChartThemeBlueNcs) {
197 pal.setColor(QPalette::Window, QRgb(0x018bba));
198 pal.setColor(QPalette::WindowText, QRgb(0x404044));
184 } else {
199 } else {
185 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
200 pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
186 pal.setColor(QPalette::WindowText, QRgb(0x404044));
201 pal.setColor(QPalette::WindowText, QRgb(0x404044));
187 }
202 }
188 window()->setPalette(pal);
203 window()->setPalette(pal);
189 }
204 }
190
205
191 void updateAntialiasing(bool enabled)
206 void updateAntialiasing(bool enabled)
192 {
207 {
193 foreach (QChartView *chart, m_charts)
208 foreach (QChartView *chart, m_charts)
194 chart->setRenderHint(QPainter::Antialiasing, enabled);
209 chart->setRenderHint(QPainter::Antialiasing, enabled);
195 }
210 }
196
211
197 void updateAnimations(bool animated)
212 void updateAnimations(bool animated)
198 {
213 {
199 QChart::AnimationOptions options = QChart::NoAnimation;
214 QChart::AnimationOptions options = QChart::NoAnimation;
200 if (animated)
215 if (animated)
201 options = QChart::AllAnimations;
216 options = QChart::AllAnimations;
202
217
203 foreach (QChartView *chart, m_charts)
218 foreach (QChartView *chart, m_charts)
204 chart->setAnimationOptions(options);
219 chart->setAnimationOptions(options);
205 }
220 }
206
221
207 private:
222 private:
208 QList<QChartView*> m_charts;
223 QList<QChartView*> m_charts;
209 QComboBox *m_themeComboBox;
224 QComboBox *m_themeComboBox;
210 DataTable m_dataTable;
225 DataTable m_dataTable;
211 };
226 };
212
227
213 int main(int argc, char *argv[])
228 int main(int argc, char *argv[])
214 {
229 {
215 QApplication a(argc, argv);
230 QApplication a(argc, argv);
216
231
217 QMainWindow window;
232 QMainWindow window;
218
233
219 MainWidget* widget = new MainWidget();
234 MainWidget* widget = new MainWidget();
220
235
221 window.setCentralWidget(widget);
236 window.setCentralWidget(widget);
222 window.resize(900, 600);
237 window.resize(900, 600);
223 window.show();
238 window.show();
224
239
225 return a.exec();
240 return a.exec();
226 }
241 }
227
242
228 #include "main.moc"
243 #include "main.moc"
@@ -1,46 +1,49
1 #ifndef DECLARATIVECHART_H
1 #ifndef DECLARATIVECHART_H
2 #define DECLARATIVECHART_H
2 #define DECLARATIVECHART_H
3
3
4 #include <QtCore/QtGlobal>
4 #include <QtCore/QtGlobal>
5 #include <QDeclarativeItem>
5 #include <QDeclarativeItem>
6 #include <qchart.h>
6 #include <qchart.h>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class DeclarativeChart : public QDeclarativeItem
10 class DeclarativeChart : public QDeclarativeItem
11 // TODO: for QTQUICK2: extend QQuickPainterItem instead
11 // TODO: for QTQUICK2: extend QQuickPainterItem instead
12 //class DeclarativeChart : public QQuickPaintedItem, public Chart
12 //class DeclarativeChart : public QQuickPaintedItem, public Chart
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 Q_ENUMS(ChartTheme)
15 Q_ENUMS(ChartTheme)
16 Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme)
16 Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme)
17
17
18 public:
18 public:
19 enum ChartTheme {
19 enum ChartTheme {
20 ThemeDefault,
20 ThemeDefault,
21 ThemeLight,
22 ThemeBlueCerulean,
23 ThemeDark,
24 ThemeBrownSand,
25 ThemeBlueNcs,
21 ThemeVanilla,
26 ThemeVanilla,
22 ThemeIcy,
27 ThemeIcy,
23 ThemeGrayscale,
28 ThemeGrayscale,
24 ThemeScientific,
29 ThemeScientific
25 ThemeBlueCerulean,
26 ThemeLight
27 };
30 };
28 DeclarativeChart(QDeclarativeItem *parent = 0);
31 DeclarativeChart(QDeclarativeItem *parent = 0);
29
32
30 public: // From QDeclarativeItem/QGraphicsItem
33 public: // From QDeclarativeItem/QGraphicsItem
31 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
34 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
32 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
35 void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
33
36
34 public:
37 public:
35 void setTheme(ChartTheme theme) {m_chart->setChartTheme((QChart::ChartTheme) theme);}
38 void setTheme(ChartTheme theme) {m_chart->setChartTheme((QChart::ChartTheme) theme);}
36 ChartTheme theme();
39 ChartTheme theme();
37
40
38 public:
41 public:
39 // Extending QChart with DeclarativeChart is not possible because QObject does not support
42 // Extending QChart with DeclarativeChart is not possible because QObject does not support
40 // multi inheritance, so we now have a QChart as a member instead
43 // multi inheritance, so we now have a QChart as a member instead
41 QChart *m_chart;
44 QChart *m_chart;
42 };
45 };
43
46
44 QTCOMMERCIALCHART_END_NAMESPACE
47 QTCOMMERCIALCHART_END_NAMESPACE
45
48
46 #endif // DECLARATIVECHART_H
49 #endif // DECLARATIVECHART_H
@@ -1,391 +1,399
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 "barpresenter_p.h"
22 #include "barpresenter_p.h"
23 #include "stackedbarpresenter_p.h"
23 #include "stackedbarpresenter_p.h"
24 #include "percentbarpresenter_p.h"
24 #include "percentbarpresenter_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"
34 #include "chartthemebluecerulean_p.h"
35 #include "chartthemedark_p.h"
36 #include "chartthemebrownsand_p.h"
37 #include "chartthemebluencs_p.h"
33 #include "chartthemevanilla_p.h"
38 #include "chartthemevanilla_p.h"
34 #include "chartthemeicy_p.h"
39 #include "chartthemeicy_p.h"
35 #include "chartthemegrayscale_p.h"
40 #include "chartthemegrayscale_p.h"
36 #include "chartthemescientific_p.h"
41 #include "chartthemescientific_p.h"
37 #include "chartthemebluecerulean_p.h"
38 #include "chartthemelight_p.h"
39
40
42
41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
43 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42
44
43 ChartTheme::ChartTheme(QChart::ChartTheme id) :
45 ChartTheme::ChartTheme(QChart::ChartTheme id) :
44 m_masterFont(QFont()),
46 m_masterFont(QFont()),
45 m_titleBrush(QColor(QRgb(0x000000))),
47 m_titleBrush(QColor(QRgb(0x000000))),
46 m_axisLinePen(QPen(QRgb(0x000000))),
48 m_axisLinePen(QPen(QRgb(0x000000))),
47 m_axisLabelBrush(QColor(QRgb(0x000000))),
49 m_axisLabelBrush(QColor(QRgb(0x000000))),
48 m_backgroundShadesPen(Qt::NoPen),
50 m_backgroundShadesPen(Qt::NoPen),
49 m_backgroundShadesBrush(Qt::NoBrush),
51 m_backgroundShadesBrush(Qt::NoBrush),
50 m_backgroundShades(BackgroundShadesNone),
52 m_backgroundShades(BackgroundShadesNone),
51 m_gridLinePen(QPen(QRgb(0x000000)))
53 m_gridLinePen(QPen(QRgb(0x000000)))
52 {
54 {
53 m_id = id;
55 m_id = id;
54 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
56 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
55 }
57 }
56
58
57
59
58 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
60 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
59 {
61 {
60 switch(theme) {
62 switch(theme) {
63 case QChart::ChartThemeLight:
64 return new ChartThemeLight();
65 case QChart::ChartThemeBlueCerulean:
66 return new ChartThemeBlueCerulean();
67 case QChart::ChartThemeDark:
68 return new ChartThemeDark();
69 case QChart::ChartThemeBrownSand:
70 return new ChartThemeBrownSand();
71 case QChart::ChartThemeBlueNcs:
72 return new ChartThemeBlueNcs();
61 case QChart::ChartThemeVanilla:
73 case QChart::ChartThemeVanilla:
62 return new ChartThemeVanilla();
74 return new ChartThemeVanilla();
63 case QChart::ChartThemeIcy:
75 case QChart::ChartThemeIcy:
64 return new ChartThemeIcy();
76 return new ChartThemeIcy();
65 case QChart::ChartThemeGrayscale:
77 case QChart::ChartThemeGrayscale:
66 return new ChartThemeGrayscale();
78 return new ChartThemeGrayscale();
67 case QChart::ChartThemeScientific:
79 case QChart::ChartThemeScientific:
68 return new ChartThemeScientific();
80 return new ChartThemeScientific();
69 case QChart::ChartThemeBlueCerulean:
70 return new ChartThemeBlueCerulean();
71 case QChart::ChartThemeLight:
72 return new ChartThemeLight();
73 default:
81 default:
74 return new ChartThemeDefault();
82 return new ChartThemeDefault();
75 }
83 }
76 }
84 }
77
85
78 void ChartTheme::decorate(QChart* chart,bool force)
86 void ChartTheme::decorate(QChart* chart,bool force)
79 {
87 {
80 QPen pen;
88 QPen pen;
81 QBrush brush;
89 QBrush brush;
82
90
83 if(brush == chart->backgroundBrush() || force)
91 if(brush == chart->backgroundBrush() || force)
84 {
92 {
85 if (m_backgroundShades == BackgroundShadesNone) {
93 if (m_backgroundShades == BackgroundShadesNone) {
86 chart->setBackgroundBrush(m_chartBackgroundGradient);
94 chart->setBackgroundBrush(m_chartBackgroundGradient);
87 }
95 }
88 else {
96 else {
89 chart->setBackgroundBrush(Qt::NoBrush);
97 chart->setBackgroundBrush(Qt::NoBrush);
90 }
98 }
91 }
99 }
92 chart->setTitleFont(m_masterFont);
100 chart->setTitleFont(m_masterFont);
93 chart->setTitleBrush(m_titleBrush);
101 chart->setTitleBrush(m_titleBrush);
94 }
102 }
95
103
96 void ChartTheme::decorate(QLegend* legend,bool force)
104 void ChartTheme::decorate(QLegend* legend,bool force)
97 {
105 {
98 QPen pen;
106 QPen pen;
99 QBrush brush;
107 QBrush brush;
100
108
101 if (pen == legend->pen() || force){
109 if (pen == legend->pen() || force){
102 //TODO:: legend->setPen();
110 //TODO:: legend->setPen();
103 }
111 }
104
112
105
113
106 if (brush == legend->brush() || force) {
114 if (brush == legend->brush() || force) {
107 legend->setBrush(m_chartBackgroundGradient);
115 legend->setBrush(m_chartBackgroundGradient);
108 }
116 }
109 }
117 }
110
118
111 void ChartTheme::decorate(QAreaSeries* series, int index,bool force)
119 void ChartTheme::decorate(QAreaSeries* series, int index,bool force)
112 {
120 {
113 QPen pen;
121 QPen pen;
114 QBrush brush;
122 QBrush brush;
115
123
116 if (pen == series->pen() || force){
124 if (pen == series->pen() || force){
117 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
125 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
118 pen.setWidthF(2);
126 pen.setWidthF(2);
119 series->setPen(pen);
127 series->setPen(pen);
120 }
128 }
121
129
122 if (brush == series->brush() || force) {
130 if (brush == series->brush() || force) {
123 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
131 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
124 series->setBrush(brush);
132 series->setBrush(brush);
125 }
133 }
126 }
134 }
127
135
128
136
129 void ChartTheme::decorate(QLineSeries* series,int index,bool force)
137 void ChartTheme::decorate(QLineSeries* series,int index,bool force)
130 {
138 {
131 QPen pen;
139 QPen pen;
132 if(pen == series->pen() || force ){
140 if(pen == series->pen() || force ){
133 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
141 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
134 pen.setWidthF(2);
142 pen.setWidthF(2);
135 series->setPen(pen);
143 series->setPen(pen);
136 }
144 }
137 }
145 }
138
146
139 void ChartTheme::decorate(QBarSeries* series,int index,bool force)
147 void ChartTheme::decorate(QBarSeries* series,int index,bool force)
140 {
148 {
141 QBrush brush;
149 QBrush brush;
142 QList<QBarSet*> sets = series->barSets();
150 QList<QBarSet*> sets = series->barSets();
143
151
144 for (int i=0; i<sets.count(); i++) {
152 for (int i=0; i<sets.count(); i++) {
145 qreal pos = 0.5;
153 qreal pos = 0.5;
146 if (sets.count() > 1)
154 if (sets.count() > 1)
147 pos = (qreal) i / (qreal) (sets.count() - 1);
155 pos = (qreal) i / (qreal) (sets.count() - 1);
148
156
149 if(brush == sets.at(i)->brush() || force ){
157 if(brush == sets.at(i)->brush() || force ){
150 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
158 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
151 sets.at(i)->setBrush(QBrush(c));
159 sets.at(i)->setBrush(QBrush(c));
152 }
160 }
153 // Pick label color as far as possible from bar color (within gradient).
161 // Pick label color as far as possible from bar color (within gradient).
154 // 0.3 is magic number that was picked as value that gave enough contrast with icy theme gradient :)
162 // 0.3 is magic number that was picked as value that gave enough contrast with icy theme gradient :)
155 // TODO: better picking of label color?
163 // TODO: better picking of label color?
156 QColor c;
164 QColor c;
157
165
158 if (pos < 0.3) {
166 if (pos < 0.3) {
159 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
167 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
160 } else {
168 } else {
161 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
169 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
162 }
170 }
163 sets.at(i)->setFloatingValuePen(QPen(c));
171 sets.at(i)->setFloatingValuePen(QPen(c));
164
172
165 }
173 }
166 }
174 }
167
175
168 void ChartTheme::decorate(QStackedBarSeries* series,int index,bool force)
176 void ChartTheme::decorate(QStackedBarSeries* series,int index,bool force)
169 {
177 {
170 QBrush brush;
178 QBrush brush;
171 QList<QBarSet*> sets = series->barSets();
179 QList<QBarSet*> sets = series->barSets();
172
180
173 for (int i=0; i<sets.count(); i++) {
181 for (int i=0; i<sets.count(); i++) {
174 qreal pos = 0.5;
182 qreal pos = 0.5;
175 if (sets.count() > 1)
183 if (sets.count() > 1)
176 pos = (qreal) i / (qreal) (sets.count() - 1);
184 pos = (qreal) i / (qreal) (sets.count() - 1);
177 if(brush == sets.at(i)->brush() || force){
185 if(brush == sets.at(i)->brush() || force){
178 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
186 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
179 sets.at(i)->setBrush(QBrush(c));
187 sets.at(i)->setBrush(QBrush(c));
180 }
188 }
181 QColor c;
189 QColor c;
182 if (pos < 0.3) {
190 if (pos < 0.3) {
183 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
191 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
184 } else {
192 } else {
185 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
193 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
186 }
194 }
187 sets.at(i)->setFloatingValuePen(QPen(c));
195 sets.at(i)->setFloatingValuePen(QPen(c));
188 }
196 }
189 }
197 }
190
198
191 void ChartTheme::decorate(QPercentBarSeries* series,int index,bool force)
199 void ChartTheme::decorate(QPercentBarSeries* series,int index,bool force)
192 {
200 {
193 QBrush brush;
201 QBrush brush;
194 QList<QBarSet*> sets = series->barSets();
202 QList<QBarSet*> sets = series->barSets();
195
203
196 for (int i=0; i<sets.count(); i++) {
204 for (int i=0; i<sets.count(); i++) {
197 qreal pos = 0.5;
205 qreal pos = 0.5;
198 if (sets.count() > 1)
206 if (sets.count() > 1)
199 pos = (qreal) i / (qreal) (sets.count() - 1);
207 pos = (qreal) i / (qreal) (sets.count() - 1);
200
208
201 if(brush == sets.at(i)->brush() || force){
209 if(brush == sets.at(i)->brush() || force){
202 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
210 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
203 sets.at(i)->setBrush(QBrush(c));
211 sets.at(i)->setBrush(QBrush(c));
204 }
212 }
205 QColor c;
213 QColor c;
206 if (pos < 0.3) {
214 if (pos < 0.3) {
207 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
215 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1);
208 } else {
216 } else {
209 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
217 c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0);
210 }
218 }
211 sets.at(i)->setFloatingValuePen(QPen(c));
219 sets.at(i)->setFloatingValuePen(QPen(c));
212 }
220 }
213 }
221 }
214
222
215 void ChartTheme::decorate(QScatterSeries* series, int index,bool force)
223 void ChartTheme::decorate(QScatterSeries* series, int index,bool force)
216 {
224 {
217
225
218 QPen pen;
226 QPen pen;
219 QBrush brush;
227 QBrush brush;
220
228
221 if (pen == series->pen() || force) {
229 if (pen == series->pen() || force) {
222 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
230 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1.0));
223 pen.setWidthF(2);
231 pen.setWidthF(2);
224 series->setPen(pen);
232 series->setPen(pen);
225 }
233 }
226
234
227 if (brush == series->brush() || force) {
235 if (brush == series->brush() || force) {
228 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
236 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
229 series->setBrush(brush);
237 series->setBrush(brush);
230 }
238 }
231 }
239 }
232
240
233 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
241 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
234 {
242 {
235 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
243 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
236
244
237 QPen pen;
245 QPen pen;
238 QBrush brush;
246 QBrush brush;
239
247
240 for (int i(0); i < series->slices().count(); i++) {
248 for (int i(0); i < series->slices().count(); i++) {
241 qreal pos = (qreal) i / (qreal) series->count();
249 qreal pos = (qreal) i / (qreal) series->count();
242 if( pen == series->slices().at(i)->slicePen() || force){
250 if( pen == series->slices().at(i)->slicePen() || force){
243 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.1);
251 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.1);
244 series->slices().at(i)->setSlicePen(penColor);
252 series->slices().at(i)->setSlicePen(penColor);
245 }
253 }
246 if( brush == series->slices().at(i)->sliceBrush() || force){
254 if( brush == series->slices().at(i)->sliceBrush() || force){
247 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
255 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
248 series->slices().at(i)->setSliceBrush(brushColor);
256 series->slices().at(i)->setSliceBrush(brushColor);
249 }
257 }
250 }
258 }
251 }
259 }
252
260
253 void ChartTheme::decorate(QSplineSeries* series, int index, bool force)
261 void ChartTheme::decorate(QSplineSeries* series, int index, bool force)
254 {
262 {
255 QPen pen;
263 QPen pen;
256 if(pen == series->pen() || force){
264 if(pen == series->pen() || force){
257 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
265 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
258 pen.setWidthF(2);
266 pen.setWidthF(2);
259 series->setPen(pen);
267 series->setPen(pen);
260 }
268 }
261 }
269 }
262
270
263 void ChartTheme::decorate(QChartAxis* axis,bool axisX, bool force)
271 void ChartTheme::decorate(QChartAxis* axis,bool axisX, bool force)
264 {
272 {
265 QPen pen;
273 QPen pen;
266 QBrush brush;
274 QBrush brush;
267 QFont font;
275 QFont font;
268
276
269 if (axis->isAxisVisible()) {
277 if (axis->isAxisVisible()) {
270
278
271 if(brush == axis->labelsBrush() || force){
279 if(brush == axis->labelsBrush() || force){
272 axis->setLabelsBrush(m_axisLabelBrush);
280 axis->setLabelsBrush(m_axisLabelBrush);
273 }
281 }
274 if(pen == axis->labelsPen() || force){
282 if(pen == axis->labelsPen() || force){
275 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
283 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
276 }
284 }
277
285
278
286
279 if (axis->shadesVisible() || force) {
287 if (axis->shadesVisible() || force) {
280
288
281 if(brush == axis->shadesBrush() || force){
289 if(brush == axis->shadesBrush() || force){
282 axis->setShadesBrush(m_backgroundShadesBrush);
290 axis->setShadesBrush(m_backgroundShadesBrush);
283 }
291 }
284
292
285 if(pen == axis->shadesPen() || force){
293 if(pen == axis->shadesPen() || force){
286 axis->setShadesPen(m_backgroundShadesPen);
294 axis->setShadesPen(m_backgroundShadesPen);
287 }
295 }
288
296
289 if(force && (m_backgroundShades == BackgroundShadesBoth
297 if(force && (m_backgroundShades == BackgroundShadesBoth
290 || (m_backgroundShades == BackgroundShadesVertical && axisX)
298 || (m_backgroundShades == BackgroundShadesVertical && axisX)
291 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
299 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
292 axis->setShadesVisible(true);
300 axis->setShadesVisible(true);
293
301
294 }
302 }
295 }
303 }
296
304
297 if(pen == axis->axisPen() || force){
305 if(pen == axis->axisPen() || force){
298 axis->setAxisPen(m_axisLinePen);
306 axis->setAxisPen(m_axisLinePen);
299 }
307 }
300
308
301 if(pen == axis->gridLinePen() || force){
309 if(pen == axis->gridLinePen() || force){
302 axis->setGridLinePen(m_gridLinePen);
310 axis->setGridLinePen(m_gridLinePen);
303 }
311 }
304
312
305 if(font == axis->labelsFont() || force){
313 if(font == axis->labelsFont() || force){
306 axis->setLabelsFont(m_masterFont);
314 axis->setLabelsFont(m_masterFont);
307 }
315 }
308 }
316 }
309 }
317 }
310
318
311 void ChartTheme::generateSeriesGradients()
319 void ChartTheme::generateSeriesGradients()
312 {
320 {
313 // Generate gradients in HSV color space
321 // Generate gradients in HSV color space
314 foreach (QColor color, m_seriesColors) {
322 foreach (QColor color, m_seriesColors) {
315 QLinearGradient g;
323 QLinearGradient g;
316 qreal h = color.hsvHueF();
324 qreal h = color.hsvHueF();
317 qreal s = color.hsvSaturationF();
325 qreal s = color.hsvSaturationF();
318
326
319 // TODO: tune the algorithm to give nice results with most base colors defined in
327 // TODO: tune the algorithm to give nice results with most base colors defined in
320 // most themes. The rest of the gradients we can define manually in theme specific
328 // most themes. The rest of the gradients we can define manually in theme specific
321 // implementation.
329 // implementation.
322 QColor start = color;
330 QColor start = color;
323 start.setHsvF(h, 0.05, 0.95);
331 start.setHsvF(h, 0.05, 0.95);
324 g.setColorAt(0.0, start);
332 g.setColorAt(0.0, start);
325
333
326 g.setColorAt(0.5, color);
334 g.setColorAt(0.5, color);
327
335
328 QColor end = color;
336 QColor end = color;
329 end.setHsvF(h, s, 0.25);
337 end.setHsvF(h, s, 0.25);
330 g.setColorAt(1.0, end);
338 g.setColorAt(1.0, end);
331
339
332 m_seriesGradients << g;
340 m_seriesGradients << g;
333 }
341 }
334 }
342 }
335
343
336
344
337 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
345 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
338 {
346 {
339 Q_ASSERT(pos >=0.0 && pos <= 1.0);
347 Q_ASSERT(pos >=0.0 && pos <= 1.0);
340 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
348 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
341 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
349 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
342 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
350 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
343 QColor c;
351 QColor c;
344 c.setRgbF(r, g, b);
352 c.setRgbF(r, g, b);
345 return c;
353 return c;
346 }
354 }
347
355
348 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
356 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
349 {
357 {
350 Q_ASSERT(pos >=0 && pos <= 1.0);
358 Q_ASSERT(pos >=0 && pos <= 1.0);
351
359
352 // another possibility:
360 // another possibility:
353 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
361 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
354
362
355 QGradientStops stops = gradient.stops();
363 QGradientStops stops = gradient.stops();
356 int count = stops.count();
364 int count = stops.count();
357
365
358 // find previous stop relative to position
366 // find previous stop relative to position
359 QGradientStop prev = stops.first();
367 QGradientStop prev = stops.first();
360 for (int i=0; i<count; i++) {
368 for (int i=0; i<count; i++) {
361 QGradientStop stop = stops.at(i);
369 QGradientStop stop = stops.at(i);
362 if (pos > stop.first)
370 if (pos > stop.first)
363 prev = stop;
371 prev = stop;
364
372
365 // given position is actually a stop position?
373 // given position is actually a stop position?
366 if (pos == stop.first) {
374 if (pos == stop.first) {
367 //qDebug() << "stop color" << pos;
375 //qDebug() << "stop color" << pos;
368 return stop.second;
376 return stop.second;
369 }
377 }
370 }
378 }
371
379
372 // find next stop relative to position
380 // find next stop relative to position
373 QGradientStop next = stops.last();
381 QGradientStop next = stops.last();
374 for (int i=count-1; i>=0; i--) {
382 for (int i=count-1; i>=0; i--) {
375 QGradientStop stop = stops.at(i);
383 QGradientStop stop = stops.at(i);
376 if (pos < stop.first)
384 if (pos < stop.first)
377 next = stop;
385 next = stop;
378 }
386 }
379
387
380 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
388 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
381
389
382 qreal range = next.first - prev.first;
390 qreal range = next.first - prev.first;
383 qreal posDelta = pos - prev.first;
391 qreal posDelta = pos - prev.first;
384 qreal relativePos = posDelta / range;
392 qreal relativePos = posDelta / range;
385
393
386 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
394 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
387
395
388 return colorAt(prev.second, next.second, relativePos);
396 return colorAt(prev.second, next.second, relativePos);
389 }
397 }
390
398
391 QTCOMMERCIALCHART_END_NAMESPACE
399 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,123 +1,126
1 #ifndef QCHART_H
1 #ifndef QCHART_H
2 #define QCHART_H
2 #define QCHART_H
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qseries.h>
5 #include <qseries.h>
6 #include <QGraphicsWidget>
6 #include <QGraphicsWidget>
7 #include <QLinearGradient>
7 #include <QLinearGradient>
8 #include <QFont>
8 #include <QFont>
9
9
10 class QGraphicsSceneResizeEvent;
10 class QGraphicsSceneResizeEvent;
11
11
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13
13
14 class AxisItem;
14 class AxisItem;
15 class QSeries;
15 class QSeries;
16 class PlotDomain;
16 class PlotDomain;
17 class BarPresenter;
17 class BarPresenter;
18 class QChartAxis;
18 class QChartAxis;
19 class ChartTheme;
19 class ChartTheme;
20 class ChartItem;
20 class ChartItem;
21 class ChartDataSet;
21 class ChartDataSet;
22 class ChartPresenter;
22 class ChartPresenter;
23 class QLegend;
23 class QLegend;
24 class ChartBackground;
24 class ChartBackground;
25
25
26
26
27 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
27 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
28 {
28 {
29 Q_OBJECT
29 Q_OBJECT
30 public:
30 public:
31 enum ChartTheme {
31 enum ChartTheme {
32 ChartThemeDefault,
32 ChartThemeDefault,
33 ChartThemeLight,
34 ChartThemeBlueCerulean,
35 ChartThemeDark,
36 ChartThemeBrownSand,
37 ChartThemeBlueNcs,
33 ChartThemeVanilla,
38 ChartThemeVanilla,
34 ChartThemeIcy,
39 ChartThemeIcy,
35 ChartThemeGrayscale,
40 ChartThemeGrayscale,
36 ChartThemeScientific,
41 ChartThemeScientific,
37 ChartThemeBlueCerulean,
38 ChartThemeLight,
39 ChartThemeCount
42 ChartThemeCount
40 };
43 };
41
44
42 enum AnimationOption {
45 enum AnimationOption {
43 NoAnimation = 0x0,
46 NoAnimation = 0x0,
44 GridAxisAnimations = 0x1,
47 GridAxisAnimations = 0x1,
45 SeriesAnimations =0x2,
48 SeriesAnimations =0x2,
46 AllAnimations = 0x3
49 AllAnimations = 0x3
47 };
50 };
48 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
51 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
49
52
50 public:
53 public:
51 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
54 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
52 ~QChart();
55 ~QChart();
53
56
54 void addSeries(QSeries* series, QChartAxis* axisY = 0);
57 void addSeries(QSeries* series, QChartAxis* axisY = 0);
55 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
58 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
56 void removeAllSeries(); // deletes series and axis
59 void removeAllSeries(); // deletes series and axis
57
60
58 void setChartTheme(QChart::ChartTheme theme);
61 void setChartTheme(QChart::ChartTheme theme);
59 QChart::ChartTheme chartTheme() const;
62 QChart::ChartTheme chartTheme() const;
60
63
61 void setTitle(const QString& title);
64 void setTitle(const QString& title);
62 QString title() const;
65 QString title() const;
63 void setTitleFont(const QFont& font);
66 void setTitleFont(const QFont& font);
64 QFont titleFont() const;
67 QFont titleFont() const;
65 void setTitleBrush(const QBrush &brush);
68 void setTitleBrush(const QBrush &brush);
66 QBrush titleBrush() const;
69 QBrush titleBrush() const;
67 void setBackgroundBrush(const QBrush& brush);
70 void setBackgroundBrush(const QBrush& brush);
68 QBrush backgroundBrush() const;
71 QBrush backgroundBrush() const;
69 void setBackgroundPen(const QPen& pen);
72 void setBackgroundPen(const QPen& pen);
70 QPen backgroundPen() const;
73 QPen backgroundPen() const;
71
74
72 void setBackgroundVisible(bool visible);
75 void setBackgroundVisible(bool visible);
73 bool isBackgroundVisible() const;
76 bool isBackgroundVisible() const;
74
77
75 void setAnimationOptions(AnimationOptions options);
78 void setAnimationOptions(AnimationOptions options);
76 AnimationOptions animationOptions() const;
79 AnimationOptions animationOptions() const;
77
80
78 void zoomIn();
81 void zoomIn();
79 void zoomIn(const QRectF& rect);
82 void zoomIn(const QRectF& rect);
80 void zoomOut();
83 void zoomOut();
81 void zoomReset();
84 void zoomReset();
82 void scrollLeft();
85 void scrollLeft();
83 void scrollRight();
86 void scrollRight();
84 void scrollUp();
87 void scrollUp();
85 void scrollDown();
88 void scrollDown();
86
89
87 QChartAxis* axisX() const;
90 QChartAxis* axisX() const;
88 QChartAxis* axisY() const;
91 QChartAxis* axisY() const;
89
92
90 // TODO: take (and give) legend instead of this.
93 // TODO: take (and give) legend instead of this.
91 QLegend* legend();
94 QLegend* legend();
92
95
93
96
94 int padding() const;
97 int padding() const;
95
98
96 protected:
99 protected:
97 void resizeEvent(QGraphicsSceneResizeEvent *event);
100 void resizeEvent(QGraphicsSceneResizeEvent *event);
98
101
99 private:
102 private:
100 inline void createChartBackgroundItem();
103 inline void createChartBackgroundItem();
101 inline void createChartTitleItem();
104 inline void createChartTitleItem();
102 void setPadding(int padding);
105 void setPadding(int padding);
103 void setBackgroundPadding(int padding);
106 void setBackgroundPadding(int padding);
104 void setBackgroundDiameter(int diameter);
107 void setBackgroundDiameter(int diameter);
105 void updateLayout();
108 void updateLayout();
106
109
107 private:
110 private:
108 Q_DISABLE_COPY(QChart)
111 Q_DISABLE_COPY(QChart)
109 ChartBackground* m_backgroundItem;
112 ChartBackground* m_backgroundItem;
110 QGraphicsSimpleTextItem* m_titleItem;
113 QGraphicsSimpleTextItem* m_titleItem;
111 QRectF m_rect;
114 QRectF m_rect;
112 QLegend* m_legend;
115 QLegend* m_legend;
113 ChartDataSet *m_dataset;
116 ChartDataSet *m_dataset;
114 ChartPresenter *m_presenter;
117 ChartPresenter *m_presenter;
115 int m_padding;
118 int m_padding;
116 int m_backgroundPadding;
119 int m_backgroundPadding;
117 };
120 };
118
121
119 QTCOMMERCIALCHART_END_NAMESPACE
122 QTCOMMERCIALCHART_END_NAMESPACE
120
123
121 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
124 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
122
125
123 #endif
126 #endif
@@ -1,144 +1,147
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
2 TARGET = QtCommercialChart
2 TARGET = QtCommercialChart
3 DESTDIR = $$CHART_BUILD_LIB_DIR
3 DESTDIR = $$CHART_BUILD_LIB_DIR
4 TEMPLATE = lib
4 TEMPLATE = lib
5 QT += core \
5 QT += core \
6 gui
6 gui
7 win32-msvc*: LIBS += User32.lib
7 win32-msvc*: LIBS += User32.lib
8 CONFIG += debug_and_release
8 CONFIG += debug_and_release
9 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
10 SOURCES += \
10 SOURCES += \
11 chartdataset.cpp \
11 chartdataset.cpp \
12 chartpresenter.cpp \
12 chartpresenter.cpp \
13 charttheme.cpp \
13 charttheme.cpp \
14 domain.cpp \
14 domain.cpp \
15 qchart.cpp \
15 qchart.cpp \
16 qchartview.cpp \
16 qchartview.cpp \
17 qseries.cpp \
17 qseries.cpp \
18 qlegend.cpp \
18 qlegend.cpp \
19 legendmarker.cpp \
19 legendmarker.cpp \
20 chartbackground.cpp
20 chartbackground.cpp
21 PRIVATE_HEADERS += \
21 PRIVATE_HEADERS += \
22 chartdataset_p.h \
22 chartdataset_p.h \
23 chartitem_p.h \
23 chartitem_p.h \
24 chartpresenter_p.h \
24 chartpresenter_p.h \
25 charttheme_p.h \
25 charttheme_p.h \
26 domain_p.h \
26 domain_p.h \
27 legendmarker_p.h \
27 legendmarker_p.h \
28 chartbackground_p.h
28 chartbackground_p.h
29 PUBLIC_HEADERS += \
29 PUBLIC_HEADERS += \
30 qchart.h \
30 qchart.h \
31 qchartglobal.h \
31 qchartglobal.h \
32 qseries.h \
32 qseries.h \
33 qchartview.h \
33 qchartview.h \
34 qlegend.h
34 qlegend.h
35
35
36 include(animations/animations.pri)
36 include(animations/animations.pri)
37 include(axis/axis.pri)
37 include(axis/axis.pri)
38 include(xychart/xychart.pri)
38 include(xychart/xychart.pri)
39 include(linechart/linechart.pri)
39 include(linechart/linechart.pri)
40 include(areachart/areachart.pri)
40 include(areachart/areachart.pri)
41 include(barchart/barchart.pri)
41 include(barchart/barchart.pri)
42 include(piechart/piechart.pri)
42 include(piechart/piechart.pri)
43 include(scatterseries/scatter.pri)
43 include(scatterseries/scatter.pri)
44 include(splinechart/splinechart.pri)
44 include(splinechart/splinechart.pri)
45
45
46 THEMES += themes/chartthemedefault_p.h \
46 THEMES += themes/chartthemedefault_p.h \
47 themes/chartthemelight_p.h \
48 themes/chartthemebluecerulean_p.h \
49 themes/chartthemedark_p.h \
50 themes/chartthemebrownsand_p.h \
51 themes/chartthemebluencs_p.h \
47 themes/chartthemeicy_p.h \
52 themes/chartthemeicy_p.h \
48 themes/chartthemegrayscale_p.h \
53 themes/chartthemegrayscale_p.h \
49 themes/chartthemescientific_p.h \
54 themes/chartthemescientific_p.h \
50 themes/chartthemevanilla_p.h \
55 themes/chartthemevanilla_p.h
51 themes/chartthemebluecerulean_p.h \
52 themes/chartthemelight_p.h
53
56
54 HEADERS += $$PUBLIC_HEADERS
57 HEADERS += $$PUBLIC_HEADERS
55 HEADERS += $$PRIVATE_HEADERS
58 HEADERS += $$PRIVATE_HEADERS
56 HEADERS += $$THEMES
59 HEADERS += $$THEMES
57 INCLUDEPATH += linechart \
60 INCLUDEPATH += linechart \
58 barchart \
61 barchart \
59 themes \
62 themes \
60 .
63 .
61 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
64 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
62 MOC_DIR = $$CHART_BUILD_DIR/lib
65 MOC_DIR = $$CHART_BUILD_DIR/lib
63 UI_DIR = $$CHART_BUILD_DIR/lib
66 UI_DIR = $$CHART_BUILD_DIR/lib
64 RCC_DIR = $$CHART_BUILD_DIR/lib
67 RCC_DIR = $$CHART_BUILD_DIR/lib
65 DEFINES += QTCOMMERCIALCHART_LIBRARY
68 DEFINES += QTCOMMERCIALCHART_LIBRARY
66
69
67 #qt public headers
70 #qt public headers
68 #this is very primitive and lame parser , TODO: make perl script insted
71 #this is very primitive and lame parser , TODO: make perl script insted
69 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR)
72 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR)
70 {
73 {
71 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
74 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
72 }
75 }
73
76
74 for(file, PUBLIC_HEADERS) {
77 for(file, PUBLIC_HEADERS) {
75 name = $$split(file,'/')
78 name = $$split(file,'/')
76 name = $$last(name)
79 name = $$last(name)
77 class = "$$cat($$file)"
80 class = "$$cat($$file)"
78 class = $$find(class,class)
81 class = $$find(class,class)
79 !isEmpty(class){
82 !isEmpty(class){
80 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
83 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
81 class = $$member(class,1)
84 class = $$member(class,1)
82 class = $$split(class,' ')
85 class = $$split(class,' ')
83 class = $$replace(class,' ','')
86 class = $$replace(class,' ','')
84 class = $$member(class,0)
87 class = $$member(class,0)
85 win32:{
88 win32:{
86 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
89 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
87 }else{
90 }else{
88 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
91 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
89 }
92 }
90 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
93 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
91 system($$command)
94 system($$command)
92 }
95 }
93 }
96 }
94
97
95 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
98 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
96 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
99 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
97
100
98 target.path = $$[QT_INSTALL_LIBS]
101 target.path = $$[QT_INSTALL_LIBS]
99 INSTALLS += target public_headers
102 INSTALLS += target public_headers
100
103
101 install_build_public_headers.name = build_public_headers
104 install_build_public_headers.name = build_public_headers
102 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
105 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
103 install_build_public_headers.input = PUBLIC_HEADERS
106 install_build_public_headers.input = PUBLIC_HEADERS
104 install_build_public_headers.commands = $$QMAKE_COPY \
107 install_build_public_headers.commands = $$QMAKE_COPY \
105 ${QMAKE_FILE_NAME} \
108 ${QMAKE_FILE_NAME} \
106 $$CHART_BUILD_PUBLIC_HEADER_DIR
109 $$CHART_BUILD_PUBLIC_HEADER_DIR
107 install_build_public_headers.CONFIG += target_predeps \
110 install_build_public_headers.CONFIG += target_predeps \
108 no_link
111 no_link
109
112
110 install_build_private_headers.name = buld_private_headers
113 install_build_private_headers.name = buld_private_headers
111 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
114 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
112 install_build_private_headers.input = PRIVATE_HEADERS
115 install_build_private_headers.input = PRIVATE_HEADERS
113 install_build_private_headers.commands = $$QMAKE_COPY \
116 install_build_private_headers.commands = $$QMAKE_COPY \
114 ${QMAKE_FILE_NAME} \
117 ${QMAKE_FILE_NAME} \
115 $$CHART_BUILD_PRIVATE_HEADER_DIR
118 $$CHART_BUILD_PRIVATE_HEADER_DIR
116 install_build_private_headers.CONFIG += target_predeps \
119 install_build_private_headers.CONFIG += target_predeps \
117 no_link
120 no_link
118
121
119 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
122 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
120 install_build_private_headers \
123 install_build_private_headers \
121
124
122 chartversion.target = qchartversion_p.h
125 chartversion.target = qchartversion_p.h
123 chartversion.commands = @echo \
126 chartversion.commands = @echo \
124 "build_time" \
127 "build_time" \
125 > \
128 > \
126 $$chartversion.target;
129 $$chartversion.target;
127 chartversion.depends = $$HEADERS \
130 chartversion.depends = $$HEADERS \
128 $$SOURCES
131 $$SOURCES
129 PRE_TARGETDEPS += qchartversion_p.h
132 PRE_TARGETDEPS += qchartversion_p.h
130 QMAKE_CLEAN += qchartversion_p.h
133 QMAKE_CLEAN += qchartversion_p.h
131 QMAKE_EXTRA_TARGETS += chartversion
134 QMAKE_EXTRA_TARGETS += chartversion
132 unix:QMAKE_DISTCLEAN += -r \
135 unix:QMAKE_DISTCLEAN += -r \
133 $$CHART_BUILD_HEADER_DIR \
136 $$CHART_BUILD_HEADER_DIR \
134 $$CHART_BUILD_LIB_DIR
137 $$CHART_BUILD_LIB_DIR
135 win32:QMAKE_DISTCLEAN += /Q \
138 win32:QMAKE_DISTCLEAN += /Q \
136 $$CHART_BUILD_HEADER_DIR \
139 $$CHART_BUILD_HEADER_DIR \
137 $$CHART_BUILD_LIB_DIR
140 $$CHART_BUILD_LIB_DIR
138
141
139 # treat warnings as errors
142 # treat warnings as errors
140 win32-msvc*: {
143 win32-msvc*: {
141 QMAKE_CXXFLAGS += /WX
144 QMAKE_CXXFLAGS += /WX
142 } else {
145 } else {
143 QMAKE_CXXFLAGS += -Werror
146 QMAKE_CXXFLAGS += -Werror
144 }
147 }
@@ -1,36 +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(0x38ad6b);
11 m_seriesColors << QRgb(0xc7e85b);
12 m_seriesColors << QRgb(0x3c84a7);
12 m_seriesColors << QRgb(0x1cb54f);
13 m_seriesColors << QRgb(0xeb8817);
13 m_seriesColors << QRgb(0x5cbf9b);
14 m_seriesColors << QRgb(0x7b7f8c);
14 m_seriesColors << QRgb(0x009fbf);
15 m_seriesColors << QRgb(0xbf593e);
15 m_seriesColors << QRgb(0xee7392);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 // Background
19 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
20 backgroundGradient.setColorAt(0.0, QRgb(0x2e303a));
20 backgroundGradient.setColorAt(0.0, QRgb(0x056189));
21 backgroundGradient.setColorAt(1.0, QRgb(0x121218));
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");
26 m_masterFont = QFont("arial");
27 m_titleBrush = QBrush(QRgb(0xffffff));
27 m_titleBrush = QBrush(QRgb(0xffffff));
28 m_axisLinePen = QPen(QRgb(0x86878c));
28 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 m_axisLinePen.setWidth(2);
29 m_axisLinePen.setWidth(2);
30 m_axisLabelBrush = QBrush(QRgb(0xffffff));
30 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 m_gridLinePen = QPen(QRgb(0x86878c));
31 m_gridLinePen = QPen(QRgb(0x84a2b0));
32 m_gridLinePen.setWidth(1);
32 m_gridLinePen.setWidth(1);
33 }
33 }
34 };
34 };
35
35
36 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now