##// END OF EJS Templates
Adds opacity to shades
Michal Klocek -
r188:81d9e3777fdd
parent child
Show More
@@ -1,56 +1,62
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlinechartseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <qchartaxis.h>
6 #include <qchartaxis.h>
7 #include <cmath>
7 #include <cmath>
8
8
9 QTCOMMERCIALCHART_USE_NAMESPACE
9 QTCOMMERCIALCHART_USE_NAMESPACE
10
10
11 #define PI 3.14159265358979
11 #define PI 3.14159265358979
12
12
13 int main(int argc, char *argv[])
13 int main(int argc, char *argv[])
14 {
14 {
15 QApplication a(argc, argv);
15 QApplication a(argc, argv);
16
16
17 QMainWindow window;
17 QMainWindow window;
18
18
19 QLineChartSeries* series0 = new QLineChartSeries();
19 QLineChartSeries* series0 = new QLineChartSeries();
20 QPen blue(Qt::blue);
20 QPen blue(Qt::blue);
21 blue.setWidth(3);
21 blue.setWidth(3);
22 series0->setPen(blue);
22 series0->setPen(blue);
23 QLineChartSeries* series1 = new QLineChartSeries();
23 QLineChartSeries* series1 = new QLineChartSeries();
24 QPen red(Qt::red);
24 QPen red(Qt::red);
25 red.setWidth(3);
25 red.setWidth(3);
26 series1->setPen(red);
26 series1->setPen(red);
27
27
28 int numPoints = 100;
28 int numPoints = 100;
29
29
30 for (int x = 0; x <= numPoints; ++x) {
30 for (int x = 0; x <= numPoints; ++x) {
31 series0->add(x, fabs(sin(PI/50*x)*100));
31 series0->add(x, fabs(sin(PI/50*x)*100));
32 series1->add(x, fabs(cos(PI/50*x)*100));
32 series1->add(x, fabs(cos(PI/50*x)*100));
33 }
33 }
34
34
35 QChartView* chartView = new QChartView(&window);
35 QChartView* chartView = new QChartView(&window);
36
36
37 chartView->setRenderHint(QPainter::Antialiasing);
37 chartView->setRenderHint(QPainter::Antialiasing);
38 chartView->setTitle("Basic line chart example");
38 chartView->setTitle("Basic line chart example");
39 chartView->addSeries(series0);
39 chartView->addSeries(series0);
40 chartView->addSeries(series1);
40 chartView->addSeries(series1);
41 chartView->setChartBackgroundBrush(Qt::white);
41
42
43 QLinearGradient backgroundGradient;
44 backgroundGradient.setColorAt(0.0, Qt::white);
45 backgroundGradient.setColorAt(1.0, QRgb(0xffff80));
46 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
47 chartView->setChartBackgroundBrush(backgroundGradient);
42
48
43 QChartAxis axis = chartView->defaultAxisX();
49 QChartAxis axis = chartView->defaultAxisX();
44 axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide);
50 axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide);
45 axis.setGridPen(Qt::DashLine);
51 axis.setGridPen(Qt::DashLine);
46
52
47 chartView->setDefaultAxisX(axis);
53 chartView->setDefaultAxisX(axis);
48 axis.setShadesBrush(Qt::lightGray);
54 axis.setShadesBrush(Qt::yellow);
49 chartView->setDefaultAxisY(axis);
55 chartView->setDefaultAxisY(axis);
50
56
51 window.setCentralWidget(chartView);
57 window.setCentralWidget(chartView);
52 window.resize(400, 300);
58 window.resize(400, 300);
53 window.show();
59 window.show();
54
60
55 return a.exec();
61 return a.exec();
56 }
62 }
@@ -1,318 +1,320
1 #include "axisitem_p.h"
1 #include "axisitem_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include <QPainter>
3 #include <QPainter>
4 #include <QDebug>
4 #include <QDebug>
5
5
6 static int label_padding = 5;
6 static int label_padding = 5;
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
11 ChartItem(parent),
11 ChartItem(parent),
12 m_ticks(4),
12 m_ticks(4),
13 m_type(type),
13 m_type(type),
14 m_labelsAngle(0),
14 m_labelsAngle(0),
15 m_shadesEnabled(true),
15 m_shadesEnabled(true),
16 m_grid(parent),
16 m_grid(parent),
17 m_shades(parent),
17 m_shades(parent),
18 m_labels(parent)
18 m_labels(parent)
19 {
19 {
20 //initial initialization
20 //initial initialization
21 m_shades.setZValue(0);
21 m_shades.setZValue(0);
22 m_grid.setZValue(2);
22 m_grid.setZValue(2);
23 createItems();
23 createItems();
24 }
24 }
25
25
26 AxisItem::~AxisItem()
26 AxisItem::~AxisItem()
27 {
27 {
28 }
28 }
29
29
30 QRectF AxisItem::boundingRect() const
30 QRectF AxisItem::boundingRect() const
31 {
31 {
32 return m_rect;
32 return m_rect;
33 }
33 }
34
34
35 void AxisItem::createItems()
35 void AxisItem::createItems()
36 {
36 {
37 for (int i = 0; i <= m_ticks; ++i) {
37 for (int i = 0; i <= m_ticks; ++i) {
38 m_grid.addToGroup(new QGraphicsLineItem(this));
38 m_grid.addToGroup(new QGraphicsLineItem(this));
39 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
39 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
40 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
40 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
41 }
41 }
42 }
42 }
43
43
44 void AxisItem::clear()
44 void AxisItem::clear()
45 {
45 {
46 foreach(QGraphicsItem* item , m_shades.childItems()) {
46 foreach(QGraphicsItem* item , m_shades.childItems()) {
47 delete item;
47 delete item;
48 }
48 }
49
49
50 foreach(QGraphicsItem* item , m_grid.childItems()) {
50 foreach(QGraphicsItem* item , m_grid.childItems()) {
51 delete item;
51 delete item;
52 }
52 }
53
53
54 foreach(QGraphicsItem* item , m_labels.childItems()) {
54 foreach(QGraphicsItem* item , m_labels.childItems()) {
55 delete item;
55 delete item;
56 }
56 }
57
57
58 }
58 }
59
59
60 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
60 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
61 {
61 {
62
62
63 }
63 }
64
64
65 void AxisItem::updateDomain()
65 void AxisItem::updateDomain()
66 {
66 {
67
67
68 QList<QGraphicsItem *> lines = m_grid.childItems();
68 QList<QGraphicsItem *> lines = m_grid.childItems();
69 QList<QGraphicsItem *> labels = m_labels.childItems();
69 QList<QGraphicsItem *> labels = m_labels.childItems();
70 QList<QGraphicsItem *> shades = m_shades.childItems();
70 QList<QGraphicsItem *> shades = m_shades.childItems();
71
71
72 switch (m_type)
72 switch (m_type)
73 {
73 {
74 case X_AXIS:
74 case X_AXIS:
75 {
75 {
76 const qreal deltaX = m_rect.width() / m_ticks;
76 const qreal deltaX = m_rect.width() / m_ticks;
77
77
78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
79
79
80 for (int i = 0; i <= m_ticks; ++i) {
80 for (int i = 0; i <= m_ticks; ++i) {
81
81
82 int x = i * deltaX + m_rect.left();
82 int x = i * deltaX + m_rect.left();
83
83
84 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
84 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
85
85
86 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
86 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
87 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
87 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
88
88
89 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
89 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
90 labelItem->setText(QString::number(label));
90 labelItem->setText(QString::number(label));
91 QPointF center = labelItem->boundingRect().center();
91 QPointF center = labelItem->boundingRect().center();
92 labelItem->setTransformOriginPoint(center.x(), center.y());
92 labelItem->setTransformOriginPoint(center.x(), center.y());
93 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
93 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
94
94
95 if(i%2){
95 if(i%2){
96 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
96 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
97 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
97 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
98 rectItem->setOpacity( 0.5 );
98 }
99 }
99 }
100 }
100 }
101 }
101 break;
102 break;
102
103
103 case Y_AXIS:
104 case Y_AXIS:
104 {
105 {
105 const qreal deltaY = m_rect.height()/ m_ticks;
106 const qreal deltaY = m_rect.height()/ m_ticks;
106
107
107 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
108 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
108
109
109 for (int i = 0; i <= m_ticks; ++i) {
110 for (int i = 0; i <= m_ticks; ++i) {
110
111
111 int y = i * -deltaY + m_rect.bottom();
112 int y = i * -deltaY + m_rect.bottom();
112
113
113 qreal label = m_domain.m_minY + (i * m_domain.spanY()/ m_ticks);
114 qreal label = m_domain.m_minY + (i * m_domain.spanY()/ m_ticks);
114
115
115 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
116 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
116 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
117 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
117
118
118 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
119 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
119 labelItem->setText(QString::number(label));
120 labelItem->setText(QString::number(label));
120 QPointF center = labelItem->boundingRect().center();
121 QPointF center = labelItem->boundingRect().center();
121 labelItem->setTransformOriginPoint(center.x(), center.y());
122 labelItem->setTransformOriginPoint(center.x(), center.y());
122 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
123 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
123
124
124
125
125 if(i%2){
126 if(i%2){
126 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
127 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
127 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
128 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
129
128 }
130 }
129 }
131 }
130 }
132 }
131 break;
133 break;
132 default:
134 default:
133 qDebug()<<"Unknown axis type";
135 qDebug()<<"Unknown axis type";
134 break;
136 break;
135 }
137 }
136 }
138 }
137
139
138 void AxisItem::handleAxisChanged(const QChartAxis& axis)
140 void AxisItem::handleAxisChanged(const QChartAxis& axis)
139 {
141 {
140 if(axis.isAxisVisible()) {
142 if(axis.isAxisVisible()) {
141 setAxisOpacity(100);
143 setAxisOpacity(100);
142 }
144 }
143 else {
145 else {
144 setAxisOpacity(0);
146 setAxisOpacity(0);
145 }
147 }
146
148
147 if(axis.isGridVisible()) {
149 if(axis.isGridVisible()) {
148 setGridOpacity(100);
150 setGridOpacity(100);
149 }
151 }
150 else {
152 else {
151 setGridOpacity(0);
153 setGridOpacity(0);
152 }
154 }
153
155
154 if(axis.isLabelsVisible())
156 if(axis.isLabelsVisible())
155 {
157 {
156 setLabelsOpacity(100);
158 setLabelsOpacity(100);
157 }
159 }
158 else {
160 else {
159 setLabelsOpacity(0);
161 setLabelsOpacity(0);
160 }
162 }
161
163
162 if(axis.isShadesVisible()) {
164 if(axis.isShadesVisible()) {
163 setShadesOpacity(100);
165 setShadesOpacity(axis.shadesOpacity());
164 }
166 }
165 else {
167 else {
166 setShadesOpacity(0);
168 setShadesOpacity(0);
167 }
169 }
168
170
169 switch(axis.labelsOrientation())
171 switch(axis.labelsOrientation())
170 {
172 {
171 case QChartAxis::LabelsOrientationHorizontal:
173 case QChartAxis::LabelsOrientationHorizontal:
172 setLabelsAngle(0);
174 setLabelsAngle(0);
173 break;
175 break;
174 case QChartAxis::LabelsOrientationVertical:
176 case QChartAxis::LabelsOrientationVertical:
175 setLabelsAngle(90);
177 setLabelsAngle(90);
176 break;
178 break;
177 case QChartAxis::LabelsOrientationSlide:
179 case QChartAxis::LabelsOrientationSlide:
178 setLabelsAngle(-45);
180 setLabelsAngle(-45);
179 break;
181 break;
180 default:
182 default:
181 break;
183 break;
182 }
184 }
183
185
184 setAxisPen(axis.axisPen());
186 setAxisPen(axis.axisPen());
185 setLabelsPen(axis.labelsPen());
187 setLabelsPen(axis.labelsPen());
186 setLabelsBrush(axis.labelsBrush());
188 setLabelsBrush(axis.labelsBrush());
187 setLabelsFont(axis.labelFont());
189 setLabelsFont(axis.labelFont());
188 setGridPen(axis.gridPen());
190 setGridPen(axis.gridPen());
189 setShadesPen(axis.shadesPen());
191 setShadesPen(axis.shadesPen());
190 setShadesBrush(axis.shadesBrush());
192 setShadesBrush(axis.shadesBrush());
191
193
192 }
194 }
193
195
194 void AxisItem::handleDomainChanged(const Domain& domain)
196 void AxisItem::handleDomainChanged(const Domain& domain)
195 {
197 {
196 m_domain = domain;
198 m_domain = domain;
197 updateDomain();
199 updateDomain();
198 update();
200 update();
199 }
201 }
200
202
201 void AxisItem::handleGeometryChanged(const QRectF& rect)
203 void AxisItem::handleGeometryChanged(const QRectF& rect)
202 {
204 {
203 m_rect = rect;
205 m_rect = rect;
204 updateDomain();
206 updateDomain();
205 update();
207 update();
206 }
208 }
207
209
208 void AxisItem::setAxisOpacity(qreal opacity)
210 void AxisItem::setAxisOpacity(qreal opacity)
209 {
211 {
210 m_axis.setOpacity(opacity);
212 m_axis.setOpacity(opacity);
211 }
213 }
212
214
213 qreal AxisItem::axisOpacity() const
215 qreal AxisItem::axisOpacity() const
214 {
216 {
215 return m_axis.opacity();
217 return m_axis.opacity();
216 }
218 }
217
219
218 void AxisItem::setGridOpacity(qreal opacity)
220 void AxisItem::setGridOpacity(qreal opacity)
219 {
221 {
220 m_grid.setOpacity(opacity);
222 m_grid.setOpacity(opacity);
221 }
223 }
222
224
223
225
224 qreal AxisItem::gridOpacity() const
226 qreal AxisItem::gridOpacity() const
225 {
227 {
226 return m_grid.opacity();
228 return m_grid.opacity();
227 }
229 }
228
230
229 void AxisItem::setLabelsOpacity(qreal opacity)
231 void AxisItem::setLabelsOpacity(qreal opacity)
230 {
232 {
231 m_labels.setOpacity(opacity);
233 m_labels.setOpacity(opacity);
232 }
234 }
233
235
234 qreal AxisItem::labelsOpacity() const
236 qreal AxisItem::labelsOpacity() const
235 {
237 {
236 return m_labels.opacity();
238 return m_labels.opacity();
237 }
239 }
238
240
239 void AxisItem::setShadesOpacity(qreal opacity)
241 void AxisItem::setShadesOpacity(qreal opacity)
240 {
242 {
241 m_shades.setOpacity(opacity);
243 m_shades.setOpacity(opacity);
242 }
244 }
243
245
244 qreal AxisItem::shadesOpacity() const
246 qreal AxisItem::shadesOpacity() const
245 {
247 {
246 return m_shades.opacity();
248 return m_shades.opacity();
247 }
249 }
248
250
249 void AxisItem::setLabelsAngle(int angle)
251 void AxisItem::setLabelsAngle(int angle)
250 {
252 {
251 foreach(QGraphicsItem* item , m_labels.childItems()) {
253 foreach(QGraphicsItem* item , m_labels.childItems()) {
252 QPointF center = item->boundingRect().center();
254 QPointF center = item->boundingRect().center();
253 item->setRotation(angle);
255 item->setRotation(angle);
254 }
256 }
255
257
256 m_labelsAngle=angle;
258 m_labelsAngle=angle;
257 }
259 }
258
260
259 void AxisItem::setLabelsPen(const QPen& pen)
261 void AxisItem::setLabelsPen(const QPen& pen)
260 {
262 {
261 foreach(QGraphicsItem* item , m_labels.childItems()) {
263 foreach(QGraphicsItem* item , m_labels.childItems()) {
262 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
264 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
263 }
265 }
264 }
266 }
265
267
266 void AxisItem::setLabelsBrush(const QBrush& brush)
268 void AxisItem::setLabelsBrush(const QBrush& brush)
267 {
269 {
268 foreach(QGraphicsItem* item , m_labels.childItems()) {
270 foreach(QGraphicsItem* item , m_labels.childItems()) {
269 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
271 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
270 }
272 }
271 }
273 }
272
274
273 void AxisItem::setLabelsFont(const QFont& font)
275 void AxisItem::setLabelsFont(const QFont& font)
274 {
276 {
275 foreach(QGraphicsItem* item , m_labels.childItems()) {
277 foreach(QGraphicsItem* item , m_labels.childItems()) {
276 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
278 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
277 }
279 }
278 }
280 }
279
281
280 void AxisItem::setShadesBrush(const QBrush& brush)
282 void AxisItem::setShadesBrush(const QBrush& brush)
281 {
283 {
282 foreach(QGraphicsItem* item , m_shades.childItems()) {
284 foreach(QGraphicsItem* item , m_shades.childItems()) {
283 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
285 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
284 }
286 }
285 }
287 }
286
288
287 void AxisItem::setShadesPen(const QPen& pen)
289 void AxisItem::setShadesPen(const QPen& pen)
288 {
290 {
289 foreach(QGraphicsItem* item , m_shades.childItems()) {
291 foreach(QGraphicsItem* item , m_shades.childItems()) {
290 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
292 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
291 }
293 }
292 }
294 }
293
295
294 void AxisItem::setAxisPen(const QPen& pen)
296 void AxisItem::setAxisPen(const QPen& pen)
295 {
297 {
296 m_axis.setPen(pen);
298 m_axis.setPen(pen);
297 }
299 }
298
300
299 void AxisItem::setGridPen(const QPen& pen)
301 void AxisItem::setGridPen(const QPen& pen)
300 {
302 {
301 foreach(QGraphicsItem* item , m_grid.childItems()) {
303 foreach(QGraphicsItem* item , m_grid.childItems()) {
302 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
304 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
303 }
305 }
304 }
306 }
305
307
306 void AxisItem::setTicks(int count)
308 void AxisItem::setTicks(int count)
307 {
309 {
308 if(count!=m_ticks){
310 if(count!=m_ticks){
309 clear();
311 clear();
310 m_ticks=count;
312 m_ticks=count;
311 createItems();
313 createItems();
312 }
314 }
313 }
315 }
314
316
315 //TODO "nice numbers algorithm"
317 //TODO "nice numbers algorithm"
316 #include "moc_axisitem_p.cpp"
318 #include "moc_axisitem_p.cpp"
317
319
318 QTCOMMERCIALCHART_END_NAMESPACE
320 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,246 +1,247
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartaxis.h"
3 #include "qchartaxis.h"
4
4
5
5
6 //series
6 //series
7 #include "barchartseries.h"
7 #include "barchartseries.h"
8 #include "stackedbarchartseries.h"
8 #include "stackedbarchartseries.h"
9 #include "percentbarchartseries.h"
9 #include "percentbarchartseries.h"
10 #include "qlinechartseries.h"
10 #include "qlinechartseries.h"
11 #include "qscatterseries.h"
11 #include "qscatterseries.h"
12 #include "qpieseries.h"
12 #include "qpieseries.h"
13
13
14 //items
14 //items
15 #include "axisitem_p.h"
15 #include "axisitem_p.h"
16 #include "bargroup.h"
16 #include "bargroup.h"
17 #include "stackedbargroup.h"
17 #include "stackedbargroup.h"
18 #include "linechartitem_p.h"
18 #include "linechartitem_p.h"
19 #include "percentbargroup.h"
19 #include "percentbargroup.h"
20 #include "scatterpresenter.h"
20 #include "scatterpresenter.h"
21 #include "piepresenter.h"
21 #include "piepresenter.h"
22
22
23 //themes
23 //themes
24 #include "chartthemevanilla_p.h"
24 #include "chartthemevanilla_p.h"
25 #include "chartthemeicy_p.h"
25 #include "chartthemeicy_p.h"
26 #include "chartthemegrayscale_p.h"
26 #include "chartthemegrayscale_p.h"
27 #include "chartthemescientific_p.h"
27 #include "chartthemescientific_p.h"
28
28
29
29
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31
31
32 /* TODO
32 /* TODO
33 case QChart::ChartThemeUnnamed1:
33 case QChart::ChartThemeUnnamed1:
34 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
34 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
35 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
35 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
36 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
36 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
37 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
37 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
38 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
38 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
39
39
40 m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
40 m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
41 m_gradientEndColor = QColor(QRgb(0xffafafaf));
41 m_gradientEndColor = QColor(QRgb(0xffafafaf));
42 */
42 */
43
43
44 ChartTheme::ChartTheme(QChart::ChartTheme id)
44 ChartTheme::ChartTheme(QChart::ChartTheme id)
45 {
45 {
46 m_id = id;
46 m_id = id;
47 m_seriesColor.append(QRgb(0xff000000));
47 m_seriesColor.append(QRgb(0xff000000));
48 m_seriesColor.append(QRgb(0xff707070));
48 m_seriesColor.append(QRgb(0xff707070));
49 m_gradientStartColor = QColor(QRgb(0xffffffff));
49 m_gradientStartColor = QColor(QRgb(0xffffffff));
50 m_gradientEndColor = QColor(QRgb(0xffafafaf));
50 m_gradientEndColor = QColor(QRgb(0xffafafaf));
51 }
51 }
52
52
53
53
54 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
54 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
55 {
55 {
56 switch(theme) {
56 switch(theme) {
57 case QChart::ChartThemeDefault:
57 case QChart::ChartThemeDefault:
58 return new ChartTheme();
58 return new ChartTheme();
59 case QChart::ChartThemeVanilla:
59 case QChart::ChartThemeVanilla:
60 return new ChartThemeVanilla();
60 return new ChartThemeVanilla();
61 case QChart::ChartThemeIcy:
61 case QChart::ChartThemeIcy:
62 return new ChartThemeIcy();
62 return new ChartThemeIcy();
63 case QChart::ChartThemeGrayscale:
63 case QChart::ChartThemeGrayscale:
64 return new ChartThemeGrayscale();
64 return new ChartThemeGrayscale();
65 case QChart::ChartThemeScientific:
65 case QChart::ChartThemeScientific:
66 return new ChartThemeScientific();
66 return new ChartThemeScientific();
67 }
67 }
68 }
68 }
69
69
70 void ChartTheme::decorate(QChart* chart)
70 void ChartTheme::decorate(QChart* chart)
71 {
71 {
72 QLinearGradient backgroundGradient;
72 QLinearGradient backgroundGradient;
73 backgroundGradient.setColorAt(0.0, m_gradientStartColor);
73 backgroundGradient.setColorAt(0.0, m_gradientStartColor);
74 backgroundGradient.setColorAt(1.0, m_gradientEndColor);
74 backgroundGradient.setColorAt(1.0, m_gradientEndColor);
75 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
75 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
76 chart->setChartBackgroundBrush(backgroundGradient);
76 chart->setChartBackgroundBrush(backgroundGradient);
77 }
77 }
78 //TODO helper to by removed later
78 //TODO helper to by removed later
79 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
79 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
80 {
80 {
81 switch(series->type())
81 switch(series->type())
82 {
82 {
83 case QChartSeries::SeriesTypeLine: {
83 case QChartSeries::SeriesTypeLine: {
84 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
84 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
85 LineChartItem* i = static_cast<LineChartItem*>(item);
85 LineChartItem* i = static_cast<LineChartItem*>(item);
86 decorate(i,s,count);
86 decorate(i,s,count);
87 break;
87 break;
88 }
88 }
89 case QChartSeries::SeriesTypeBar: {
89 case QChartSeries::SeriesTypeBar: {
90 BarChartSeries* b = static_cast<BarChartSeries*>(series);
90 BarChartSeries* b = static_cast<BarChartSeries*>(series);
91 BarGroup* i = static_cast<BarGroup*>(item);
91 BarGroup* i = static_cast<BarGroup*>(item);
92 decorate(i,b,count);
92 decorate(i,b,count);
93 break;
93 break;
94 }
94 }
95 case QChartSeries::SeriesTypeStackedBar: {
95 case QChartSeries::SeriesTypeStackedBar: {
96 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
96 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
97 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
97 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
98 decorate(i,s,count);
98 decorate(i,s,count);
99 break;
99 break;
100 }
100 }
101 case QChartSeries::SeriesTypePercentBar: {
101 case QChartSeries::SeriesTypePercentBar: {
102 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
102 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
103 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
103 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
104 decorate(i,s,count);
104 decorate(i,s,count);
105 break;
105 break;
106 }
106 }
107 case QChartSeries::SeriesTypePie: {
107 case QChartSeries::SeriesTypePie: {
108 QPieSeries* s = static_cast<QPieSeries*>(series);
108 QPieSeries* s = static_cast<QPieSeries*>(series);
109 PiePresenter* i = static_cast<PiePresenter*>(item);
109 PiePresenter* i = static_cast<PiePresenter*>(item);
110 decorate(i,s,count);
110 decorate(i,s,count);
111 break;
111 break;
112 }
112 }
113 default:
113 default:
114 qDebug()<<"Wrong item to be decorated by theme";
114 qDebug()<<"Wrong item to be decorated by theme";
115 break;
115 break;
116 }
116 }
117
117
118 }
118 }
119
119
120 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
120 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
121 {
121 {
122 QPen pen;
122 QPen pen;
123 if(pen != series->pen()){
123 if(pen != series->pen()){
124 item->setPen(series->pen());
124 item->setPen(series->pen());
125 return;
125 return;
126 }
126 }
127 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
127 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
128 pen.setWidthF(2);
128 pen.setWidthF(2);
129 item->setPen(pen);
129 item->setPen(pen);
130 }
130 }
131
131
132 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
132 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
133 {
133 {
134 // TODO: better way to descide series color and remove hard coded colors.
134 // TODO: better way to descide series color and remove hard coded colors.
135 item->resetBrushes();
135 item->resetBrushes();
136 for (int i=0; i<m_seriesColor.count(); i++) {
136 for (int i=0; i<m_seriesColor.count(); i++) {
137 QBrush brush(m_seriesColor.at(i));
137 QBrush brush(m_seriesColor.at(i));
138 item->addBrush(brush);
138 item->addBrush(brush);
139 }
139 }
140 item->addBrush(QBrush(QColor(255,0,0,128)));
140 item->addBrush(QBrush(QColor(255,0,0,128)));
141 item->addBrush(QBrush(QColor(255,255,0,128)));
141 item->addBrush(QBrush(QColor(255,255,0,128)));
142 item->addBrush(QBrush(QColor(0,255,0,128)));
142 item->addBrush(QBrush(QColor(0,255,0,128)));
143 item->addBrush(QBrush(QColor(0,0,255,128)));
143 item->addBrush(QBrush(QColor(0,0,255,128)));
144 item->addBrush(QBrush(QColor(255,128,0,128)));
144 item->addBrush(QBrush(QColor(255,128,0,128)));
145 }
145 }
146
146
147 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
147 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
148 {
148 {
149 // TODO: better way to descide series color and remove hard coded colors.
149 // TODO: better way to descide series color and remove hard coded colors.
150 item->resetBrushes();
150 item->resetBrushes();
151 for (int i=0; i<m_seriesColor.count(); i++) {
151 for (int i=0; i<m_seriesColor.count(); i++) {
152 QBrush brush(m_seriesColor.at(i));
152 QBrush brush(m_seriesColor.at(i));
153 item->addBrush(brush);
153 item->addBrush(brush);
154 }
154 }
155 item->addBrush(QBrush(QColor(255,0,0,128)));
155 item->addBrush(QBrush(QColor(255,0,0,128)));
156 item->addBrush(QBrush(QColor(255,255,0,128)));
156 item->addBrush(QBrush(QColor(255,255,0,128)));
157 item->addBrush(QBrush(QColor(0,255,0,128)));
157 item->addBrush(QBrush(QColor(0,255,0,128)));
158 item->addBrush(QBrush(QColor(0,0,255,128)));
158 item->addBrush(QBrush(QColor(0,0,255,128)));
159 item->addBrush(QBrush(QColor(255,128,0,128)));
159 item->addBrush(QBrush(QColor(255,128,0,128)));
160 }
160 }
161
161
162 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
162 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
163 {
163 {
164 // TODO: better way to descide series color and remove hard coded colors.
164 // TODO: better way to descide series color and remove hard coded colors.
165 item->resetBrushes();
165 item->resetBrushes();
166 for (int i=0; i<m_seriesColor.count(); i++) {
166 for (int i=0; i<m_seriesColor.count(); i++) {
167 QBrush brush(m_seriesColor.at(i));
167 QBrush brush(m_seriesColor.at(i));
168 item->addBrush(brush);
168 item->addBrush(brush);
169 }
169 }
170 item->addBrush(QBrush(QColor(255,0,0,128)));
170 item->addBrush(QBrush(QColor(255,0,0,128)));
171 item->addBrush(QBrush(QColor(255,255,0,128)));
171 item->addBrush(QBrush(QColor(255,255,0,128)));
172 item->addBrush(QBrush(QColor(0,255,0,128)));
172 item->addBrush(QBrush(QColor(0,255,0,128)));
173 item->addBrush(QBrush(QColor(0,0,255,128)));
173 item->addBrush(QBrush(QColor(0,0,255,128)));
174 item->addBrush(QBrush(QColor(255,128,0,128)));
174 item->addBrush(QBrush(QColor(255,128,0,128)));
175 }
175 }
176
176
177 void ChartTheme::decorate(ScatterPresenter* presenter, QScatterSeries* series, int count)
177 void ChartTheme::decorate(ScatterPresenter* presenter, QScatterSeries* series, int count)
178 {
178 {
179 Q_ASSERT(presenter);
179 Q_ASSERT(presenter);
180 Q_ASSERT(series);
180 Q_ASSERT(series);
181
181
182 presenter->m_markerPen.setColor(m_seriesColor.at(count % m_seriesColor.size()));
182 presenter->m_markerPen.setColor(m_seriesColor.at(count % m_seriesColor.size()));
183
183
184 // QPen pen;
184 // QPen pen;
185 // if(pen != series->pen()){
185 // if(pen != series->pen()){
186 // item->setPen(series->pen());
186 // item->setPen(series->pen());
187 // return;
187 // return;
188 // }
188 // }
189 // pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
189 // pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
190 // pen.setWidthF(2);
190 // pen.setWidthF(2);
191 // item->setPen(pen);
191 // item->setPen(pen);
192 }
192 }
193
193
194 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
194 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
195 {
195 {
196 // create a list of slice colors based on current theme
196 // create a list of slice colors based on current theme
197 int i = 0;
197 int i = 0;
198 QList<QColor> colors;
198 QList<QColor> colors;
199 while (colors.count() < series->count()) {
199 while (colors.count() < series->count()) {
200
200
201 // get base color
201 // get base color
202 QColor c = m_seriesColor[i++];
202 QColor c = m_seriesColor[i++];
203 i = i % m_seriesColor.count();
203 i = i % m_seriesColor.count();
204
204
205 // -1 means achromatic color -> cannot manipulate lightness
205 // -1 means achromatic color -> cannot manipulate lightness
206 // TODO: find a better way to randomize lightness
206 // TODO: find a better way to randomize lightness
207 if (c.toHsv().hue() == -1)
207 if (c.toHsv().hue() == -1)
208 qWarning() << "ChartTheme::decorate() warning: achromatic theme color";
208 qWarning() << "ChartTheme::decorate() warning: achromatic theme color";
209
209
210 // randomize lightness
210 // randomize lightness
211 qreal f = 50 + (qrand() % 100); // 50 is 50% darker, 100 is the same, 150 is 50% lighter
211 qreal f = 50 + (qrand() % 100); // 50 is 50% darker, 100 is the same, 150 is 50% lighter
212 c = c.lighter(f);
212 c = c.lighter(f);
213
213
214 // find duplicates
214 // find duplicates
215 bool isUnique = true;
215 bool isUnique = true;
216 foreach (QColor color, colors) {
216 foreach (QColor color, colors) {
217 if (c == color)
217 if (c == color)
218 isUnique = false;
218 isUnique = false;
219 }
219 }
220
220
221 // add to array if unique
221 // add to array if unique
222 //if (isUnique)
222 //if (isUnique)
223 colors << c;
223 colors << c;
224 }
224 }
225
225
226 // finally update colors
226 // finally update colors
227 foreach (QPieSliceId id, series->ids()) {
227 foreach (QPieSliceId id, series->ids()) {
228 QPieSlice s = series->slice(id);
228 QPieSlice s = series->slice(id);
229 s.setPen(QPen(Qt::black)); // TODO: get from theme
229 s.setPen(QPen(Qt::black)); // TODO: get from theme
230 s.setBrush(colors.takeFirst());
230 s.setBrush(colors.takeFirst());
231 series->update(s);
231 series->update(s);
232 }
232 }
233 }
233 }
234
234
235
235
236 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
236 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
237 {
237 {
238 //TODO: dummy defults for now
238 //TODO: dummy defults for now
239
239
240 axis.setLabelsBrush(Qt::black);
240 axis.setLabelsBrush(Qt::black);
241 axis.setLabelsPen(Qt::NoPen);
241 axis.setLabelsPen(Qt::NoPen);
242 axis.setShadesPen(Qt::NoPen);
242 axis.setShadesPen(Qt::NoPen);
243 axis.setShadesOpacity(0.5);
243 item->handleAxisChanged(axis);
244 item->handleAxisChanged(axis);
244 }
245 }
245
246
246 QTCOMMERCIALCHART_END_NAMESPACE
247 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,81 +1,86
1 #include "qchartaxis.h"
1 #include "qchartaxis.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 QChartAxis::QChartAxis():
5 QChartAxis::QChartAxis():
6 m_axisVisible(true),
6 m_axisVisible(true),
7 m_gridVisible(true),
7 m_gridVisible(true),
8 m_labelsVisible(true),
8 m_labelsVisible(true),
9 m_shadesVisible(true)
9 m_shadesVisible(true),
10 m_shadesOpacity(1.0)
10 {
11 {
11 // TODO Auto-generated constructor stub
12 // TODO Auto-generated constructor stub
12
13
13 }
14 }
14
15
15 QChartAxis::~QChartAxis()
16 QChartAxis::~QChartAxis()
16 {
17 {
17 // TODO Auto-generated destructor stub
18 // TODO Auto-generated destructor stub
18 }
19 }
19
20
20 void QChartAxis::setAxisPen(const QPen& pen)
21 void QChartAxis::setAxisPen(const QPen& pen)
21 {
22 {
22 m_axisPen=pen;
23 m_axisPen=pen;
23 }
24 }
24
25
25 void QChartAxis::setAxisVisible(bool visible)
26 void QChartAxis::setAxisVisible(bool visible)
26 {
27 {
27 m_axisVisible=visible;
28 m_axisVisible=visible;
28 }
29 }
29
30
30 void QChartAxis::setGridVisible(bool visible)
31 void QChartAxis::setGridVisible(bool visible)
31 {
32 {
32 m_gridVisible=visible;
33 m_gridVisible=visible;
33 }
34 }
34
35
35 void QChartAxis::setGridPen(const QPen& pen)
36 void QChartAxis::setGridPen(const QPen& pen)
36 {
37 {
37 m_gridPen=pen;
38 m_gridPen=pen;
38 }
39 }
39
40
40 void QChartAxis::setLabelsVisible(bool visible)
41 void QChartAxis::setLabelsVisible(bool visible)
41 {
42 {
42 m_labelsVisible=visible;
43 m_labelsVisible=visible;
43 }
44 }
44
45
45 void QChartAxis::setLabelsPen(const QPen& pen)
46 void QChartAxis::setLabelsPen(const QPen& pen)
46 {
47 {
47 m_labelsPen=pen;
48 m_labelsPen=pen;
48 }
49 }
49
50
50 void QChartAxis::setLabelsBrush(const QBrush& brush)
51 void QChartAxis::setLabelsBrush(const QBrush& brush)
51 {
52 {
52 m_labelsBrush=brush;
53 m_labelsBrush=brush;
53 }
54 }
54
55
55 void QChartAxis::setLabelsFont(const QFont& font)
56 void QChartAxis::setLabelsFont(const QFont& font)
56 {
57 {
57 m_labelsFont=font;
58 m_labelsFont=font;
58 }
59 }
59
60
60 void QChartAxis::setLabelsOrientation(LabelsOrientation orientation)
61 void QChartAxis::setLabelsOrientation(LabelsOrientation orientation)
61 {
62 {
62 m_labelsOrientation=orientation;
63 m_labelsOrientation=orientation;
63 }
64 }
64
65
65 void QChartAxis::setShadesVisible(bool visible)
66 void QChartAxis::setShadesVisible(bool visible)
66 {
67 {
67 m_shadesVisible=visible;
68 m_shadesVisible=visible;
68 }
69 }
69
70
70 void QChartAxis::setShadesPen(const QPen& pen)
71 void QChartAxis::setShadesPen(const QPen& pen)
71 {
72 {
72 m_shadesPen=pen;
73 m_shadesPen=pen;
73 }
74 }
74
75
75 void QChartAxis::setShadesBrush(const QBrush& brush)
76 void QChartAxis::setShadesBrush(const QBrush& brush)
76 {
77 {
77 m_shadesBrush=brush;
78 m_shadesBrush=brush;
78 }
79 }
79
80
81 void QChartAxis::setShadesOpacity(qreal opacity)
82 {
83 m_shadesOpacity=opacity;
84 }
80
85
81 QTCOMMERCIALCHART_END_NAMESPACE
86 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,76 +1,82
1 #ifndef QCHARTAXIS_H_
1 #ifndef QCHARTAXIS_H_
2 #define QCHARTAXIS_H_
2 #define QCHARTAXIS_H_
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <QPen>
5 #include <QPen>
6 #include <QFont>
6 #include <QFont>
7
7
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QTCOMMERCIALCHART_EXPORT QChartAxis
11 class QTCOMMERCIALCHART_EXPORT QChartAxis
12 {
12 {
13 public:
13 public:
14 enum LabelsOrientation{ LabelsOrientationHorizontal, LabelsOrientationVertical , LabelsOrientationSlide };
14 enum LabelsOrientation{ LabelsOrientationHorizontal, LabelsOrientationVertical , LabelsOrientationSlide };
15
15
16 QChartAxis();
16 QChartAxis();
17 virtual ~QChartAxis();
17 virtual ~QChartAxis();
18
18
19 //axis
19 //axis
20 bool isAxisVisible() const { return m_axisVisible;};
20 bool isAxisVisible() const { return m_axisVisible;};
21 void setAxisVisible(bool visible);
21 void setAxisVisible(bool visible);
22 void setAxisPen(const QPen& pen);
22 void setAxisPen(const QPen& pen);
23 QPen axisPen() const { return m_axisPen;};
23 QPen axisPen() const { return m_axisPen;};
24 void setAxisBrush(const QBrush& brush);
24 void setAxisBrush(const QBrush& brush);
25 QBrush axisBrush() const { return m_axisBrush;};
25 QBrush axisBrush() const { return m_axisBrush;};
26
26
27 //grid
27 //grid
28 bool isGridVisible() const { return m_gridVisible;};
28 bool isGridVisible() const { return m_gridVisible;};
29 void setGridVisible(bool visible);
29 void setGridVisible(bool visible);
30 void setGridPen(const QPen& pen);
30 void setGridPen(const QPen& pen);
31 QPen gridPen() const {return m_gridPen;}
31 QPen gridPen() const {return m_gridPen;}
32
32
33 //labels
33 //labels
34 bool isLabelsVisible() const { return m_labelsVisible;};
34 bool isLabelsVisible() const { return m_labelsVisible;};
35 void setLabelsVisible(bool visible);
35 void setLabelsVisible(bool visible);
36 void setLabelsPen(const QPen& pen);
36 void setLabelsPen(const QPen& pen);
37 QPen labelsPen() const { return m_labelsPen;}
37 QPen labelsPen() const { return m_labelsPen;}
38 void setLabelsBrush(const QBrush& brush);
38 void setLabelsBrush(const QBrush& brush);
39 QBrush labelsBrush() const { return m_labelsBrush;}
39 QBrush labelsBrush() const { return m_labelsBrush;}
40 void setLabelsFont(const QFont& font);
40 void setLabelsFont(const QFont& font);
41 QFont labelFont() const { return m_labelsFont;}
41 QFont labelFont() const { return m_labelsFont;}
42 void setLabelsOrientation(LabelsOrientation orientation);
42 void setLabelsOrientation(LabelsOrientation orientation);
43 LabelsOrientation labelsOrientation() const { return m_labelsOrientation;};
43 LabelsOrientation labelsOrientation() const { return m_labelsOrientation;};
44
44
45 //shades
45 //shades
46 bool isShadesVisible() const { return m_shadesVisible;};
46 bool isShadesVisible() const { return m_shadesVisible;};
47 void setShadesVisible(bool visible);
47 void setShadesVisible(bool visible);
48 void setShadesPen(const QPen& pen);
48 void setShadesPen(const QPen& pen);
49 QPen shadesPen() const { return m_shadesPen;}
49 QPen shadesPen() const { return m_shadesPen;}
50 void setShadesBrush(const QBrush& brush);
50 void setShadesBrush(const QBrush& brush);
51 QBrush shadesBrush() const { return m_shadesBrush;}
51 QBrush shadesBrush() const { return m_shadesBrush;}
52 void setShadesOpacity(qreal opacity);
53 qreal shadesOpacity() const { return m_shadesOpacity;}
54
52
55
53
56
54 private:
57 private:
55
58
56 bool m_axisVisible;
59 bool m_axisVisible;
57 QPen m_axisPen;
60 QPen m_axisPen;
58 QBrush m_axisBrush;
61 QBrush m_axisBrush;
59
62
60 bool m_gridVisible;
63 bool m_gridVisible;
61 QPen m_gridPen;
64 QPen m_gridPen;
62
65
63 bool m_labelsVisible;
66 bool m_labelsVisible;
64 QPen m_labelsPen;
67 QPen m_labelsPen;
65 QBrush m_labelsBrush;
68 QBrush m_labelsBrush;
66 QFont m_labelsFont;
69 QFont m_labelsFont;
67
70
68 bool m_shadesVisible;
71 bool m_shadesVisible;
69 QPen m_shadesPen;
72 QPen m_shadesPen;
70 QBrush m_shadesBrush;
73 QBrush m_shadesBrush;
71
74
75 qreal m_shadesOpacity;
76
77
72 LabelsOrientation m_labelsOrientation;
78 LabelsOrientation m_labelsOrientation;
73 };
79 };
74
80
75 QTCOMMERCIALCHART_END_NAMESPACE
81 QTCOMMERCIALCHART_END_NAMESPACE
76 #endif /* QCHARTAXIS_H_ */
82 #endif /* QCHARTAXIS_H_ */
General Comments 0
You need to be logged in to leave comments. Login now