@@ -1,40 +1,40 | |||||
1 | #include <QtGui/QApplication> |
|
1 | #include <QtGui/QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <qchartglobal.h> |
|
3 | #include <qchartglobal.h> | |
4 | #include <qchartview.h> |
|
4 | #include <qchartview.h> | |
5 | #include <qpieseries.h> |
|
5 | #include <qpieseries.h> | |
6 | #include <qpieslice.h> |
|
6 | #include <qpieslice.h> | |
7 | #include "customslice.h" |
|
7 | #include "customslice.h" | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | QTCOMMERCIALCHART_USE_NAMESPACE | |
10 |
|
10 | |||
11 | int main(int argc, char *argv[]) |
|
11 | int main(int argc, char *argv[]) | |
12 | { |
|
12 | { | |
13 | QApplication a(argc, argv); |
|
13 | QApplication a(argc, argv); | |
14 |
|
14 | |||
15 | QMainWindow window; |
|
15 | QMainWindow window; | |
16 |
|
16 | |||
17 | QPieSeries *series = new QPieSeries(); |
|
17 | QPieSeries *series = new QPieSeries(); | |
18 | series->add(5, "Slice 1"); |
|
18 | series->add(5, "Slice 1"); | |
19 | series->add(2, "Slice 2"); |
|
19 | series->add(2, "Slice 2"); | |
20 | series->add(3, "Slice 3"); |
|
20 | series->add(3, "Slice 3"); | |
21 | series->add(4, "Slice 4"); |
|
21 | series->add(4, "Slice 4"); | |
22 | series->add(5, "Slice 5"); |
|
22 | series->add(5, "Slice 5"); | |
23 | series->add(6, "Slice 6"); |
|
23 | series->add(6, "Slice 6"); | |
24 | series->add(7, "Slice 7"); |
|
24 | series->add(7, "Slice 7"); | |
25 | series->add(new CustomSlice(8)); |
|
25 | series->add(new CustomSlice(8)); | |
26 | series->enableClickExplodes(true); |
|
26 | series->enableClickExplodes(true); | |
27 | series->enableHoverHighlight(true); |
|
27 | series->enableHoverHighlight(true); | |
28 |
|
28 | |||
29 | QChartView* chartView = new QChartView(&window); |
|
29 | QChartView* chartView = new QChartView(&window); | |
30 | chartView->setRenderHint(QPainter::Antialiasing); |
|
30 | chartView->setRenderHint(QPainter::Antialiasing); | |
31 | chartView->addSeries(series); |
|
|||
32 | chartView->setChartTitle("simple piechart"); |
|
|||
33 | chartView->setChartTheme(QChart::ChartThemeIcy); |
|
31 | chartView->setChartTheme(QChart::ChartThemeIcy); | |
|
32 | chartView->setChartTitle("Simple piechart"); | |||
|
33 | chartView->addSeries(series); | |||
34 |
|
34 | |||
35 | window.setCentralWidget(chartView); |
|
35 | window.setCentralWidget(chartView); | |
36 | window.resize(600, 600); |
|
36 | window.resize(600, 600); | |
37 | window.show(); |
|
37 | window.show(); | |
38 |
|
38 | |||
39 | return a.exec(); |
|
39 | return a.exec(); | |
40 | } |
|
40 | } |
@@ -1,226 +1,241 | |||||
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 "qbarchartseries.h" |
|
7 | #include "qbarchartseries.h" | |
8 | #include "qstackedbarchartseries.h" |
|
8 | #include "qstackedbarchartseries.h" | |
9 | #include "qpercentbarchartseries.h" |
|
9 | #include "qpercentbarchartseries.h" | |
10 | #include "qlinechartseries.h" |
|
10 | #include "qlinechartseries.h" | |
11 | #include "qpieseries.h" |
|
11 | #include "qpieseries.h" | |
12 | #include "qscatterseries.h" |
|
12 | #include "qscatterseries.h" | |
13 | //items |
|
13 | //items | |
14 | #include "axisitem_p.h" |
|
14 | #include "axisitem_p.h" | |
15 | #include "barpresenter.h" |
|
15 | #include "barpresenter.h" | |
16 | #include "stackedbarpresenter.h" |
|
16 | #include "stackedbarpresenter.h" | |
17 | #include "linechartitem_p.h" |
|
17 | #include "linechartitem_p.h" | |
18 | #include "percentbarpresenter.h" |
|
18 | #include "percentbarpresenter.h" | |
19 | #include "linechartanimationitem_p.h" |
|
19 | #include "linechartanimationitem_p.h" | |
20 | #include "piepresenter.h" |
|
20 | #include "piepresenter.h" | |
21 | #include "scatterpresenter_p.h" |
|
21 | #include "scatterpresenter_p.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), |
|
25 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | |
26 | m_chart(chart), |
|
26 | m_chart(chart), | |
27 | m_dataset(dataset), |
|
27 | m_dataset(dataset), | |
28 | m_chartTheme(0), |
|
28 | m_chartTheme(0), | |
29 | m_marginSize(0), |
|
29 | m_marginSize(0), | |
30 | m_rect(QRectF(QPoint(0,0),m_chart->size())) |
|
30 | m_rect(QRectF(QPoint(0,0),m_chart->size())) | |
31 | { |
|
31 | { | |
32 | createConnections(); |
|
32 | createConnections(); | |
33 | setChartTheme(QChart::ChartThemeDefault); |
|
33 | setChartTheme(QChart::ChartThemeDefault); | |
34 |
|
34 | |||
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | ChartPresenter::~ChartPresenter() |
|
37 | ChartPresenter::~ChartPresenter() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | void ChartPresenter::createConnections() |
|
41 | void ChartPresenter::createConnections() | |
42 | { |
|
42 | { | |
43 | QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged())); |
|
43 | QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged())); | |
44 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*))); |
|
44 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*))); | |
45 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*))); |
|
45 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*))); | |
46 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*))); |
|
46 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*))); | |
47 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); |
|
47 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); | |
48 | QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&))); |
|
48 | QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&))); | |
49 | QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&))); |
|
49 | QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&))); | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | QRectF ChartPresenter::geometry() const |
|
53 | QRectF ChartPresenter::geometry() const | |
54 | { |
|
54 | { | |
55 | return m_rect; |
|
55 | return m_rect; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void ChartPresenter::handleGeometryChanged() |
|
58 | void ChartPresenter::handleGeometryChanged() | |
59 | { |
|
59 | { | |
60 | m_rect = QRectF(QPoint(0,0),m_chart->size()); |
|
60 | m_rect = QRectF(QPoint(0,0),m_chart->size()); | |
61 | m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize); |
|
61 | m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize); | |
62 | Q_ASSERT(m_rect.isValid()); |
|
62 | Q_ASSERT(m_rect.isValid()); | |
63 | emit geometryChanged(m_rect); |
|
63 | emit geometryChanged(m_rect); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | int ChartPresenter::margin() const |
|
66 | int ChartPresenter::margin() const | |
67 | { |
|
67 | { | |
68 | return m_marginSize; |
|
68 | return m_marginSize; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void ChartPresenter::setMargin(int margin) |
|
71 | void ChartPresenter::setMargin(int margin) | |
72 | { |
|
72 | { | |
73 | m_marginSize = margin; |
|
73 | m_marginSize = margin; | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void ChartPresenter::handleAxisAdded(QChartAxis* axis) |
|
76 | void ChartPresenter::handleAxisAdded(QChartAxis* axis) | |
77 | { |
|
77 | { | |
78 | AxisItem* item ; |
|
78 | AxisItem* item ; | |
79 |
|
79 | |||
80 | if(axis==m_dataset->axisX()){ |
|
80 | if(axis==m_dataset->axisX()){ | |
81 | item = new AxisItem(AxisItem::X_AXIS,m_chart); |
|
81 | item = new AxisItem(AxisItem::X_AXIS,m_chart); | |
82 | }else{ |
|
82 | }else{ | |
83 | item = new AxisItem(AxisItem::Y_AXIS,m_chart); |
|
83 | item = new AxisItem(AxisItem::Y_AXIS,m_chart); | |
84 | } |
|
84 | } | |
85 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
85 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
86 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); |
|
86 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); | |
87 |
|
87 | |||
88 | item->handleAxisUpdate(axis); |
|
88 | item->handleAxisUpdate(axis); | |
89 | item->handleGeometryChanged(m_rect); |
|
89 | item->handleGeometryChanged(m_rect); | |
90 | m_chartTheme->decorate(axis,item); |
|
90 | m_chartTheme->decorate(axis,item); | |
91 | m_axisItems.insert(axis,item); |
|
91 | m_axisItems.insert(axis,item); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) |
|
94 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) | |
95 | { |
|
95 | { | |
96 | AxisItem* item = m_axisItems.take(axis); |
|
96 | AxisItem* item = m_axisItems.take(axis); | |
97 | Q_ASSERT(item); |
|
97 | Q_ASSERT(item); | |
98 | delete item; |
|
98 | delete item; | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | void ChartPresenter::handleSeriesAdded(QChartSeries* series) |
|
102 | void ChartPresenter::handleSeriesAdded(QChartSeries* series) | |
103 | { |
|
103 | { | |
104 | switch(series->type()) |
|
104 | switch(series->type()) | |
105 | { |
|
105 | { | |
106 | case QChartSeries::SeriesTypeLine: { |
|
106 | case QChartSeries::SeriesTypeLine: { | |
107 | QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series); |
|
107 | QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series); | |
108 | LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); |
|
108 | LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); | |
109 | m_chartTheme->decorate(item,lineSeries,m_chartItems.count()); |
|
109 | m_chartTheme->decorate(item,lineSeries,m_chartItems.count()); | |
110 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
110 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
111 | QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
111 | QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
112 | m_chartItems.insert(series,item); |
|
112 | m_chartItems.insert(series,item); | |
113 | break; |
|
113 | break; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | case QChartSeries::SeriesTypeBar: { |
|
116 | case QChartSeries::SeriesTypeBar: { | |
117 | QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series); |
|
117 | QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series); | |
118 | BarPresenter* item = new BarPresenter(barSeries,m_chart); |
|
118 | BarPresenter* item = new BarPresenter(barSeries,m_chart); | |
119 | m_chartTheme->decorate(item,barSeries,m_chartItems.count()); |
|
119 | m_chartTheme->decorate(item,barSeries,m_chartItems.count()); | |
120 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
120 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
121 | QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
121 | QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
122 | m_chartItems.insert(series,item); |
|
122 | m_chartItems.insert(series,item); | |
123 | // m_axisXItem->setVisible(false); |
|
123 | // m_axisXItem->setVisible(false); | |
124 | break; |
|
124 | break; | |
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | case QChartSeries::SeriesTypeStackedBar: { |
|
127 | case QChartSeries::SeriesTypeStackedBar: { | |
128 |
|
128 | |||
129 | QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series); |
|
129 | QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series); | |
130 | StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries,m_chart); |
|
130 | StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries,m_chart); | |
131 | m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count()); |
|
131 | m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count()); | |
132 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
132 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
133 | QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
133 | QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
134 | m_chartItems.insert(series,item); |
|
134 | m_chartItems.insert(series,item); | |
135 | break; |
|
135 | break; | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | case QChartSeries::SeriesTypePercentBar: { |
|
138 | case QChartSeries::SeriesTypePercentBar: { | |
139 |
|
139 | |||
140 | QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series); |
|
140 | QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series); | |
141 | PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries,m_chart); |
|
141 | PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries,m_chart); | |
142 | m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count()); |
|
142 | m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count()); | |
143 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
143 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
144 | QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
144 | QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
145 | m_chartItems.insert(series,item); |
|
145 | m_chartItems.insert(series,item); | |
146 | break; |
|
146 | break; | |
147 | } |
|
147 | } | |
148 | case QChartSeries::SeriesTypeScatter: { |
|
148 | case QChartSeries::SeriesTypeScatter: { | |
149 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); |
|
149 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); | |
150 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); |
|
150 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); | |
151 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), |
|
151 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), | |
152 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); |
|
152 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); | |
153 | m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count()); |
|
153 | m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count()); | |
154 | m_chartItems.insert(scatterSeries, scatterPresenter); |
|
154 | m_chartItems.insert(scatterSeries, scatterPresenter); | |
155 | break; |
|
155 | break; | |
156 | } |
|
156 | } | |
157 | case QChartSeries::SeriesTypePie: { |
|
157 | case QChartSeries::SeriesTypePie: { | |
158 | QPieSeries *s = qobject_cast<QPieSeries *>(series); |
|
158 | QPieSeries *s = qobject_cast<QPieSeries *>(series); | |
159 | PiePresenter* pie = new PiePresenter(m_chart, s); |
|
159 | PiePresenter* pie = new PiePresenter(m_chart, s); | |
160 | m_chartTheme->decorate(pie, s, m_chartItems.count()); |
|
160 | m_chartTheme->decorate(pie, s, m_chartItems.count()); | |
161 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&))); |
|
161 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&))); | |
|
162 | ||||
|
163 | // Hide all from background when there is only piechart | |||
|
164 | // TODO: refactor this ugly code... should be one setting for this | |||
|
165 | if (m_chartItems.count() == 0) { | |||
|
166 | m_chart->axisX()->setAxisVisible(false); | |||
|
167 | m_chart->axisY()->setAxisVisible(false); | |||
|
168 | m_chart->axisX()->setGridVisible(false); | |||
|
169 | m_chart->axisY()->setGridVisible(false); | |||
|
170 | m_chart->axisX()->setLabelsVisible(false); | |||
|
171 | m_chart->axisY()->setLabelsVisible(false); | |||
|
172 | m_chart->axisX()->setShadesVisible(false); | |||
|
173 | m_chart->axisY()->setShadesVisible(false); | |||
|
174 | m_chart->setChartBackgroundBrush(Qt::transparent); | |||
|
175 | } | |||
|
176 | ||||
162 | m_chartItems.insert(series, pie); |
|
177 | m_chartItems.insert(series, pie); | |
163 | break; |
|
178 | break; | |
164 | } |
|
179 | } | |
165 | default: { |
|
180 | default: { | |
166 | qDebug()<< "Series type" << series->type() << "not implemented."; |
|
181 | qDebug()<< "Series type" << series->type() << "not implemented."; | |
167 | break; |
|
182 | break; | |
168 | } |
|
183 | } | |
169 | } |
|
184 | } | |
170 |
|
185 | |||
171 | if(m_rect.isValid()) emit geometryChanged(m_rect); |
|
186 | if(m_rect.isValid()) emit geometryChanged(m_rect); | |
172 | } |
|
187 | } | |
173 |
|
188 | |||
174 | void ChartPresenter::handleSeriesRemoved(QChartSeries* series) |
|
189 | void ChartPresenter::handleSeriesRemoved(QChartSeries* series) | |
175 | { |
|
190 | { | |
176 | ChartItem* item = m_chartItems.take(series); |
|
191 | ChartItem* item = m_chartItems.take(series); | |
177 | delete item; |
|
192 | delete item; | |
178 | } |
|
193 | } | |
179 |
|
194 | |||
180 | void ChartPresenter::handleSeriesChanged(QChartSeries* series) |
|
195 | void ChartPresenter::handleSeriesChanged(QChartSeries* series) | |
181 | { |
|
196 | { | |
182 | //TODO: |
|
197 | //TODO: | |
183 | } |
|
198 | } | |
184 |
|
199 | |||
185 | void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain) |
|
200 | void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain) | |
186 | { |
|
201 | { | |
187 | m_chartItems.value(series)->handleDomainChanged(domain); |
|
202 | m_chartItems.value(series)->handleDomainChanged(domain); | |
188 | } |
|
203 | } | |
189 |
|
204 | |||
190 | void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels) |
|
205 | void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels) | |
191 | { |
|
206 | { | |
192 | m_axisItems.value(axis)->handleLabelsChanged(axis,labels); |
|
207 | m_axisItems.value(axis)->handleLabelsChanged(axis,labels); | |
193 | } |
|
208 | } | |
194 |
|
209 | |||
195 | void ChartPresenter::setChartTheme(QChart::ChartTheme theme) |
|
210 | void ChartPresenter::setChartTheme(QChart::ChartTheme theme) | |
196 | { |
|
211 | { | |
197 | delete m_chartTheme; |
|
212 | delete m_chartTheme; | |
198 |
|
213 | |||
199 | m_chartTheme = ChartTheme::createTheme(theme); |
|
214 | m_chartTheme = ChartTheme::createTheme(theme); | |
200 |
|
215 | |||
201 | m_chartTheme->decorate(m_chart); |
|
216 | m_chartTheme->decorate(m_chart); | |
202 | QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems); |
|
217 | QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems); | |
203 |
|
218 | |||
204 | int index=0; |
|
219 | int index=0; | |
205 | while (i.hasNext()) { |
|
220 | while (i.hasNext()) { | |
206 | i.next(); |
|
221 | i.next(); | |
207 | index++; |
|
222 | index++; | |
208 | m_chartTheme->decorate(i.value(),i.key(),index); |
|
223 | m_chartTheme->decorate(i.value(),i.key(),index); | |
209 | } |
|
224 | } | |
210 |
|
225 | |||
211 | QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems); |
|
226 | QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems); | |
212 | while (j.hasNext()) { |
|
227 | while (j.hasNext()) { | |
213 | j.next(); |
|
228 | j.next(); | |
214 | m_chartTheme->decorate(j.key(),j.value()); |
|
229 | m_chartTheme->decorate(j.key(),j.value()); | |
215 | } |
|
230 | } | |
216 | } |
|
231 | } | |
217 |
|
232 | |||
218 | QChart::ChartTheme ChartPresenter::chartTheme() |
|
233 | QChart::ChartTheme ChartPresenter::chartTheme() | |
219 | { |
|
234 | { | |
220 | return m_chartTheme->id(); |
|
235 | return m_chartTheme->id(); | |
221 | } |
|
236 | } | |
222 |
|
237 | |||
223 |
|
238 | |||
224 | #include "moc_chartpresenter_p.cpp" |
|
239 | #include "moc_chartpresenter_p.cpp" | |
225 |
|
240 | |||
226 | QTCOMMERCIALCHART_END_NAMESPACE |
|
241 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now