##// END OF EJS Templates
Adds missing ids to theme classes
Michal Klocek -
r153:04be7b528347
parent child
Show More
@@ -1,251 +1,261
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include "chartdataset_p.h"
4 #include "chartdataset_p.h"
5 #include "charttheme_p.h"
5 #include "charttheme_p.h"
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 "qpieseries.h"
11 #include "qpieseries.h"
12 //items
12 //items
13 #include "axisitem_p.h"
13 #include "axisitem_p.h"
14 #include "bargroup.h"
14 #include "bargroup.h"
15 #include "stackedbargroup.h"
15 #include "stackedbargroup.h"
16 #include "linechartitem_p.h"
16 #include "linechartitem_p.h"
17 #include "percentbargroup.h"
17 #include "percentbargroup.h"
18 #include "linechartanimationitem_p.h"
18 #include "linechartanimationitem_p.h"
19 #include "piepresenter.h"
19 #include "piepresenter.h"
20
20
21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
22
22
23 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
23 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
24 m_chart(chart),
24 m_chart(chart),
25 m_dataset(dataset),
25 m_dataset(dataset),
26 m_chartTheme(0),
26 m_chartTheme(0),
27 m_domainIndex(0),
27 m_domainIndex(0),
28 m_marginSize(0),
28 m_marginSize(0),
29 m_rect(QRectF(QPoint(0,0),m_chart->size()))
29 m_rect(QRectF(QPoint(0,0),m_chart->size()))
30 {
30 {
31 setTheme(QChart::ChartThemeDefault);
31 setChartTheme(QChart::ChartThemeDefault);
32 createConnections();
32 createConnections();
33 createDeafultAxis();
33 createDeafultAxis();
34 }
34 }
35
35
36 ChartPresenter::~ChartPresenter()
36 ChartPresenter::~ChartPresenter()
37 {
37 {
38 }
38 }
39
39
40 void ChartPresenter::createDeafultAxis()
40 void ChartPresenter::createDeafultAxis()
41 {
41 {
42 //default axis
42 //default axis
43 QChartAxis* axisX = new QChartAxis(this);
43 QChartAxis* axisX = new QChartAxis(this);
44 QChartAxis* axisY = new QChartAxis(this);
44 QChartAxis* axisY = new QChartAxis(this);
45
45
46 m_axis << new AxisItem(axisX,AxisItem::X_AXIS,m_chart);
46 m_axis << new AxisItem(axisX,AxisItem::X_AXIS,m_chart);
47 m_axis << new AxisItem(axisY,AxisItem::Y_AXIS,m_chart);
47 m_axis << new AxisItem(axisY,AxisItem::Y_AXIS,m_chart);
48
48
49 foreach(AxisItem* item, m_axis) {
49 foreach(AxisItem* item, m_axis) {
50 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
50 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
51 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
51 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
52 }
52 }
53 }
53 }
54
54
55 void ChartPresenter::createConnections()
55 void ChartPresenter::createConnections()
56 {
56 {
57 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
57 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
58 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
58 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
59 }
59 }
60
60
61 void ChartPresenter::handleGeometryChanged()
61 void ChartPresenter::handleGeometryChanged()
62 {
62 {
63 m_rect = QRectF(QPoint(0,0),m_chart->size());
63 m_rect = QRectF(QPoint(0,0),m_chart->size());
64 m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize);
64 m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize);
65 Q_ASSERT(m_rect.isValid());
65 Q_ASSERT(m_rect.isValid());
66 emit geometryChanged(m_rect);
66 emit geometryChanged(m_rect);
67 }
67 }
68
68
69 int ChartPresenter::margin() const
69 int ChartPresenter::margin() const
70 {
70 {
71 return m_marginSize;
71 return m_marginSize;
72 }
72 }
73
73
74 void ChartPresenter::setMargin(int margin)
74 void ChartPresenter::setMargin(int margin)
75 {
75 {
76 m_marginSize = margin;
76 m_marginSize = margin;
77 }
77 }
78
78
79 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
79 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
80 {
80 {
81 switch(series->type())
81 switch(series->type())
82 {
82 {
83 case QChartSeries::SeriesTypeLine: {
83 case QChartSeries::SeriesTypeLine: {
84 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
84 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
85 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
85 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
86 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
86 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
87 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
87 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
88 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
88 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
89 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
89 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
90 m_chartItems.insert(series,item);
90 m_chartItems.insert(series,item);
91 break;
91 break;
92 }
92 }
93
93
94 case QChartSeries::SeriesTypeBar: {
94 case QChartSeries::SeriesTypeBar: {
95 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
95 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
96 BarGroup* item = new BarGroup(*barSeries,m_chart);
96 BarGroup* item = new BarGroup(*barSeries,m_chart);
97 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
97 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
98 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
98 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
99 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
99 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
100 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
100 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
101 m_chartItems.insert(series,item);
101 m_chartItems.insert(series,item);
102 // m_axisXItem->setVisible(false);
102 // m_axisXItem->setVisible(false);
103 break;
103 break;
104 }
104 }
105
105
106 case QChartSeries::SeriesTypeStackedBar: {
106 case QChartSeries::SeriesTypeStackedBar: {
107
107
108 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
108 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
109 StackedBarGroup* item = new StackedBarGroup(*stackedBarSeries,m_chart);
109 StackedBarGroup* item = new StackedBarGroup(*stackedBarSeries,m_chart);
110 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
110 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
111 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
111 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
112 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
112 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
113 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
113 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
114 m_chartItems.insert(series,item);
114 m_chartItems.insert(series,item);
115 break;
115 break;
116 }
116 }
117
117
118 case QChartSeries::SeriesTypePercentBar: {
118 case QChartSeries::SeriesTypePercentBar: {
119
119
120 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
120 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
121 PercentBarGroup* item = new PercentBarGroup(*percentBarSeries,m_chart);
121 PercentBarGroup* item = new PercentBarGroup(*percentBarSeries,m_chart);
122 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
122 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
123 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
123 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
124 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
124 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
125 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
125 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
126 m_chartItems.insert(series,item);
126 m_chartItems.insert(series,item);
127 break;
127 break;
128 }
128 }
129 /*
129 /*
130 case QChartSeries::SeriesTypeScatter: {
130 case QChartSeries::SeriesTypeScatter: {
131 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
131 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
132 scatterSeries->d->m_theme = m_chartTheme->themeForSeries();
132 scatterSeries->d->m_theme = m_chartTheme->themeForSeries();
133 scatterSeries->d->setParentItem(this);
133 scatterSeries->d->setParentItem(this);
134 scatterSeries->d->m_boundingRect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
134 scatterSeries->d->m_boundingRect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
135 m_chartItems << scatterSeries->d;
135 m_chartItems << scatterSeries->d;
136 m_chartTheme->addObserver(scatterSeries->d);
136 m_chartTheme->addObserver(scatterSeries->d);
137
137
138 foreach (qreal x, scatterSeries->d->m_x) {
138 foreach (qreal x, scatterSeries->d->m_x) {
139 domain.m_minX = qMin(domain.m_minX, x);
139 domain.m_minX = qMin(domain.m_minX, x);
140 domain.m_maxX = qMax(domain.m_maxX, x);
140 domain.m_maxX = qMax(domain.m_maxX, x);
141 }
141 }
142 foreach (qreal y, scatterSeries->d->m_y) {
142 foreach (qreal y, scatterSeries->d->m_y) {
143 domain.m_minY = qMin(domain.m_minY, y);
143 domain.m_minY = qMin(domain.m_minY, y);
144 domain.m_maxY = qMax(domain.m_maxY, y);
144 domain.m_maxY = qMax(domain.m_maxY, y);
145 }
145 }
146
146
147 break;
147 break;
148 }
148 }
149 */
149 */
150
150
151 case QChartSeries::SeriesTypePie: {
151 case QChartSeries::SeriesTypePie: {
152 QPieSeries *pieSeries = qobject_cast<QPieSeries *>(series);
152 QPieSeries *pieSeries = qobject_cast<QPieSeries *>(series);
153 PiePresenter* pie = new PiePresenter(m_chart, pieSeries);
153 PiePresenter* pie = new PiePresenter(m_chart, pieSeries);
154 pieSeries->m_piePresenter = pie; // TODO: remove this pointer passing use signals&slots
154 pieSeries->m_piePresenter = pie; // TODO: remove this pointer passing use signals&slots
155 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
155 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
156 QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)), pie, SLOT(handleDomainChanged(const Domain&)));
156 QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)), pie, SLOT(handleDomainChanged(const Domain&)));
157 m_chartItems.insert(series, pie);
157 m_chartItems.insert(series, pie);
158 break;
158 break;
159 }
159 }
160
160
161 default: {
161 default: {
162 qDebug()<< "Series type" << series->type() << "not implemented.";
162 qDebug()<< "Series type" << series->type() << "not implemented.";
163 break;
163 break;
164 }
164 }
165 }
165 }
166
166
167 if(m_rect.isValid()) emit geometryChanged(m_rect);
167 if(m_rect.isValid()) emit geometryChanged(m_rect);
168 }
168 }
169
169
170 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
170 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
171 {
171 {
172 //TODO:
172 //TODO:
173 }
173 }
174
174
175 void ChartPresenter::zoomInToRect(const QRectF& rect)
175 void ChartPresenter::zoomInToRect(const QRectF& rect)
176 {
176 {
177 if(!rect.isValid()) return;
177 if(!rect.isValid()) return;
178 QRectF r = rect.normalized();
178 QRectF r = rect.normalized();
179 r.translate(-m_marginSize, -m_marginSize);
179 r.translate(-m_marginSize, -m_marginSize);
180 Domain domain (m_dataset->domain().subDomain(r,m_rect.width(),m_rect.height()));
180 Domain domain (m_dataset->domain().subDomain(r,m_rect.width(),m_rect.height()));
181 m_dataset->addDomain(domain);
181 m_dataset->addDomain(domain);
182 }
182 }
183
183
184 void ChartPresenter::zoomIn()
184 void ChartPresenter::zoomIn()
185 {
185 {
186 if (!m_dataset->nextDomain()) {
186 if (!m_dataset->nextDomain()) {
187 QRectF rect = m_rect;
187 QRectF rect = m_rect;
188 rect.setWidth(rect.width()/2);
188 rect.setWidth(rect.width()/2);
189 rect.setHeight(rect.height()/2);
189 rect.setHeight(rect.height()/2);
190 rect.moveCenter(m_rect.center());
190 rect.moveCenter(m_rect.center());
191 Domain domain (m_dataset->domain().subDomain(rect,m_rect.width(),m_rect.height()));
191 Domain domain (m_dataset->domain().subDomain(rect,m_rect.width(),m_rect.height()));
192 m_dataset->addDomain(domain);
192 m_dataset->addDomain(domain);
193 }
193 }
194 }
194 }
195
195
196 void ChartPresenter::zoomOut()
196 void ChartPresenter::zoomOut()
197 {
197 {
198 m_dataset->previousDomain();
198 m_dataset->previousDomain();
199 }
199 }
200
200
201 void ChartPresenter::zoomReset()
201 void ChartPresenter::zoomReset()
202 {
202 {
203 m_dataset->clearDomains();
203 m_dataset->clearDomains();
204 }
204 }
205
205
206 void ChartPresenter::setTheme(QChart::ChartThemeId theme)
206 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
207 {
207 {
208 delete m_chartTheme;
208 delete m_chartTheme;
209
209
210 m_chartTheme = ChartTheme::createTheme(theme);
210 m_chartTheme = ChartTheme::createTheme(theme);
211
211
212 m_chartTheme->decorate(m_chart);
212 m_chartTheme->decorate(m_chart);
213 QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems);
213 QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems);
214
214
215 int index=0;
215 int index=0;
216 while (i.hasNext()) {
216 while (i.hasNext()) {
217 i.next();
217 i.next();
218 index++;
218 index++;
219 m_chartTheme->decorate(i.value(),i.key(),index);
219 m_chartTheme->decorate(i.value(),i.key(),index);
220 }
220 }
221 }
221 }
222
222
223
223
224 QChart::ChartThemeId ChartPresenter::theme()
224 QChart::ChartTheme ChartPresenter::chartTheme()
225 {
225 {
226 return (QChart::ChartThemeId) 0;
226 return m_chartTheme->id();
227 }
228
229 void ChartPresenter::setAxisX(QChartAxis* axis)
230 {
231
232 }
233
234 void ChartPresenter::addAxisY(QChartAxis* axis)
235 {
236
227 }
237 }
228
238
229 /*
239 /*
230 void ChartPresenter::setAxisX(const QChartAxis& axis)
240 void ChartPresenter::setAxisX(const QChartAxis& axis)
231 {
241 {
232 setAxis(m_axisXItem,axis);
242 setAxis(m_axisXItem,axis);
233 }
243 }
234 void ChartPresenter::setAxisY(const QChartAxis& axis)
244 void ChartPresenter::setAxisY(const QChartAxis& axis)
235 {
245 {
236 setAxis(m_axisYItem.at(0),axis);
246 setAxis(m_axisYItem.at(0),axis);
237 }
247 }
238
248
239 void ChartPresenter::setAxisY(const QList<QChartAxis>& axis)
249 void ChartPresenter::setAxisY(const QList<QChartAxis>& axis)
240 {
250 {
241 //TODO not implemented
251 //TODO not implemented
242 }
252 }
243
253
244 void ChartPresenter::setAxis(AxisItem *item, const QChartAxis& axis)
254 void ChartPresenter::setAxis(AxisItem *item, const QChartAxis& axis)
245 {
255 {
246 item->setVisible(axis.isAxisVisible());
256 item->setVisible(axis.isAxisVisible());
247 }
257 }
248 */
258 */
249 #include "moc_chartpresenter_p.cpp"
259 #include "moc_chartpresenter_p.cpp"
250
260
251 QTCOMMERCIALCHART_END_NAMESPACE
261 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,72 +1,67
1 #ifndef CHARTPRESENTER_H_
1 #ifndef CHARTPRESENTER_H_
2 #define CHARTPRESENTER_H_
2 #define CHARTPRESENTER_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
6 #include <QRectF>
6 #include <QRectF>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class ChartItem;
10 class ChartItem;
11 class QChartSeries;
11 class QChartSeries;
12 class ChartDataSet;
12 class ChartDataSet;
13 //class QChart;
13 //class QChart;
14 class Domain;
14 class Domain;
15 class AxisItem;
15 class AxisItem;
16 class ChartTheme;
16 class ChartTheme;
17
17
18 class ChartPresenter: public QObject
18 class ChartPresenter: public QObject
19 {
19 {
20 Q_OBJECT
20 Q_OBJECT
21 public:
21 public:
22 ChartPresenter(QChart* chart,ChartDataSet *dataset);
22 ChartPresenter(QChart* chart,ChartDataSet *dataset);
23 virtual ~ChartPresenter();
23 virtual ~ChartPresenter();
24 /*
25 void setAxisX(const QChartAxis& axis);
26 void setAxisY(const QChartAxis& axis);
27 void setAxisY(const QList<QChartAxis>& axis);
28
29
30 */
31
24
32 void setMargin(int margin);
25 void setMargin(int margin);
33 int margin() const;
26 int margin() const;
34
27
35 void zoomInToRect(const QRectF& rectangle);
28 void zoomInToRect(const QRectF& rectangle);
36 void zoomIn();
29 void zoomIn();
37 void zoomOut();
30 void zoomOut();
38 void zoomReset();
31 void zoomReset();
39
32
40 void setTheme(QChart::ChartThemeId theme);
33 void setChartTheme(QChart::ChartTheme theme);
41 QChart::ChartThemeId theme();
34 QChart::ChartTheme chartTheme();
42
35
36 void setAxisX(QChartAxis* axis);
37 void addAxisY(QChartAxis* axis);
43 private:
38 private:
44 void createConnections();
39 void createConnections();
45 void createDeafultAxis();
40 void createDeafultAxis();
46
41
47 public slots:
42 public slots:
48 void handleSeriesAdded(QChartSeries* series);
43 void handleSeriesAdded(QChartSeries* series);
49 void handleSeriesRemoved(QChartSeries* series){};
44 void handleSeriesRemoved(QChartSeries* series){};
50 void handleSeriesChanged(QChartSeries* series);
45 void handleSeriesChanged(QChartSeries* series);
51 //void handleDomainChanged(Domain oldDomain,Domain newDomain);
46 //void handleDomainChanged(Domain oldDomain,Domain newDomain);
52 void handleGeometryChanged();
47 void handleGeometryChanged();
53
48
54 signals:
49 signals:
55 void geometryChanged(const QRectF& rect);
50 void geometryChanged(const QRectF& rect);
56
51
57 private:
52 private:
58 QMap<QChartSeries*,ChartItem*> m_chartItems;
53 QMap<QChartSeries*,ChartItem*> m_chartItems;
59 QChart* m_chart;
54 QChart* m_chart;
60 ChartDataSet* m_dataset;
55 ChartDataSet* m_dataset;
61 QVector<Domain> m_domains;
56 QVector<Domain> m_domains;
62 QList<AxisItem*> m_axis;
57 QList<AxisItem*> m_axis;
63 ChartTheme *m_chartTheme;
58 ChartTheme *m_chartTheme;
64 int m_domainIndex;
59 int m_domainIndex;
65 int m_marginSize;
60 int m_marginSize;
66 QRectF m_rect;
61 QRectF m_rect;
67
62
68 };
63 };
69
64
70 QTCOMMERCIALCHART_END_NAMESPACE
65 QTCOMMERCIALCHART_END_NAMESPACE
71
66
72 #endif /* CHARTPRESENTER_H_ */
67 #endif /* CHARTPRESENTER_H_ */
@@ -1,149 +1,150
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #include "qchart.h"
2 #include "qchart.h"
3
3
4
4
5 //series
5 //series
6 #include "barchartseries.h"
6 #include "barchartseries.h"
7 #include "stackedbarchartseries.h"
7 #include "stackedbarchartseries.h"
8 #include "percentbarchartseries.h"
8 #include "percentbarchartseries.h"
9 #include "qlinechartseries.h"
9 #include "qlinechartseries.h"
10 //items
10 //items
11 #include "axisitem_p.h"
11 #include "axisitem_p.h"
12 #include "bargroup.h"
12 #include "bargroup.h"
13 #include "stackedbargroup.h"
13 #include "stackedbargroup.h"
14 #include "linechartitem_p.h"
14 #include "linechartitem_p.h"
15 #include "percentbargroup.h"
15 #include "percentbargroup.h"
16
16
17 //themes
17 //themes
18 #include "chartthemevanilla_p.h"
18 #include "chartthemevanilla_p.h"
19 #include "chartthemeicy_p.h"
19 #include "chartthemeicy_p.h"
20 #include "chartthemegrayscale_p.h"
20 #include "chartthemegrayscale_p.h"
21 #include "chartthemescientific_p.h"
21 #include "chartthemescientific_p.h"
22
22
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /* TODO
26 /* TODO
27 case QChart::ChartThemeUnnamed1:
27 case QChart::ChartThemeUnnamed1:
28 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
28 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
29 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
29 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
30 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
30 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
31 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
31 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
32 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
32 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
33
33
34 m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
34 m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
35 m_gradientEndColor = QColor(QRgb(0xffafafaf));
35 m_gradientEndColor = QColor(QRgb(0xffafafaf));
36 */
36 */
37
37
38 ChartTheme::ChartTheme()
38 ChartTheme::ChartTheme(QChart::ChartTheme id)
39 {
39 {
40 m_id = id;
40 m_seriesColor.append(QRgb(0xff000000));
41 m_seriesColor.append(QRgb(0xff000000));
41 m_seriesColor.append(QRgb(0xff707070));
42 m_seriesColor.append(QRgb(0xff707070));
42 m_gradientStartColor = QColor(QRgb(0xffffffff));
43 m_gradientStartColor = QColor(QRgb(0xffffffff));
43 m_gradientEndColor = QColor(QRgb(0xffafafaf));
44 m_gradientEndColor = QColor(QRgb(0xffafafaf));
44 }
45 }
45
46
46
47
47 ChartTheme* ChartTheme::createTheme(QChart::ChartThemeId theme)
48 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
48 {
49 {
49 switch(theme) {
50 switch(theme) {
50 case QChart::ChartThemeDefault:
51 case QChart::ChartThemeDefault:
51 return new ChartTheme();
52 return new ChartTheme();
52 case QChart::ChartThemeVanilla:
53 case QChart::ChartThemeVanilla:
53 return new ChartThemeVanilla();
54 return new ChartThemeVanilla();
54 case QChart::ChartThemeIcy:
55 case QChart::ChartThemeIcy:
55 return new ChartThemeIcy();
56 return new ChartThemeIcy();
56 case QChart::ChartThemeGrayscale:
57 case QChart::ChartThemeGrayscale:
57 return new ChartThemeGrayscale();
58 return new ChartThemeGrayscale();
58 case QChart::ChartThemeScientific:
59 case QChart::ChartThemeScientific:
59 return new ChartThemeScientific();
60 return new ChartThemeScientific();
60 }
61 }
61 }
62 }
62
63
63 void ChartTheme::decorate(QChart* chart)
64 void ChartTheme::decorate(QChart* chart)
64 {
65 {
65 QLinearGradient backgroundGradient;
66 QLinearGradient backgroundGradient;
66 backgroundGradient.setColorAt(0.0, m_gradientStartColor);
67 backgroundGradient.setColorAt(0.0, m_gradientStartColor);
67 backgroundGradient.setColorAt(1.0, m_gradientEndColor);
68 backgroundGradient.setColorAt(1.0, m_gradientEndColor);
68 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
69 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
69 chart->setChartBackgroundBrush(backgroundGradient);
70 chart->setChartBackgroundBrush(backgroundGradient);
70 }
71 }
71 //TODO helper to by removed later
72 //TODO helper to by removed later
72 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
73 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
73 {
74 {
74 switch(series->type())
75 switch(series->type())
75 {
76 {
76 case QChartSeries::SeriesTypeLine: {
77 case QChartSeries::SeriesTypeLine: {
77 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
78 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
78 LineChartItem* i = static_cast<LineChartItem*>(item);
79 LineChartItem* i = static_cast<LineChartItem*>(item);
79 decorate(i,s,count);
80 decorate(i,s,count);
80 break;
81 break;
81 }
82 }
82 case QChartSeries::SeriesTypeBar: {
83 case QChartSeries::SeriesTypeBar: {
83 BarChartSeries* b = static_cast<BarChartSeries*>(series);
84 BarChartSeries* b = static_cast<BarChartSeries*>(series);
84 BarGroup* i = static_cast<BarGroup*>(item);
85 BarGroup* i = static_cast<BarGroup*>(item);
85 decorate(i,b,count);
86 decorate(i,b,count);
86 break;
87 break;
87 }
88 }
88 case QChartSeries::SeriesTypeStackedBar: {
89 case QChartSeries::SeriesTypeStackedBar: {
89 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
90 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
90 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
91 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
91 decorate(i,s,count);
92 decorate(i,s,count);
92 break;
93 break;
93 }
94 }
94 case QChartSeries::SeriesTypePercentBar: {
95 case QChartSeries::SeriesTypePercentBar: {
95 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
96 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
96 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
97 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
97 decorate(i,s,count);
98 decorate(i,s,count);
98 break;
99 break;
99 }
100 }
100 default:
101 default:
101 qDebug()<<"Wrong item to be decorated by theme";
102 qDebug()<<"Wrong item to be decorated by theme";
102 break;
103 break;
103 }
104 }
104
105
105 }
106 }
106
107
107 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
108 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
108 {
109 {
109 QPen pen;
110 QPen pen;
110 if(pen != series->pen()){
111 if(pen != series->pen()){
111 item->setPen(series->pen());
112 item->setPen(series->pen());
112 return;
113 return;
113 }
114 }
114 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
115 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
115 pen.setWidthF(2);
116 pen.setWidthF(2);
116 item->setPen(pen);
117 item->setPen(pen);
117 }
118 }
118
119
119 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
120 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
120 {
121 {
121 item->addColor(QColor(255,0,0,128));
122 item->addColor(QColor(255,0,0,128));
122 item->addColor(QColor(255,255,0,128));
123 item->addColor(QColor(255,255,0,128));
123 item->addColor(QColor(0,255,0,128));
124 item->addColor(QColor(0,255,0,128));
124 item->addColor(QColor(0,0,255,128));
125 item->addColor(QColor(0,0,255,128));
125 item->addColor(QColor(255,128,0,128));
126 item->addColor(QColor(255,128,0,128));
126 }
127 }
127
128
128 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
129 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
129 {
130 {
130 // Add some fugly colors for 5 fist series...
131 // Add some fugly colors for 5 fist series...
131 item->addColor(QColor(255,0,0,128));
132 item->addColor(QColor(255,0,0,128));
132 item->addColor(QColor(255,255,0,128));
133 item->addColor(QColor(255,255,0,128));
133 item->addColor(QColor(0,255,0,128));
134 item->addColor(QColor(0,255,0,128));
134 item->addColor(QColor(0,0,255,128));
135 item->addColor(QColor(0,0,255,128));
135 item->addColor(QColor(255,128,0,128));
136 item->addColor(QColor(255,128,0,128));
136 }
137 }
137
138
138 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
139 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
139 {
140 {
140 // Add some fugly colors for 5 fist series...
141 // Add some fugly colors for 5 fist series...
141 item->addColor(QColor(255,0,0,128));
142 item->addColor(QColor(255,0,0,128));
142 item->addColor(QColor(255,255,0,128));
143 item->addColor(QColor(255,255,0,128));
143 item->addColor(QColor(0,255,0,128));
144 item->addColor(QColor(0,255,0,128));
144 item->addColor(QColor(0,0,255,128));
145 item->addColor(QColor(0,0,255,128));
145 item->addColor(QColor(255,128,0,128));
146 item->addColor(QColor(255,128,0,128));
146 }
147 }
147
148
148
149
149 QTCOMMERCIALCHART_END_NAMESPACE
150 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,43 +1,45
1 #ifndef CHARTTHEME_H
1 #ifndef CHARTTHEME_H
2 #define CHARTTHEME_H
2 #define CHARTTHEME_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchart.h"
5 #include "qchart.h"
6 #include <QColor>
6 #include <QColor>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class ChartItem;
10 class ChartItem;
11 class QChartSeries;
11 class QChartSeries;
12 class LineChartItem;
12 class LineChartItem;
13 class QLineChartSeries;
13 class QLineChartSeries;
14 class BarGroup;
14 class BarGroup;
15 class BarChartSeries;
15 class BarChartSeries;
16 class StackedBarGroup;
16 class StackedBarGroup;
17 class StackedBarChartSeries;
17 class StackedBarChartSeries;
18 class PercentBarChartSeries;
18 class PercentBarChartSeries;
19 class PercentBarGroup;
19 class PercentBarGroup;
20
20
21 class ChartTheme
21 class ChartTheme
22 {
22 {
23 protected:
23 protected:
24 explicit ChartTheme();
24 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
25 public:
25 public:
26 static ChartTheme* createTheme(QChart::ChartThemeId theme);
26 static ChartTheme* createTheme(QChart::ChartTheme theme);
27 QChart::ChartTheme id() const {return m_id;}
27 void decorate(QChart* chart);
28 void decorate(QChart* chart);
28 void decorate(ChartItem* item, QChartSeries* series,int count);
29 void decorate(ChartItem* item, QChartSeries* series,int count);
29 void decorate(LineChartItem* item, QLineChartSeries*, int count);
30 void decorate(LineChartItem* item, QLineChartSeries*, int count);
30 void decorate(BarGroup* item, BarChartSeries* series,int count);
31 void decorate(BarGroup* item, BarChartSeries* series,int count);
31 void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count);
32 void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count);
32 void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count);
33 void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count);
33
34
34 protected:
35 protected:
36 QChart::ChartTheme m_id;
35 QColor m_gradientStartColor;
37 QColor m_gradientStartColor;
36 QColor m_gradientEndColor;
38 QColor m_gradientEndColor;
37 QList<QColor> m_seriesColor;
39 QList<QColor> m_seriesColor;
38
40
39 };
41 };
40
42
41 QTCOMMERCIALCHART_END_NAMESPACE
43 QTCOMMERCIALCHART_END_NAMESPACE
42
44
43 #endif // CHARTTHEME_H
45 #endif // CHARTTHEME_H
@@ -1,190 +1,180
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qscatterseries.h"
2 #include "qscatterseries.h"
3 #include "qscatterseries_p.h"
3 #include "qscatterseries_p.h"
4 #include "qpieseries.h"
4 #include "qpieseries.h"
5 #include "qchartaxis.h"
5 #include "qchartaxis.h"
6 #include "chartpresenter_p.h"
6 #include "chartpresenter_p.h"
7 #include "chartdataset_p.h"
7 #include "chartdataset_p.h"
8
8
9 //series
9 //series
10 #include "barchartseries.h"
10 #include "barchartseries.h"
11 #include "stackedbarchartseries.h"
11 #include "stackedbarchartseries.h"
12 #include "percentbarchartseries.h"
12 #include "percentbarchartseries.h"
13 #include "qlinechartseries.h"
13 #include "qlinechartseries.h"
14
14
15 #include <QGraphicsScene>
15 #include <QGraphicsScene>
16 #include <QGraphicsSceneResizeEvent>
16 #include <QGraphicsSceneResizeEvent>
17 #include <QDebug>
17 #include <QDebug>
18
18
19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
20
20
21 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
21 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
22 m_backgroundItem(0),
22 m_backgroundItem(0),
23 m_titleItem(0),
23 m_titleItem(0),
24 m_dataset(new ChartDataSet(this)),
24 m_dataset(new ChartDataSet(this)),
25 m_presenter(new ChartPresenter(this,m_dataset))
25 m_presenter(new ChartPresenter(this,m_dataset))
26 {
26 {
27 }
27 }
28
28
29 QChart::~QChart() {}
29 QChart::~QChart() {}
30
30
31 void QChart::addSeries(QChartSeries* series)
31 void QChart::addSeries(QChartSeries* series)
32 {
32 {
33 m_dataset->addSeries(series);
33 m_dataset->addSeries(series);
34 }
34 }
35
35
36 //TODO on review, is it really needed ??
36 //TODO on review, is it really needed ??
37 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
37 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
38 {
38 {
39 // TODO: support also other types; not only scatter and pie
39 // TODO: support also other types; not only scatter and pie
40
40
41 QChartSeries *series(0);
41 QChartSeries *series(0);
42
42
43 switch (type) {
43 switch (type) {
44 case QChartSeries::SeriesTypeLine: {
44 case QChartSeries::SeriesTypeLine: {
45 series = QLineChartSeries::create();
45 series = QLineChartSeries::create();
46 break;
46 break;
47 }
47 }
48 case QChartSeries::SeriesTypeBar: {
48 case QChartSeries::SeriesTypeBar: {
49 series = new BarChartSeries(this);
49 series = new BarChartSeries(this);
50 break;
50 break;
51 }
51 }
52 case QChartSeries::SeriesTypeStackedBar: {
52 case QChartSeries::SeriesTypeStackedBar: {
53 series = new StackedBarChartSeries(this);
53 series = new StackedBarChartSeries(this);
54 break;
54 break;
55 }
55 }
56 case QChartSeries::SeriesTypePercentBar: {
56 case QChartSeries::SeriesTypePercentBar: {
57 series = new PercentBarChartSeries(this);
57 series = new PercentBarChartSeries(this);
58 break;
58 break;
59 }
59 }
60 case QChartSeries::SeriesTypeScatter: {
60 case QChartSeries::SeriesTypeScatter: {
61 series = new QScatterSeries(this);
61 series = new QScatterSeries(this);
62 break;
62 break;
63 }
63 }
64 case QChartSeries::SeriesTypePie: {
64 case QChartSeries::SeriesTypePie: {
65 series = new QPieSeries(this);
65 series = new QPieSeries(this);
66 break;
66 break;
67 }
67 }
68 default:
68 default:
69 Q_ASSERT(false);
69 Q_ASSERT(false);
70 break;
70 break;
71 }
71 }
72
72
73 addSeries(series);
73 addSeries(series);
74 return series;
74 return series;
75 }
75 }
76
76
77 void QChart::setChartBackgroundBrush(const QBrush& brush)
77 void QChart::setChartBackgroundBrush(const QBrush& brush)
78 {
78 {
79
79
80 if(!m_backgroundItem) {
80 if(!m_backgroundItem) {
81 m_backgroundItem = new QGraphicsRectItem(this);
81 m_backgroundItem = new QGraphicsRectItem(this);
82 m_backgroundItem->setZValue(-1);
82 m_backgroundItem->setZValue(-1);
83 }
83 }
84
84
85 m_backgroundItem->setBrush(brush);
85 m_backgroundItem->setBrush(brush);
86 m_backgroundItem->update();
86 m_backgroundItem->update();
87 }
87 }
88
88
89 void QChart::setChartBackgroundPen(const QPen& pen)
89 void QChart::setChartBackgroundPen(const QPen& pen)
90 {
90 {
91
91
92 if(!m_backgroundItem) {
92 if(!m_backgroundItem) {
93 m_backgroundItem = new QGraphicsRectItem(this);
93 m_backgroundItem = new QGraphicsRectItem(this);
94 m_backgroundItem->setZValue(-1);
94 m_backgroundItem->setZValue(-1);
95 }
95 }
96
96
97 m_backgroundItem->setPen(pen);
97 m_backgroundItem->setPen(pen);
98 m_backgroundItem->update();
98 m_backgroundItem->update();
99 }
99 }
100
100
101 void QChart::setTitle(const QString& title,const QFont& font)
101 void QChart::setTitle(const QString& title,const QFont& font)
102 {
102 {
103 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
103 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
104 m_titleItem->setPlainText(title);
104 m_titleItem->setPlainText(title);
105 m_titleItem->setFont(font);
105 m_titleItem->setFont(font);
106 }
106 }
107
107
108 int QChart::margin() const
108 int QChart::margin() const
109 {
109 {
110 return m_presenter->margin();
110 return m_presenter->margin();
111 }
111 }
112
112
113 void QChart::setMargin(int margin)
113 void QChart::setMargin(int margin)
114 {
114 {
115 m_presenter->setMargin(margin);
115 m_presenter->setMargin(margin);
116 }
116 }
117
117
118 void QChart::setTheme(QChart::ChartThemeId theme)
118 void QChart::setChartTheme(QChart::ChartTheme theme)
119 {
119 {
120 m_presenter->setTheme(theme);
120 m_presenter->setChartTheme(theme);
121 }
121 }
122
122
123 QChart::ChartThemeId QChart::theme()
123 QChart::ChartTheme QChart::chartTheme() const
124 {
124 {
125 return m_presenter->theme();
125 return m_presenter->chartTheme();
126 }
126 }
127
127
128 void QChart::zoomInToRect(const QRectF& rectangle)
128 void QChart::zoomInToRect(const QRectF& rectangle)
129 {
129 {
130 m_presenter->zoomInToRect(rectangle);
130 m_presenter->zoomInToRect(rectangle);
131 }
131 }
132
132
133 void QChart::zoomIn()
133 void QChart::zoomIn()
134 {
134 {
135 m_presenter->zoomIn();
135 m_presenter->zoomIn();
136 }
136 }
137
137
138 void QChart::zoomOut()
138 void QChart::zoomOut()
139 {
139 {
140 m_presenter->zoomOut();
140 m_presenter->zoomOut();
141 }
141 }
142
142
143 void QChart::zoomReset()
143 void QChart::zoomReset()
144 {
144 {
145 m_presenter->zoomReset();
145 m_presenter->zoomReset();
146 }
146 }
147
147
148 void QChart::setAxisX(const QChartAxis& axis)
148 void QChart::setAxisX(QChartAxis* axis)
149 {
149 {
150
150 m_presenter->setAxisX(axis);
151 }
151 }
152 void QChart::setAxisY(const QChartAxis& axis)
152 void QChart::addAxisY(QChartAxis* axis)
153 {
154
155 }
156
157 void QChart::setAxisY(const QList<QChartAxis>& axis)
158 {
153 {
159 //TODO not implemented
154 m_presenter->addAxisY(axis);
160 }
161
162 void QChart::setAxis(AxisItem *item, const QChartAxis& axis)
163 {
164
165 }
155 }
166
156
167 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
157 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
168 {
158 {
169
159
170 m_rect = QRectF(QPoint(0,0),event->newSize());
160 m_rect = QRectF(QPoint(0,0),event->newSize());
171 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
161 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
172
162
173 // recalculate title position
163 // recalculate title position
174 if (m_titleItem) {
164 if (m_titleItem) {
175 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
165 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
176 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
166 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
177 }
167 }
178
168
179 //recalculate background gradient
169 //recalculate background gradient
180 if (m_backgroundItem) {
170 if (m_backgroundItem) {
181 m_backgroundItem->setRect(rect);
171 m_backgroundItem->setRect(rect);
182 }
172 }
183
173
184 QGraphicsWidget::resizeEvent(event);
174 QGraphicsWidget::resizeEvent(event);
185 update();
175 update();
186 }
176 }
187
177
188 #include "moc_qchart.cpp"
178 #include "moc_qchart.cpp"
189
179
190 QTCOMMERCIALCHART_END_NAMESPACE
180 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,92 +1,90
1 #ifndef CHART_H
1 #ifndef CHART_H
2 #define CHART_H
2 #define CHART_H
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qchartseries.h>
5 #include <qchartseries.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 QChartSeries;
15 class QChartSeries;
16 class PlotDomain;
16 class PlotDomain;
17 class BarGroup;
17 class BarGroup;
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
23
24 // TODO: We don't need to have QChart tied to QGraphicsItem:
24 // TODO: We don't need to have QChart tied to QGraphicsItem:
25 //class QTCOMMERCIALCHART_EXPORT QChart
25 //class QTCOMMERCIALCHART_EXPORT QChart
26 //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem {
26 //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem {
27 // public: QChartGraphicsItem(QChart &chart);
27 // public: QChartGraphicsItem(QChart &chart);
28
28
29 /*!
29 /*!
30 * TODO: define the responsibilities
30 * TODO: define the responsibilities
31 */
31 */
32 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
32 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35 public:
35 public:
36 enum ChartThemeId {
36 enum ChartTheme {
37 ChartThemeInvalid = -1,
38 /*! The default theme follows the GUI style of the Operating System */
37 /*! The default theme follows the GUI style of the Operating System */
39 ChartThemeDefault,
38 ChartThemeDefault,
40 ChartThemeVanilla,
39 ChartThemeVanilla,
41 ChartThemeIcy,
40 ChartThemeIcy,
42 ChartThemeGrayscale,
41 ChartThemeGrayscale,
43 ChartThemeScientific,
42 ChartThemeScientific,
44 //ChartThemeUnnamed1
43 //ChartThemeUnnamed1
45 };
44 };
46
45
47 public:
46 public:
48 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
47 QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
49 ~QChart();
48 ~QChart();
50
49
51 void addSeries(QChartSeries* series);
50 void addSeries(QChartSeries* series);
52
51
53 //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type);
52 //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type);
54 // TODO: who owns the series now? maybe owned by chart and returned a reference instead...
53 // TODO: who owns the series now? maybe owned by chart and returned a reference instead...
55 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
54 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
56
55
57 void setMargin(int margin);
56 void setMargin(int margin);
58 int margin() const;
57 int margin() const;
59 void setTheme(QChart::ChartThemeId theme);
58 void setChartTheme(QChart::ChartTheme theme);
60 QChart::ChartThemeId theme();
59 QChart::ChartTheme chartTheme() const;
61
60
62 void setTitle(const QString& title,const QFont& font = QFont());
61 void setTitle(const QString& title,const QFont& font = QFont());
63 void setChartBackgroundBrush(const QBrush& brush);
62 void setChartBackgroundBrush(const QBrush& brush);
64 void setChartBackgroundPen(const QPen& pen);
63 void setChartBackgroundPen(const QPen& pen);
65
64
66 void zoomInToRect(const QRectF& rectangle);
65 void zoomInToRect(const QRectF& rectangle);
67 void zoomIn();
66 void zoomIn();
68 void zoomOut();
67 void zoomOut();
69 void zoomReset();
68 void zoomReset();
70
69
71 void setAxisX(const QChartAxis& axis);
70 void setAxisX(QChartAxis* axis);
72 void setAxisY(const QChartAxis& axis);
71 void addAxisY(QChartAxis* axis);
73 void setAxisY(const QList<QChartAxis>& axis);
74
72
75 protected:
73 protected:
76 void resizeEvent(QGraphicsSceneResizeEvent *event);
74 void resizeEvent(QGraphicsSceneResizeEvent *event);
77
75
78 private:
76 private:
79 void setAxis(AxisItem *item, const QChartAxis& axis);
77 void setAxis(AxisItem *item, const QChartAxis& axis);
80
78
81 private:
79 private:
82 Q_DISABLE_COPY(QChart)
80 Q_DISABLE_COPY(QChart)
83 QGraphicsRectItem* m_backgroundItem;
81 QGraphicsRectItem* m_backgroundItem;
84 QGraphicsTextItem* m_titleItem;
82 QGraphicsTextItem* m_titleItem;
85 QRectF m_rect;
83 QRectF m_rect;
86 ChartDataSet *m_dataset;
84 ChartDataSet *m_dataset;
87 ChartPresenter *m_presenter;
85 ChartPresenter *m_presenter;
88 };
86 };
89
87
90 QTCOMMERCIALCHART_END_NAMESPACE
88 QTCOMMERCIALCHART_END_NAMESPACE
91
89
92 #endif
90 #endif
@@ -1,198 +1,202
1 #include "qchartview.h"
1 #include "qchartview.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include <QGraphicsView>
3 #include <QGraphicsView>
4 #include <QGraphicsScene>
4 #include <QGraphicsScene>
5 #include <QRubberBand>
5 #include <QRubberBand>
6 #include <QResizeEvent>
6 #include <QResizeEvent>
7 #include <QDebug>
7 #include <QDebug>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 QChartView::QChartView(QWidget *parent) :
11 QChartView::QChartView(QWidget *parent) :
12 QGraphicsView(parent),
12 QGraphicsView(parent),
13 m_scene(new QGraphicsScene()),
13 m_scene(new QGraphicsScene()),
14 m_chart(new QChart()),
14 m_chart(new QChart()),
15 m_rubberBand(0),
15 m_rubberBand(0),
16 m_verticalRubberBand(false),
16 m_verticalRubberBand(false),
17 m_horizonalRubberBand(false)
17 m_horizonalRubberBand(false)
18 {
18 {
19 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
19 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
21 setScene(m_scene);
21 setScene(m_scene);
22 m_chart->setMargin(50);
22 m_chart->setMargin(50);
23 m_scene->addItem(m_chart);
23 m_scene->addItem(m_chart);
24 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
24 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
25 }
25 }
26
26
27 QChartView::~QChartView()
27 QChartView::~QChartView()
28 {
28 {
29 }
29 }
30
30
31 void QChartView::resizeEvent(QResizeEvent *event)
31 void QChartView::resizeEvent(QResizeEvent *event)
32 {
32 {
33 m_scene->setSceneRect(0,0,size().width(),size().height());
33 m_scene->setSceneRect(0,0,size().width(),size().height());
34 m_chart->resize(size());
34 m_chart->resize(size());
35 QWidget::resizeEvent(event);
35 QWidget::resizeEvent(event);
36 }
36 }
37
37
38
38
39 void QChartView::addSeries(QChartSeries* series)
39 void QChartView::addSeries(QChartSeries* series)
40 {
40 {
41 m_chart->addSeries(series);
41 m_chart->addSeries(series);
42 }
42 }
43
43
44 QChartSeries* QChartView::createSeries(QChartSeries::QChartSeriesType type)
44 QChartSeries* QChartView::createSeries(QChartSeries::QChartSeriesType type)
45 {
45 {
46
46
47 return m_chart->createSeries(type);
47 return m_chart->createSeries(type);
48 }
48 }
49
49
50 void QChartView::zoomInToRect(const QRect& rectangle)
50 void QChartView::zoomInToRect(const QRect& rectangle)
51 {
51 {
52 m_chart->zoomInToRect(rectangle);
52 m_chart->zoomInToRect(rectangle);
53 }
53 }
54
54
55 void QChartView::zoomIn()
55 void QChartView::zoomIn()
56 {
56 {
57 m_chart->zoomIn();
57 m_chart->zoomIn();
58 }
58 }
59
59
60 void QChartView::zoomOut()
60 void QChartView::zoomOut()
61 {
61 {
62 m_chart->zoomOut();
62 m_chart->zoomOut();
63 }
63 }
64
64
65 int QChartView::margin() const
65 int QChartView::margin() const
66 {
66 {
67 return m_chart->margin();
67 return m_chart->margin();
68 }
68 }
69
69
70 void QChartView::setTitle(const QString& title)
70 void QChartView::setTitle(const QString& title)
71 {
71 {
72 m_chart->setTitle(title);
72 m_chart->setTitle(title);
73 }
73 }
74
74
75 void QChartView::setChartBackgroundBrush(const QBrush& brush)
75 void QChartView::setChartBackgroundBrush(const QBrush& brush)
76 {
76 {
77 m_chart->setChartBackgroundBrush(brush);
77 m_chart->setChartBackgroundBrush(brush);
78 }
78 }
79 void QChartView::setChartBackgroundPen(const QPen& pen)
79 void QChartView::setChartBackgroundPen(const QPen& pen)
80 {
80 {
81 m_chart->setChartBackgroundPen(pen);
81 m_chart->setChartBackgroundPen(pen);
82 }
82 }
83
83
84
84
85 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
85 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
86 {
86 {
87 switch(policy){
87 switch(policy){
88 case VerticalRubberBand:
88 case VerticalRubberBand:
89 m_verticalRubberBand = true;
89 m_verticalRubberBand = true;
90 m_horizonalRubberBand = false;
90 m_horizonalRubberBand = false;
91 break;
91 break;
92 case HorizonalRubberBand:
92 case HorizonalRubberBand:
93 m_verticalRubberBand = false;
93 m_verticalRubberBand = false;
94 m_horizonalRubberBand = true;
94 m_horizonalRubberBand = true;
95 break;
95 break;
96 case RectangleRubberBand:
96 case RectangleRubberBand:
97 m_verticalRubberBand = true;
97 m_verticalRubberBand = true;
98 m_horizonalRubberBand = true;
98 m_horizonalRubberBand = true;
99 break;
99 break;
100 case NoRubberBand:
100 case NoRubberBand:
101 default:
101 default:
102 delete m_rubberBand;
102 delete m_rubberBand;
103 m_rubberBand=0;
103 m_rubberBand=0;
104 m_horizonalRubberBand = false;
104 m_horizonalRubberBand = false;
105 m_verticalRubberBand = false;
105 m_verticalRubberBand = false;
106 return;
106 return;
107 }
107 }
108 if(!m_rubberBand){
108 if(!m_rubberBand){
109 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
109 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
110 m_rubberBand->setEnabled(true);
110 m_rubberBand->setEnabled(true);
111 }
111 }
112 }
112 }
113
113
114 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
114 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
115 {
115 {
116 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
116 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
117 if(m_horizonalRubberBand) return HorizonalRubberBand;
117 if(m_horizonalRubberBand) return HorizonalRubberBand;
118 if(m_verticalRubberBand) return VerticalRubberBand;
118 if(m_verticalRubberBand) return VerticalRubberBand;
119 return NoRubberBand;
119 return NoRubberBand;
120 }
120 }
121
121
122
122
123 void QChartView::mousePressEvent(QMouseEvent *event)
123 void QChartView::mousePressEvent(QMouseEvent *event)
124 {
124 {
125 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
125 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
126
126
127 int margin = m_chart->margin();
127 int margin = m_chart->margin();
128 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
128 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
129
129
130 if (rect.contains(event->pos())) {
130 if (rect.contains(event->pos())) {
131 m_rubberBandOrigin = event->pos();
131 m_rubberBandOrigin = event->pos();
132 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
132 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
133 m_rubberBand->show();
133 m_rubberBand->show();
134 event->accept();
134 event->accept();
135 }
135 }
136 }
136 }
137 }
137 }
138
138
139 void QChartView::mouseMoveEvent(QMouseEvent *event)
139 void QChartView::mouseMoveEvent(QMouseEvent *event)
140 {
140 {
141 if(m_rubberBand && m_rubberBand->isVisible()){
141 if(m_rubberBand && m_rubberBand->isVisible()){
142 int margin = m_chart->margin();
142 int margin = m_chart->margin();
143 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
143 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
144 int width = event->pos().x() - m_rubberBandOrigin.x();
144 int width = event->pos().x() - m_rubberBandOrigin.x();
145 int height = event->pos().y() - m_rubberBandOrigin.y();
145 int height = event->pos().y() - m_rubberBandOrigin.y();
146 if(!m_verticalRubberBand) {
146 if(!m_verticalRubberBand) {
147 m_rubberBandOrigin.setY(rect.top());
147 m_rubberBandOrigin.setY(rect.top());
148 height = rect.height();
148 height = rect.height();
149 }
149 }
150 if(!m_horizonalRubberBand) {
150 if(!m_horizonalRubberBand) {
151 m_rubberBandOrigin.setX(rect.left());
151 m_rubberBandOrigin.setX(rect.left());
152 width= rect.width();
152 width= rect.width();
153 }
153 }
154 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
154 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
155 } else {
155 } else {
156 QGraphicsView::mouseMoveEvent(event);
156 QGraphicsView::mouseMoveEvent(event);
157 }
157 }
158 }
158 }
159
159
160 void QChartView::mouseReleaseEvent(QMouseEvent *event)
160 void QChartView::mouseReleaseEvent(QMouseEvent *event)
161 {
161 {
162 if(m_rubberBand){
162 if(m_rubberBand){
163 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
163 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
164 m_rubberBand->hide();
164 m_rubberBand->hide();
165 QRect rect = m_rubberBand->geometry();
165 QRect rect = m_rubberBand->geometry();
166 m_chart->zoomInToRect(rect);
166 m_chart->zoomInToRect(rect);
167 event->accept();
167 event->accept();
168 }
168 }
169
169
170 if(event->button()==Qt::RightButton)
170 if(event->button()==Qt::RightButton)
171 m_chart->zoomReset();
171 m_chart->zoomReset();
172 }else{
172 }else{
173 QGraphicsView::mouseReleaseEvent(event);
173 QGraphicsView::mouseReleaseEvent(event);
174 }
174 }
175 }
175 }
176
176
177 void QChartView::keyPressEvent(QKeyEvent *event)
177 void QChartView::keyPressEvent(QKeyEvent *event)
178 {
178 {
179 switch (event->key()) {
179 switch (event->key()) {
180 case Qt::Key_Plus:
180 case Qt::Key_Plus:
181 zoomIn();
181 zoomIn();
182 break;
182 break;
183 case Qt::Key_Minus:
183 case Qt::Key_Minus:
184 zoomOut();
184 zoomOut();
185 break;
185 break;
186 default:
186 default:
187 QGraphicsView::keyPressEvent(event);
187 QGraphicsView::keyPressEvent(event);
188 break;
188 break;
189 }
189 }
190 }
190 }
191
191
192 void QChartView::setTheme(QChart::ChartThemeId theme)
192 void QChartView::setChartTheme(QChart::ChartTheme theme)
193 {
193 {
194 m_chart->setTheme(theme);
194 m_chart->setChartTheme(theme);
195 }
195 }
196
196
197 QChart::ChartTheme QChartView::chartTheme() const
198 {
199 return m_chart->chartTheme();
200 }
197
201
198 QTCOMMERCIALCHART_END_NAMESPACE
202 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,68 +1,69
1 #ifndef QCHARTWIDGET_H
1 #ifndef QCHARTWIDGET_H
2 #define QCHARTWIDGET_H
2 #define QCHARTWIDGET_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchartseries.h"
5 #include "qchartseries.h"
6 #include "qchart.h"
6 #include "qchart.h"
7 #include <QGraphicsView>
7 #include <QGraphicsView>
8
8
9 class QGraphicsScene;
9 class QGraphicsScene;
10 class QRubberBand;
10 class QRubberBand;
11
11
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13
13
14 class QChart;
14 class QChart;
15
15
16 class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView
16 class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView
17 {
17 {
18 public:
18 public:
19 enum RubberBandPolicy { NoRubberBand, VerticalRubberBand, HorizonalRubberBand, RectangleRubberBand };
19 enum RubberBandPolicy { NoRubberBand, VerticalRubberBand, HorizonalRubberBand, RectangleRubberBand };
20
20
21 explicit QChartView(QWidget *parent = 0);
21 explicit QChartView(QWidget *parent = 0);
22 ~QChartView();
22 ~QChartView();
23
23
24 //implement from QWidget
24 //implement from QWidget
25 void resizeEvent(QResizeEvent *event);
25 void resizeEvent(QResizeEvent *event);
26
26
27 void addSeries(QChartSeries* series);
27 void addSeries(QChartSeries* series);
28
28
29 // Convenience function
29 // Convenience function
30 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
30 QChartSeries* createSeries(QChartSeries::QChartSeriesType type);
31
31
32 int margin() const;
32 int margin() const;
33
33
34 void setTitle(const QString& title);
34 void setTitle(const QString& title);
35 void setChartBackgroundBrush(const QBrush& brush);
35 void setChartBackgroundBrush(const QBrush& brush);
36 void setChartBackgroundPen(const QPen& pen);
36 void setChartBackgroundPen(const QPen& pen);
37
37
38 void zoomInToRect(const QRect& rectangle);
38 void zoomInToRect(const QRect& rectangle);
39 void zoomIn();
39 void zoomIn();
40 void zoomOut();
40 void zoomOut();
41
41
42 void setRubberBandPolicy(const RubberBandPolicy );
42 void setRubberBandPolicy(const RubberBandPolicy );
43 RubberBandPolicy rubberBandPolicy() const;
43 RubberBandPolicy rubberBandPolicy() const;
44
44
45 void setTheme(QChart::ChartThemeId theme);
45 void setChartTheme(QChart::ChartTheme theme);
46 QChart::ChartTheme chartTheme() const;
46
47
47 protected:
48 protected:
48 void mousePressEvent(QMouseEvent *event);
49 void mousePressEvent(QMouseEvent *event);
49 void mouseMoveEvent(QMouseEvent *event);
50 void mouseMoveEvent(QMouseEvent *event);
50 void mouseReleaseEvent(QMouseEvent *event);
51 void mouseReleaseEvent(QMouseEvent *event);
51 void keyPressEvent(QKeyEvent *event);
52 void keyPressEvent(QKeyEvent *event);
52
53
53
54
54 private:
55 private:
55 QGraphicsScene *m_scene;
56 QGraphicsScene *m_scene;
56 QChart* m_chart;
57 QChart* m_chart;
57 QPoint m_rubberBandOrigin;
58 QPoint m_rubberBandOrigin;
58 QRubberBand* m_rubberBand;
59 QRubberBand* m_rubberBand;
59 bool m_verticalRubberBand;
60 bool m_verticalRubberBand;
60 bool m_horizonalRubberBand;
61 bool m_horizonalRubberBand;
61 Q_DISABLE_COPY(QChartView)
62 Q_DISABLE_COPY(QChartView)
62
63
63
64
64 };
65 };
65
66
66 QTCOMMERCIALCHART_END_NAMESPACE
67 QTCOMMERCIALCHART_END_NAMESPACE
67
68
68 #endif // QCHARTWIDGET_H
69 #endif // QCHARTWIDGET_H
@@ -1,20 +1,20
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeGrayscale: public ChartTheme
5 class ChartThemeGrayscale: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeGrayscale()
8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
9 {
9 {
10 m_seriesColor.append(QRgb(0xFF869299));
10 m_seriesColor.append(QRgb(0xFF869299));
11 m_seriesColor.append(QRgb(0xFFA5BDCC));
11 m_seriesColor.append(QRgb(0xFFA5BDCC));
12 m_seriesColor.append(QRgb(0xFFE8FFFC));
12 m_seriesColor.append(QRgb(0xFFE8FFFC));
13 m_seriesColor.append(QRgb(0xFFCCC2C2));
13 m_seriesColor.append(QRgb(0xFFCCC2C2));
14
14
15 m_gradientStartColor = QColor(QRgb(0xffffffff));
15 m_gradientStartColor = QColor(QRgb(0xffffffff));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
17 }
17 }
18 };
18 };
19
19
20 QTCOMMERCIALCHART_END_NAMESPACE
20 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,20 +1,20
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeIcy: public ChartTheme
5 class ChartThemeIcy: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeIcy()
8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
9 {
9 {
10 m_seriesColor.append(QRgb(0xFF0D2673));
10 m_seriesColor.append(QRgb(0xFF0D2673));
11 m_seriesColor.append(QRgb(0xFF2685BF));
11 m_seriesColor.append(QRgb(0xFF2685BF));
12 m_seriesColor.append(QRgb(0xFF3DADD9));
12 m_seriesColor.append(QRgb(0xFF3DADD9));
13 m_seriesColor.append(QRgb(0xFF62C3D9));
13 m_seriesColor.append(QRgb(0xFF62C3D9));
14
14
15 m_gradientStartColor = QColor(QRgb(0xffBDE3F2));
15 m_gradientStartColor = QColor(QRgb(0xffBDE3F2));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
17 }
17 }
18 };
18 };
19
19
20 QTCOMMERCIALCHART_END_NAMESPACE
20 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,20 +1,20
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeScientific: public ChartTheme
5 class ChartThemeScientific: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeScientific()
8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
9 {
9 {
10 m_seriesColor.append(QRgb(0xFF000000));
10 m_seriesColor.append(QRgb(0xFF000000));
11 m_seriesColor.append(QRgb(0xFFFFAD00));
11 m_seriesColor.append(QRgb(0xFFFFAD00));
12 m_seriesColor.append(QRgb(0xFF596A75));
12 m_seriesColor.append(QRgb(0xFF596A75));
13 m_seriesColor.append(QRgb(0xFF474747));
13 m_seriesColor.append(QRgb(0xFF474747));
14
14
15 m_gradientStartColor = QColor(QRgb(0xffafafaf));
15 m_gradientStartColor = QColor(QRgb(0xffafafaf));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
16 m_gradientEndColor = QColor(QRgb(0xffafafaf));
17 }
17 }
18 };
18 };
19
19
20 QTCOMMERCIALCHART_END_NAMESPACE
20 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,21 +1,21
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 class ChartThemeVanilla: public ChartTheme
5 class ChartThemeVanilla: public ChartTheme
6 {
6 {
7 public:
7 public:
8 ChartThemeVanilla()
8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
9 {
9 {
10 m_seriesColor.append(QColor(217, 197, 116));
10 m_seriesColor.append(QColor(217, 197, 116));
11 m_seriesColor.append(QColor(214, 168, 150));
11 m_seriesColor.append(QColor(214, 168, 150));
12 m_seriesColor.append(QColor(160, 160, 113));
12 m_seriesColor.append(QColor(160, 160, 113));
13 m_seriesColor.append(QColor(210, 210, 52));
13 m_seriesColor.append(QColor(210, 210, 52));
14 m_seriesColor.append(QColor(136, 114, 58));
14 m_seriesColor.append(QColor(136, 114, 58));
15
15
16 m_gradientStartColor = QColor(QRgb(0xff9d844d));
16 m_gradientStartColor = QColor(QRgb(0xff9d844d));
17 m_gradientEndColor = QColor(QRgb(0xffafafaf));
17 m_gradientEndColor = QColor(QRgb(0xffafafaf));
18 }
18 }
19 };
19 };
20
20
21 QTCOMMERCIALCHART_END_NAMESPACE
21 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now