##// END OF EJS Templates
Removed chart view background
Tero Ahola -
r598:73bc9555ba68
parent child
Show More
@@ -1,399 +1,390
1 #include "qchartview.h"
1 #include "qchartview.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartaxis.h"
3 #include "qchartaxis.h"
4 #include <QGraphicsView>
4 #include <QGraphicsView>
5 #include <QGraphicsScene>
5 #include <QGraphicsScene>
6 #include <QRubberBand>
6 #include <QRubberBand>
7 #include <QResizeEvent>
7 #include <QResizeEvent>
8 #include <QDebug>
8 #include <QDebug>
9
9
10 /*!
10 /*!
11 \enum QChartView::RubberBandPolicy
11 \enum QChartView::RubberBandPolicy
12
12
13 This enum describes the different types of rubber bands that can be used for zoom rect selection
13 This enum describes the different types of rubber bands that can be used for zoom rect selection
14
14
15 \value NoRubberBand
15 \value NoRubberBand
16 \value VerticalRubberBand
16 \value VerticalRubberBand
17 \value HorizonalRubberBand
17 \value HorizonalRubberBand
18 \value RectangleRubberBand
18 \value RectangleRubberBand
19 */
19 */
20
20
21 /*!
21 /*!
22 \class QChartView
22 \class QChartView
23 \brief Standalone charting widget.
23 \brief Standalone charting widget.
24
24
25 QChartView is a standalone widget that can display charts. It does not require separate
25 QChartView is a standalone widget that can display charts. It does not require separate
26 QGraphicsScene to work. It manages the graphical representation of different types of
26 QGraphicsScene to work. It manages the graphical representation of different types of
27 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
27 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
28 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
28 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
29
29
30 \sa QChart
30 \sa QChart
31 */
31 */
32
32
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
34
35 /*!
35 /*!
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);
48 setScene(m_scene);
48 setScene(m_scene);
49 m_chart->setMargin(50);
49 m_chart->setMargin(50);
50 m_scene->addItem(m_chart);
50 m_scene->addItem(m_chart);
51 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
51 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
52 }
52 }
53
53
54
54
55 /*!
55 /*!
56 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
56 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
57 */
57 */
58 QChartView::~QChartView()
58 QChartView::~QChartView()
59 {
59 {
60 }
60 }
61
61
62 /*!
62 /*!
63 Resizes and updates the chart area using the \a event data
63 Resizes and updates the chart area using the \a event data
64 */
64 */
65 void QChartView::resizeEvent(QResizeEvent *event)
65 void QChartView::resizeEvent(QResizeEvent *event)
66 {
66 {
67 m_scene->setSceneRect(0,0,size().width(),size().height());
67 m_scene->setSceneRect(0,0,size().width(),size().height());
68 m_chart->resize(size());
68 m_chart->resize(size());
69 QWidget::resizeEvent(event);
69 QWidget::resizeEvent(event);
70 }
70 }
71
71
72 /*!
72 /*!
73 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
73 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
74 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
74 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
75 the y axis).
75 the y axis).
76 \sa removeSeries(), removeAllSeries()
76 \sa removeSeries(), removeAllSeries()
77 */
77 */
78 void QChartView::addSeries(QSeries* series,QChartAxis *axisY)
78 void QChartView::addSeries(QSeries* series,QChartAxis *axisY)
79 {
79 {
80 m_chart->addSeries(series,axisY);
80 m_chart->addSeries(series,axisY);
81 }
81 }
82
82
83 /*!
83 /*!
84 Removes the \a series specified in a perameter from the QChartView.
84 Removes the \a series specified in a perameter from the QChartView.
85 It releses its ownership of the specified QChartSeries object.
85 It releses its ownership of the specified QChartSeries object.
86 It does not delete the pointed QChartSeries data object
86 It does not delete the pointed QChartSeries data object
87 \sa addSeries(), removeAllSeries()
87 \sa addSeries(), removeAllSeries()
88 */
88 */
89 void QChartView::removeSeries(QSeries* series)
89 void QChartView::removeSeries(QSeries* series)
90 {
90 {
91 m_chart->removeSeries(series);
91 m_chart->removeSeries(series);
92 }
92 }
93
93
94 /*!
94 /*!
95 Removes all the QChartSeries that have been added to the QChartView
95 Removes all the QChartSeries that have been added to the QChartView
96 It also deletes the pointed QChartSeries data objects
96 It also deletes the pointed QChartSeries data objects
97 \sa addSeries(), removeSeries()
97 \sa addSeries(), removeSeries()
98 */
98 */
99 void QChartView::removeAllSeries()
99 void QChartView::removeAllSeries()
100 {
100 {
101 m_chart->removeAllSeries();
101 m_chart->removeAllSeries();
102 }
102 }
103
103
104 /*!
104 /*!
105 Zooms in the view by a factor of 2
105 Zooms in the view by a factor of 2
106 */
106 */
107 void QChartView::zoomIn()
107 void QChartView::zoomIn()
108 {
108 {
109 m_chart->zoomIn();
109 m_chart->zoomIn();
110 }
110 }
111
111
112 /*!
112 /*!
113 Zooms in the view to a maximum level at which \a rect is still fully visible.
113 Zooms in the view to a maximum level at which \a rect is still fully visible.
114 */
114 */
115 void QChartView::zoomIn(const QRect& rect)
115 void QChartView::zoomIn(const QRect& rect)
116 {
116 {
117 m_chart->zoomIn(rect);
117 m_chart->zoomIn(rect);
118 }
118 }
119
119
120 /*!
120 /*!
121 Restores the view zoom level to the previous one.
121 Restores the view zoom level to the previous one.
122 */
122 */
123 void QChartView::zoomOut()
123 void QChartView::zoomOut()
124 {
124 {
125 m_chart->zoomOut();
125 m_chart->zoomOut();
126 }
126 }
127
127
128 /*!
128 /*!
129 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
129 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
130 */
130 */
131 int QChartView::margin() const
131 int QChartView::margin() const
132 {
132 {
133 return m_chart->margin();
133 return m_chart->margin();
134 }
134 }
135
135
136 /*!
136 /*!
137 Sets the chart \a title. A description text that is drawn above the chart.
137 Sets the chart \a title. A description text that is drawn above the chart.
138 */
138 */
139 void QChartView::setChartTitle(const QString& title)
139 void QChartView::setChartTitle(const QString& title)
140 {
140 {
141 m_chart->setChartTitle(title);
141 m_chart->setChartTitle(title);
142 }
142 }
143
143
144 /*!
144 /*!
145 Returns the chart's title. A description text that is drawn above the chart.
145 Returns the chart's title. A description text that is drawn above the chart.
146 */
146 */
147 QString QChartView::chartTitle() const
147 QString QChartView::chartTitle() const
148 {
148 {
149 return m_chart->chartTitle();
149 return m_chart->chartTitle();
150 }
150 }
151
151
152 /*!
152 /*!
153 Sets the \a font that is used for rendering the description text that is rendered above the chart.
153 Sets the \a font that is used for rendering the description text that is rendered above the chart.
154 */
154 */
155 void QChartView::setChartTitleFont(const QFont& font)
155 void QChartView::setChartTitleFont(const QFont& font)
156 {
156 {
157 m_chart->setChartTitleFont(font);
157 m_chart->setChartTitleFont(font);
158 }
158 }
159
159
160 /*!
160 /*!
161 Sets the \a brush used for rendering the title text.
161 Sets the \a brush used for rendering the title text.
162 */
162 */
163 void QChartView::setChartTitleBrush(const QBrush &brush)
163 void QChartView::setChartTitleBrush(const QBrush &brush)
164 {
164 {
165 m_chart->setChartTitleBrush(brush);
165 m_chart->setChartTitleBrush(brush);
166 }
166 }
167
167
168 /*!
168 /*!
169 Returns the brush used for rendering the title text.
169 Returns the brush used for rendering the title text.
170 */
170 */
171 QBrush QChartView::chartTitleBrush()
171 QBrush QChartView::chartTitleBrush()
172 {
172 {
173 return m_chart->chartTitleBrush();
173 return m_chart->chartTitleBrush();
174 }
174 }
175
175
176 /*!
176 /*!
177 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
177 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
178 */
178 */
179 void QChartView::setChartBackgroundBrush(const QBrush& brush)
179 void QChartView::setChartBackgroundBrush(const QBrush& brush)
180 {
180 {
181 m_chart->setChartBackgroundBrush(brush);
181 m_chart->setChartBackgroundBrush(brush);
182 }
182 }
183
183
184 /*!
184 /*!
185 Sets the \a pen that is used for painting the background of the chart area of the QChartView widget.
185 Sets the \a pen that is used for painting the background of the chart area of the QChartView widget.
186 */
186 */
187 void QChartView::setChartBackgroundPen(const QPen& pen)
187 void QChartView::setChartBackgroundPen(const QPen& pen)
188 {
188 {
189 m_chart->setChartBackgroundPen(pen);
189 m_chart->setChartBackgroundPen(pen);
190 }
190 }
191
191
192 /*!
192 /*!
193 Sets the RubberBandPlicy to \a policy. Selected policy determines the way zooming is performed.
193 Sets the RubberBandPlicy to \a policy. Selected policy determines the way zooming is performed.
194 */
194 */
195 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
195 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
196 {
196 {
197 switch(policy) {
197 switch(policy) {
198 case VerticalRubberBand:
198 case VerticalRubberBand:
199 m_verticalRubberBand = true;
199 m_verticalRubberBand = true;
200 m_horizonalRubberBand = false;
200 m_horizonalRubberBand = false;
201 break;
201 break;
202 case HorizonalRubberBand:
202 case HorizonalRubberBand:
203 m_verticalRubberBand = false;
203 m_verticalRubberBand = false;
204 m_horizonalRubberBand = true;
204 m_horizonalRubberBand = true;
205 break;
205 break;
206 case RectangleRubberBand:
206 case RectangleRubberBand:
207 m_verticalRubberBand = true;
207 m_verticalRubberBand = true;
208 m_horizonalRubberBand = true;
208 m_horizonalRubberBand = true;
209 break;
209 break;
210 case NoRubberBand:
210 case NoRubberBand:
211 default:
211 default:
212 delete m_rubberBand;
212 delete m_rubberBand;
213 m_rubberBand=0;
213 m_rubberBand=0;
214 m_horizonalRubberBand = false;
214 m_horizonalRubberBand = false;
215 m_verticalRubberBand = false;
215 m_verticalRubberBand = false;
216 return;
216 return;
217 }
217 }
218 if(!m_rubberBand) {
218 if(!m_rubberBand) {
219 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
219 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
220 m_rubberBand->setEnabled(true);
220 m_rubberBand->setEnabled(true);
221 }
221 }
222 }
222 }
223
223
224 /*!
224 /*!
225 Returns the RubberBandPolicy that is currently being used by the widget.
225 Returns the RubberBandPolicy that is currently being used by the widget.
226 */
226 */
227 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
227 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
228 {
228 {
229 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
229 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
230 if(m_horizonalRubberBand) return HorizonalRubberBand;
230 if(m_horizonalRubberBand) return HorizonalRubberBand;
231 if(m_verticalRubberBand) return VerticalRubberBand;
231 if(m_verticalRubberBand) return VerticalRubberBand;
232 return NoRubberBand;
232 return NoRubberBand;
233 }
233 }
234
234
235 /*!
235 /*!
236 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
236 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
237 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
237 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
238 */
238 */
239 void QChartView::mousePressEvent(QMouseEvent *event)
239 void QChartView::mousePressEvent(QMouseEvent *event)
240 {
240 {
241 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
241 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
242
242
243 int margin = m_chart->margin();
243 int margin = m_chart->margin();
244 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
244 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
245
245
246 if (rect.contains(event->pos())) {
246 if (rect.contains(event->pos())) {
247 m_rubberBandOrigin = event->pos();
247 m_rubberBandOrigin = event->pos();
248 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
248 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
249 m_rubberBand->show();
249 m_rubberBand->show();
250 event->accept();
250 event->accept();
251 }
251 }
252 }
252 }
253 else {
253 else {
254 QGraphicsView::mousePressEvent(event);
254 QGraphicsView::mousePressEvent(event);
255 }
255 }
256 }
256 }
257
257
258 /*!
258 /*!
259 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
259 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
260 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
260 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
261 */
261 */
262 void QChartView::mouseMoveEvent(QMouseEvent *event)
262 void QChartView::mouseMoveEvent(QMouseEvent *event)
263 {
263 {
264 if(m_rubberBand && m_rubberBand->isVisible()) {
264 if(m_rubberBand && m_rubberBand->isVisible()) {
265 int margin = m_chart->margin();
265 int margin = m_chart->margin();
266 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
266 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
267 int width = event->pos().x() - m_rubberBandOrigin.x();
267 int width = event->pos().x() - m_rubberBandOrigin.x();
268 int height = event->pos().y() - m_rubberBandOrigin.y();
268 int height = event->pos().y() - m_rubberBandOrigin.y();
269 if(!m_verticalRubberBand) {
269 if(!m_verticalRubberBand) {
270 m_rubberBandOrigin.setY(rect.top());
270 m_rubberBandOrigin.setY(rect.top());
271 height = rect.height();
271 height = rect.height();
272 }
272 }
273 if(!m_horizonalRubberBand) {
273 if(!m_horizonalRubberBand) {
274 m_rubberBandOrigin.setX(rect.left());
274 m_rubberBandOrigin.setX(rect.left());
275 width= rect.width();
275 width= rect.width();
276 }
276 }
277 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
277 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
278 }
278 }
279 else {
279 else {
280 QGraphicsView::mouseMoveEvent(event);
280 QGraphicsView::mouseMoveEvent(event);
281 }
281 }
282 }
282 }
283
283
284 /*!
284 /*!
285 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
285 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
286 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
286 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
287 */
287 */
288 void QChartView::mouseReleaseEvent(QMouseEvent *event)
288 void QChartView::mouseReleaseEvent(QMouseEvent *event)
289 {
289 {
290 if(m_rubberBand) {
290 if(m_rubberBand) {
291 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
291 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
292 m_rubberBand->hide();
292 m_rubberBand->hide();
293 QRect rect = m_rubberBand->geometry();
293 QRect rect = m_rubberBand->geometry();
294 m_chart->zoomIn(rect);
294 m_chart->zoomIn(rect);
295 event->accept();
295 event->accept();
296 }
296 }
297
297
298 if(event->button()==Qt::RightButton)
298 if(event->button()==Qt::RightButton)
299 m_chart->zoomReset();
299 m_chart->zoomReset();
300 }
300 }
301 else {
301 else {
302 QGraphicsView::mouseReleaseEvent(event);
302 QGraphicsView::mouseReleaseEvent(event);
303 }
303 }
304 }
304 }
305
305
306 /*!
306 /*!
307 Pressing + and - keys performs zoomIn() and zoomOut() respectivly.
307 Pressing + and - keys performs zoomIn() and zoomOut() respectivly.
308 In other \a event is passed to the QGraphicsView::keyPressEvent() implementation
308 In other \a event is passed to the QGraphicsView::keyPressEvent() implementation
309 */
309 */
310 void QChartView::keyPressEvent(QKeyEvent *event)
310 void QChartView::keyPressEvent(QKeyEvent *event)
311 {
311 {
312 switch (event->key()) {
312 switch (event->key()) {
313 case Qt::Key_Plus:
313 case Qt::Key_Plus:
314 zoomIn();
314 zoomIn();
315 break;
315 break;
316 case Qt::Key_Minus:
316 case Qt::Key_Minus:
317 zoomOut();
317 zoomOut();
318 break;
318 break;
319 default:
319 default:
320 QGraphicsView::keyPressEvent(event);
320 QGraphicsView::keyPressEvent(event);
321 break;
321 break;
322 }
322 }
323 }
323 }
324
324
325 /*!
325 /*!
326 Sets the \a theme used by the chart for rendering the graphical representation of the data
326 Sets the \a theme used by the chart for rendering the graphical representation of the data
327 \sa QChart::ChartTheme, chartTheme()
327 \sa QChart::ChartTheme, chartTheme()
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 }
340 m_chart->setChartTheme(theme);
331 m_chart->setChartTheme(theme);
341 }
332 }
342
333
343 /*!
334 /*!
344 Returns the theme enum used by the chart.
335 Returns the theme enum used by the chart.
345 \sa setChartTheme()
336 \sa setChartTheme()
346 */
337 */
347 QChart::ChartTheme QChartView::chartTheme() const
338 QChart::ChartTheme QChartView::chartTheme() const
348 {
339 {
349 return m_chart->chartTheme();
340 return m_chart->chartTheme();
350 }
341 }
351
342
352 /*!
343 /*!
353 Returns the pointer to the x axis object of the chart
344 Returns the pointer to the x axis object of the chart
354 */
345 */
355 QChartAxis* QChartView::axisX() const
346 QChartAxis* QChartView::axisX() const
356 {
347 {
357 return m_chart->axisX();
348 return m_chart->axisX();
358 }
349 }
359
350
360 /*!
351 /*!
361 Returns the pointer to the y axis object of the chart
352 Returns the pointer to the y axis object of the chart
362 */
353 */
363 QChartAxis* QChartView::axisY() const
354 QChartAxis* QChartView::axisY() const
364 {
355 {
365 return m_chart->axisY();
356 return m_chart->axisY();
366 }
357 }
367
358
368 /*!
359 /*!
369 Returns the pointer to legend object of the chart
360 Returns the pointer to legend object of the chart
370 */
361 */
371 QLegend* QChartView::legend() const
362 QLegend* QChartView::legend() const
372 {
363 {
373 return m_chart->legend();
364 return m_chart->legend();
374 }
365 }
375
366
376 /*!
367 /*!
377 Sets animation \a options for the chart
368 Sets animation \a options for the chart
378 */
369 */
379 void QChartView::setAnimationOptions(QChart::AnimationOptions options)
370 void QChartView::setAnimationOptions(QChart::AnimationOptions options)
380 {
371 {
381 m_chart->setAnimationOptions(options);
372 m_chart->setAnimationOptions(options);
382 }
373 }
383
374
384 /*!
375 /*!
385 Returns animation options for the chart
376 Returns animation options for the chart
386 */
377 */
387 QChart::AnimationOptions QChartView::animationOptions() const
378 QChart::AnimationOptions QChartView::animationOptions() const
388 {
379 {
389 return m_chart->animationOptions();
380 return m_chart->animationOptions();
390 }
381 }
391
382
392 void QChartView::scroll(int dx,int dy)
383 void QChartView::scroll(int dx,int dy)
393 {
384 {
394 m_chart->scroll(dx,dy);
385 m_chart->scroll(dx,dy);
395 }
386 }
396
387
397 #include "moc_qchartview.cpp"
388 #include "moc_qchartview.cpp"
398
389
399 QTCOMMERCIALCHART_END_NAMESPACE
390 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,32 +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(0x5dbe9b);
12 m_seriesColors << QRgb(0x5dbe9b);
13 m_seriesColors << QRgb(0x4fbef3);
13 m_seriesColors << QRgb(0x4fbef3);
14 generateSeriesGradients();
14 generateSeriesGradients();
15
15
16 // No chart background, chart view specifies a background
16 // Background
17 // TODO: what if the chart is drawn on custom graphics scene instead of QChartView?
17 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0x056188));
19 backgroundGradient.setColorAt(1.0, QRgb(0x101a33));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_chartBackgroundGradient = backgroundGradient;
18
22
19 // Axes and other
23 // Axes and other
20 m_masterFont = QFont();
24 m_masterFont = QFont();
21 m_axisLinePen = QPen(QRgb(0xf7f7ff));
25 m_axisLinePen = QPen(QRgb(0xf7f7ff));
22 m_axisLinePen.setWidth(2);
26 m_axisLinePen.setWidth(2);
23 m_axisLabelBrush = QBrush(QRgb(0xf7f7ff));
27 m_axisLabelBrush = QBrush(QRgb(0xf7f7ff));
24 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
28 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
25 m_backgroundShadesPen = Qt::NoPen;
29 m_backgroundShadesPen = Qt::NoPen;
26 m_backgroundShades = BackgroundShadesNone;
30 m_backgroundShades = BackgroundShadesNone;
27 m_gridLinePen = QPen(QRgb(0xf7f7ff));
31 m_gridLinePen = QPen(QRgb(0xf7f7ff));
28 m_gridLinePen.setWidth(1);
32 m_gridLinePen.setWidth(1);
29 }
33 }
30 };
34 };
31
35
32 QTCOMMERCIALCHART_END_NAMESPACE
36 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now