@@ -1,374 +1,374 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "themewidget.h" |
|
21 | #include "themewidget.h" | |
22 |
|
22 | |||
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QPieSeries> |
|
24 | #include <QPieSeries> | |
25 | #include <QPieSlice> |
|
25 | #include <QPieSlice> | |
26 | #include <QBarSeries> |
|
26 | #include <QBarSeries> | |
27 | #include <QPercentBarSeries> |
|
27 | #include <QPercentBarSeries> | |
28 | #include <QStackedBarSeries> |
|
28 | #include <QStackedBarSeries> | |
29 | #include <QBarSet> |
|
29 | #include <QBarSet> | |
30 | #include <QLineSeries> |
|
30 | #include <QLineSeries> | |
31 | #include <QSplineSeries> |
|
31 | #include <QSplineSeries> | |
32 | #include <QScatterSeries> |
|
32 | #include <QScatterSeries> | |
33 | #include <QAreaSeries> |
|
33 | #include <QAreaSeries> | |
34 | #include <QLegend> |
|
34 | #include <QLegend> | |
35 | #include <QGridLayout> |
|
35 | #include <QGridLayout> | |
36 | #include <QFormLayout> |
|
36 | #include <QFormLayout> | |
37 | #include <QComboBox> |
|
37 | #include <QComboBox> | |
38 | #include <QSpinBox> |
|
38 | #include <QSpinBox> | |
39 | #include <QCheckBox> |
|
39 | #include <QCheckBox> | |
40 | #include <QGroupBox> |
|
40 | #include <QGroupBox> | |
41 | #include <QLabel> |
|
41 | #include <QLabel> | |
42 | #include <QTime> |
|
42 | #include <QTime> | |
43 |
|
43 | |||
44 | ThemeWidget::ThemeWidget(QWidget* parent) : |
|
44 | ThemeWidget::ThemeWidget(QWidget* parent) : | |
45 | QWidget(parent), |
|
45 | QWidget(parent), | |
46 | m_listCount(3), |
|
46 | m_listCount(3), | |
47 | m_valueMax(10), |
|
47 | m_valueMax(10), | |
48 | m_valueCount(7), |
|
48 | m_valueCount(7), | |
49 | m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)), |
|
49 | m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)), | |
50 | m_themeComboBox(createThemeBox()), |
|
50 | m_themeComboBox(createThemeBox()), | |
51 | m_antialiasCheckBox(new QCheckBox("Anti-aliasing")), |
|
51 | m_antialiasCheckBox(new QCheckBox("Anti-aliasing")), | |
52 | m_animatedComboBox(createAnimationBox()), |
|
52 | m_animatedComboBox(createAnimationBox()), | |
53 | m_legendComboBox(createLegendBox()) |
|
53 | m_legendComboBox(createLegendBox()) | |
54 | { |
|
54 | { | |
55 | connectSignals(); |
|
55 | connectSignals(); | |
56 | // create layout |
|
56 | // create layout | |
57 | QGridLayout* baseLayout = new QGridLayout(); |
|
57 | QGridLayout* baseLayout = new QGridLayout(); | |
58 | QHBoxLayout *settingsLayout = new QHBoxLayout(); |
|
58 | QHBoxLayout *settingsLayout = new QHBoxLayout(); | |
59 | settingsLayout->addWidget(new QLabel("Theme:")); |
|
59 | settingsLayout->addWidget(new QLabel("Theme:")); | |
60 | settingsLayout->addWidget(m_themeComboBox); |
|
60 | settingsLayout->addWidget(m_themeComboBox); | |
61 | settingsLayout->addWidget(new QLabel("Animation:")); |
|
61 | settingsLayout->addWidget(new QLabel("Animation:")); | |
62 | settingsLayout->addWidget(m_animatedComboBox); |
|
62 | settingsLayout->addWidget(m_animatedComboBox); | |
63 | settingsLayout->addWidget(new QLabel("Legend:")); |
|
63 | settingsLayout->addWidget(new QLabel("Legend:")); | |
64 | settingsLayout->addWidget(m_legendComboBox); |
|
64 | settingsLayout->addWidget(m_legendComboBox); | |
65 | settingsLayout->addWidget(m_antialiasCheckBox); |
|
65 | settingsLayout->addWidget(m_antialiasCheckBox); | |
66 | settingsLayout->addStretch(); |
|
66 | settingsLayout->addStretch(); | |
67 | baseLayout->addLayout(settingsLayout, 0, 0, 1, 3); |
|
67 | baseLayout->addLayout(settingsLayout, 0, 0, 1, 3); | |
68 |
|
68 | |||
69 | //create charts |
|
69 | //create charts | |
70 |
|
70 | |||
71 | QChartView *chartView; |
|
71 | QChartView *chartView; | |
72 |
|
72 | |||
73 | chartView = new QChartView(createAreaChart()); |
|
73 | chartView = new QChartView(createAreaChart()); | |
74 | baseLayout->addWidget(chartView, 1, 0); |
|
74 | baseLayout->addWidget(chartView, 1, 0); | |
75 | m_charts << chartView; |
|
75 | m_charts << chartView; | |
76 |
|
76 | |||
77 | chartView = new QChartView(createBarChart(m_valueCount)); |
|
77 | chartView = new QChartView(createBarChart(m_valueCount)); | |
78 | baseLayout->addWidget(chartView, 1, 1); |
|
78 | baseLayout->addWidget(chartView, 1, 1); | |
79 | m_charts << chartView; |
|
79 | m_charts << chartView; | |
80 |
|
80 | |||
81 | chartView = new QChartView(createLineChart()); |
|
81 | chartView = new QChartView(createLineChart()); | |
82 | baseLayout->addWidget(chartView, 1, 2); |
|
82 | baseLayout->addWidget(chartView, 1, 2); | |
83 | m_charts << chartView; |
|
83 | m_charts << chartView; | |
84 |
|
84 | |||
85 | chartView = new QChartView(createPieChart()); |
|
85 | chartView = new QChartView(createPieChart()); | |
86 | chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen... |
|
86 | chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen... | |
87 | baseLayout->addWidget(chartView, 2, 0); |
|
87 | baseLayout->addWidget(chartView, 2, 0); | |
88 | m_charts << chartView; |
|
88 | m_charts << chartView; | |
89 |
|
89 | |||
90 | chartView = new QChartView(createSplineChart()); |
|
90 | chartView = new QChartView(createSplineChart()); | |
91 | baseLayout->addWidget(chartView, 2, 1); |
|
91 | baseLayout->addWidget(chartView, 2, 1); | |
92 | m_charts << chartView; |
|
92 | m_charts << chartView; | |
93 |
|
93 | |||
94 | chartView = new QChartView(createScatterChart()); |
|
94 | chartView = new QChartView(createScatterChart()); | |
95 | baseLayout->addWidget(chartView, 2, 2); |
|
95 | baseLayout->addWidget(chartView, 2, 2); | |
96 | m_charts << chartView; |
|
96 | m_charts << chartView; | |
97 |
|
97 | |||
98 | setLayout(baseLayout); |
|
98 | setLayout(baseLayout); | |
99 |
|
99 | |||
100 | // Set defaults |
|
100 | // Set defaults | |
101 | m_antialiasCheckBox->setChecked(true); |
|
101 | m_antialiasCheckBox->setChecked(true); | |
102 | updateUI(); |
|
102 | updateUI(); | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | ThemeWidget::~ThemeWidget() |
|
105 | ThemeWidget::~ThemeWidget() | |
106 | { |
|
106 | { | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | void ThemeWidget::connectSignals() |
|
109 | void ThemeWidget::connectSignals() | |
110 | { |
|
110 | { | |
111 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
111 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
112 | connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); |
|
112 | connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); | |
113 | connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
113 | connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
114 | connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); |
|
114 | connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const |
|
117 | DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const | |
118 | { |
|
118 | { | |
119 | DataTable dataTable; |
|
119 | DataTable dataTable; | |
120 |
|
120 | |||
121 | // set seed for random stuff |
|
121 | // set seed for random stuff | |
122 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); |
|
122 | qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); | |
123 |
|
123 | |||
124 | // generate random data |
|
124 | // generate random data | |
125 | for (int i(0); i < listCount; i++) { |
|
125 | for (int i(0); i < listCount; i++) { | |
126 | DataList dataList; |
|
126 | DataList dataList; | |
127 | qreal yValue(0); |
|
127 | qreal yValue(0); | |
128 | for (int j(0); j < valueCount; j++) { |
|
128 | for (int j(0); j < valueCount; j++) { | |
129 | yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; |
|
129 | yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; | |
130 | QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount), |
|
130 | QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount), | |
131 | yValue); |
|
131 | yValue); | |
132 | QString label = "Slice " + QString::number(i) + ":" + QString::number(j); |
|
132 | QString label = "Slice " + QString::number(i) + ":" + QString::number(j); | |
133 | dataList << Data(value, label); |
|
133 | dataList << Data(value, label); | |
134 | } |
|
134 | } | |
135 | dataTable << dataList; |
|
135 | dataTable << dataList; | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | return dataTable; |
|
138 | return dataTable; | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | QComboBox* ThemeWidget::createThemeBox() const |
|
141 | QComboBox* ThemeWidget::createThemeBox() const | |
142 | { |
|
142 | { | |
143 | // settings layout |
|
143 | // settings layout | |
144 | QComboBox* themeComboBox = new QComboBox(); |
|
144 | QComboBox* themeComboBox = new QComboBox(); | |
145 | themeComboBox->addItem("Light", QChart::ChartThemeLight); |
|
145 | themeComboBox->addItem("Light", QChart::ChartThemeLight); | |
146 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); |
|
146 | themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); | |
147 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); |
|
147 | themeComboBox->addItem("Dark", QChart::ChartThemeDark); | |
148 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); |
|
148 | themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); | |
149 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); |
|
149 | themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); | |
150 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); |
|
150 | themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); | |
151 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); |
|
151 | themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); | |
152 | return themeComboBox; |
|
152 | return themeComboBox; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | QComboBox* ThemeWidget::createAnimationBox() const |
|
155 | QComboBox* ThemeWidget::createAnimationBox() const | |
156 | { |
|
156 | { | |
157 | // settings layout |
|
157 | // settings layout | |
158 | QComboBox* animationComboBox = new QComboBox(); |
|
158 | QComboBox* animationComboBox = new QComboBox(); | |
159 | animationComboBox->addItem("No Animations", QChart::NoAnimation); |
|
159 | animationComboBox->addItem("No Animations", QChart::NoAnimation); | |
160 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); |
|
160 | animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); | |
161 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); |
|
161 | animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); | |
162 | animationComboBox->addItem("All Animations", QChart::AllAnimations); |
|
162 | animationComboBox->addItem("All Animations", QChart::AllAnimations); | |
163 | return animationComboBox; |
|
163 | return animationComboBox; | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | QComboBox* ThemeWidget::createLegendBox() const |
|
166 | QComboBox* ThemeWidget::createLegendBox() const | |
167 | { |
|
167 | { | |
168 | QComboBox* legendComboBox = new QComboBox(); |
|
168 | QComboBox* legendComboBox = new QComboBox(); | |
169 | legendComboBox->addItem("No Legend ", 0); |
|
169 | legendComboBox->addItem("No Legend ", 0); | |
170 | legendComboBox->addItem("Legend Top", QLegend::AlignmentTop); |
|
170 | legendComboBox->addItem("Legend Top", QLegend::AlignmentTop); | |
171 | legendComboBox->addItem("Legend Bottom", QLegend::AlignmentBottom); |
|
171 | legendComboBox->addItem("Legend Bottom", QLegend::AlignmentBottom); | |
172 | legendComboBox->addItem("Legend Left", QLegend::AlignmentLeft); |
|
172 | legendComboBox->addItem("Legend Left", QLegend::AlignmentLeft); | |
173 | legendComboBox->addItem("Legend Right", QLegend::AlignmentRight); |
|
173 | legendComboBox->addItem("Legend Right", QLegend::AlignmentRight); | |
174 | return legendComboBox; |
|
174 | return legendComboBox; | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | QChart* ThemeWidget::createAreaChart() const |
|
177 | QChart* ThemeWidget::createAreaChart() const | |
178 | { |
|
178 | { | |
179 | QChart *chart = new QChart(); |
|
179 | QChart *chart = new QChart(); | |
180 | chart->axisX()->setNiceNumbers(true); |
|
180 | chart->axisX()->setNiceNumbersEnabled(true); | |
181 | chart->axisY()->setNiceNumbers(true); |
|
181 | chart->axisY()->setNiceNumbersEnabled(true); | |
182 | chart->setTitle("Area chart"); |
|
182 | chart->setTitle("Area chart"); | |
183 |
|
183 | |||
184 | // The lower series initialized to zero values |
|
184 | // The lower series initialized to zero values | |
185 | QLineSeries *lowerSeries = 0; |
|
185 | QLineSeries *lowerSeries = 0; | |
186 | QString name("Series "); |
|
186 | QString name("Series "); | |
187 | int nameIndex = 0; |
|
187 | int nameIndex = 0; | |
188 | for (int i(0); i < m_dataTable.count(); i++) { |
|
188 | for (int i(0); i < m_dataTable.count(); i++) { | |
189 | QLineSeries *upperSeries = new QLineSeries(chart); |
|
189 | QLineSeries *upperSeries = new QLineSeries(chart); | |
190 | for (int j(0); j < m_dataTable[i].count(); j++) { |
|
190 | for (int j(0); j < m_dataTable[i].count(); j++) { | |
191 | Data data = m_dataTable[i].at(j); |
|
191 | Data data = m_dataTable[i].at(j); | |
192 | if (lowerSeries) |
|
192 | if (lowerSeries) | |
193 | upperSeries->append(QPointF(j, lowerSeries->y(i) + data.first.y())); |
|
193 | upperSeries->append(QPointF(j, lowerSeries->y(i) + data.first.y())); | |
194 | else |
|
194 | else | |
195 | upperSeries->append(QPointF(j, data.first.y())); |
|
195 | upperSeries->append(QPointF(j, data.first.y())); | |
196 | } |
|
196 | } | |
197 | QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); |
|
197 | QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); | |
198 | area->setName(name + QString::number(nameIndex)); |
|
198 | area->setName(name + QString::number(nameIndex)); | |
199 | nameIndex++; |
|
199 | nameIndex++; | |
200 | chart->addSeries(area); |
|
200 | chart->addSeries(area); | |
201 | lowerSeries = upperSeries; |
|
201 | lowerSeries = upperSeries; | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | return chart; |
|
204 | return chart; | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | QChart* ThemeWidget::createBarChart(int valueCount) const |
|
207 | QChart* ThemeWidget::createBarChart(int valueCount) const | |
208 | { |
|
208 | { | |
209 | QChart* chart = new QChart(); |
|
209 | QChart* chart = new QChart(); | |
210 | chart->axisX()->setNiceNumbers(true); |
|
210 | chart->axisX()->setNiceNumbersEnabled(true); | |
211 | chart->axisY()->setNiceNumbers(true); |
|
211 | chart->axisY()->setNiceNumbersEnabled(true); | |
212 | chart->setTitle("Bar chart"); |
|
212 | chart->setTitle("Bar chart"); | |
213 |
|
213 | |||
214 | QBarCategories categories; |
|
214 | QBarCategories categories; | |
215 | for (int i(0); i < valueCount; i++) |
|
215 | for (int i(0); i < valueCount; i++) | |
216 | categories << QString::number(i); |
|
216 | categories << QString::number(i); | |
217 |
|
217 | |||
218 | QStackedBarSeries* series = new QStackedBarSeries(categories, chart); |
|
218 | QStackedBarSeries* series = new QStackedBarSeries(categories, chart); | |
219 | for (int i(0); i < m_dataTable.count(); i++) { |
|
219 | for (int i(0); i < m_dataTable.count(); i++) { | |
220 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); |
|
220 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
221 | foreach (Data data, m_dataTable[i]) |
|
221 | foreach (Data data, m_dataTable[i]) | |
222 | *set << data.first.y(); |
|
222 | *set << data.first.y(); | |
223 | series->appendBarSet(set); |
|
223 | series->appendBarSet(set); | |
224 | } |
|
224 | } | |
225 | chart->addSeries(series); |
|
225 | chart->addSeries(series); | |
226 |
|
226 | |||
227 | return chart; |
|
227 | return chart; | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | QChart* ThemeWidget::createLineChart() const |
|
230 | QChart* ThemeWidget::createLineChart() const | |
231 | { |
|
231 | { | |
232 | QChart* chart = new QChart(); |
|
232 | QChart* chart = new QChart(); | |
233 | chart->axisX()->setNiceNumbers(true); |
|
233 | chart->axisX()->setNiceNumbersEnabled(true); | |
234 | chart->axisY()->setNiceNumbers(true); |
|
234 | chart->axisY()->setNiceNumbersEnabled(true); | |
235 | chart->setTitle("Line chart"); |
|
235 | chart->setTitle("Line chart"); | |
236 |
|
236 | |||
237 | QString name("Series "); |
|
237 | QString name("Series "); | |
238 | int nameIndex = 0; |
|
238 | int nameIndex = 0; | |
239 | foreach (DataList list, m_dataTable) { |
|
239 | foreach (DataList list, m_dataTable) { | |
240 | QLineSeries *series = new QLineSeries(chart); |
|
240 | QLineSeries *series = new QLineSeries(chart); | |
241 | foreach (Data data, list) |
|
241 | foreach (Data data, list) | |
242 | series->append(data.first); |
|
242 | series->append(data.first); | |
243 | series->setName(name + QString::number(nameIndex)); |
|
243 | series->setName(name + QString::number(nameIndex)); | |
244 | nameIndex++; |
|
244 | nameIndex++; | |
245 | chart->addSeries(series); |
|
245 | chart->addSeries(series); | |
246 | } |
|
246 | } | |
247 |
|
247 | |||
248 | return chart; |
|
248 | return chart; | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | QChart* ThemeWidget::createPieChart() const |
|
251 | QChart* ThemeWidget::createPieChart() const | |
252 | { |
|
252 | { | |
253 | QChart* chart = new QChart(); |
|
253 | QChart* chart = new QChart(); | |
254 | chart->setTitle("Pie chart"); |
|
254 | chart->setTitle("Pie chart"); | |
255 |
|
255 | |||
256 | qreal pieSize = 1.0 / m_dataTable.count(); |
|
256 | qreal pieSize = 1.0 / m_dataTable.count(); | |
257 | for (int i = 0; i < m_dataTable.count(); i++) { |
|
257 | for (int i = 0; i < m_dataTable.count(); i++) { | |
258 | QPieSeries *series = new QPieSeries(chart); |
|
258 | QPieSeries *series = new QPieSeries(chart); | |
259 | foreach (Data data, m_dataTable[i]) { |
|
259 | foreach (Data data, m_dataTable[i]) { | |
260 | QPieSlice *slice = series->append(data.first.y(), data.second); |
|
260 | QPieSlice *slice = series->append(data.first.y(), data.second); | |
261 | if (data == m_dataTable[i].first()) { |
|
261 | if (data == m_dataTable[i].first()) { | |
262 | slice->setLabelVisible(); |
|
262 | slice->setLabelVisible(); | |
263 | slice->setExploded(); |
|
263 | slice->setExploded(); | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 | qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count()); |
|
266 | qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count()); | |
267 | series->setPieSize(pieSize); |
|
267 | series->setPieSize(pieSize); | |
268 | series->setHorizontalPosition(hPos); |
|
268 | series->setHorizontalPosition(hPos); | |
269 | series->setVerticalPosition(0.5); |
|
269 | series->setVerticalPosition(0.5); | |
270 | chart->addSeries(series); |
|
270 | chart->addSeries(series); | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | return chart; |
|
273 | return chart; | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | QChart* ThemeWidget::createSplineChart() const |
|
276 | QChart* ThemeWidget::createSplineChart() const | |
277 | { // spine chart |
|
277 | { // spine chart | |
278 | QChart* chart = new QChart(); |
|
278 | QChart* chart = new QChart(); | |
279 | chart->axisX()->setNiceNumbers(true); |
|
279 | chart->axisX()->setNiceNumbersEnabled(true); | |
280 | chart->axisY()->setNiceNumbers(true); |
|
280 | chart->axisY()->setNiceNumbersEnabled(true); | |
281 | chart->setTitle("Spline chart"); |
|
281 | chart->setTitle("Spline chart"); | |
282 | QString name("Series "); |
|
282 | QString name("Series "); | |
283 | int nameIndex = 0; |
|
283 | int nameIndex = 0; | |
284 | foreach (DataList list, m_dataTable) { |
|
284 | foreach (DataList list, m_dataTable) { | |
285 | QSplineSeries *series = new QSplineSeries(chart); |
|
285 | QSplineSeries *series = new QSplineSeries(chart); | |
286 | foreach (Data data, list) |
|
286 | foreach (Data data, list) | |
287 | series->append(data.first); |
|
287 | series->append(data.first); | |
288 | series->setName(name + QString::number(nameIndex)); |
|
288 | series->setName(name + QString::number(nameIndex)); | |
289 | nameIndex++; |
|
289 | nameIndex++; | |
290 | chart->addSeries(series); |
|
290 | chart->addSeries(series); | |
291 | } |
|
291 | } | |
292 | return chart; |
|
292 | return chart; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | QChart* ThemeWidget::createScatterChart() const |
|
295 | QChart* ThemeWidget::createScatterChart() const | |
296 | { // scatter chart |
|
296 | { // scatter chart | |
297 | QChart* chart = new QChart(); |
|
297 | QChart* chart = new QChart(); | |
298 | chart->axisX()->setNiceNumbers(true); |
|
298 | chart->axisX()->setNiceNumbersEnabled(true); | |
299 | chart->axisY()->setNiceNumbers(true); |
|
299 | chart->axisY()->setNiceNumbersEnabled(true); | |
300 | chart->setTitle("Scatter chart"); |
|
300 | chart->setTitle("Scatter chart"); | |
301 | QString name("Series "); |
|
301 | QString name("Series "); | |
302 | int nameIndex = 0; |
|
302 | int nameIndex = 0; | |
303 | foreach (DataList list, m_dataTable) { |
|
303 | foreach (DataList list, m_dataTable) { | |
304 | QScatterSeries *series = new QScatterSeries(chart); |
|
304 | QScatterSeries *series = new QScatterSeries(chart); | |
305 | foreach (Data data, list) |
|
305 | foreach (Data data, list) | |
306 | series->append(data.first); |
|
306 | series->append(data.first); | |
307 | series->setName(name + QString::number(nameIndex)); |
|
307 | series->setName(name + QString::number(nameIndex)); | |
308 | nameIndex++; |
|
308 | nameIndex++; | |
309 | chart->addSeries(series); |
|
309 | chart->addSeries(series); | |
310 | } |
|
310 | } | |
311 | return chart; |
|
311 | return chart; | |
312 | } |
|
312 | } | |
313 |
|
313 | |||
314 | void ThemeWidget::updateUI() |
|
314 | void ThemeWidget::updateUI() | |
315 | { |
|
315 | { | |
316 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); |
|
316 | QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); | |
317 |
|
317 | |||
318 | if (m_charts.at(0)->chart()->theme() != theme) { |
|
318 | if (m_charts.at(0)->chart()->theme() != theme) { | |
319 | foreach (QChartView *chartView, m_charts) |
|
319 | foreach (QChartView *chartView, m_charts) | |
320 | chartView->chart()->setTheme(theme); |
|
320 | chartView->chart()->setTheme(theme); | |
321 |
|
321 | |||
322 | QPalette pal = window()->palette(); |
|
322 | QPalette pal = window()->palette(); | |
323 | if (theme == QChart::ChartThemeLight) { |
|
323 | if (theme == QChart::ChartThemeLight) { | |
324 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
324 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
325 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
325 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
326 | } else if (theme == QChart::ChartThemeDark) { |
|
326 | } else if (theme == QChart::ChartThemeDark) { | |
327 | pal.setColor(QPalette::Window, QRgb(0x121218)); |
|
327 | pal.setColor(QPalette::Window, QRgb(0x121218)); | |
328 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
328 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
329 | } else if (theme == QChart::ChartThemeBlueCerulean) { |
|
329 | } else if (theme == QChart::ChartThemeBlueCerulean) { | |
330 | pal.setColor(QPalette::Window, QRgb(0x40434a)); |
|
330 | pal.setColor(QPalette::Window, QRgb(0x40434a)); | |
331 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); |
|
331 | pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); | |
332 | } else if (theme == QChart::ChartThemeBrownSand) { |
|
332 | } else if (theme == QChart::ChartThemeBrownSand) { | |
333 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); |
|
333 | pal.setColor(QPalette::Window, QRgb(0x9e8965)); | |
334 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
334 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
335 | } else if (theme == QChart::ChartThemeBlueNcs) { |
|
335 | } else if (theme == QChart::ChartThemeBlueNcs) { | |
336 | pal.setColor(QPalette::Window, QRgb(0x018bba)); |
|
336 | pal.setColor(QPalette::Window, QRgb(0x018bba)); | |
337 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
337 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
338 | } else if (theme == QChart::ChartThemeHighContrast) { |
|
338 | } else if (theme == QChart::ChartThemeHighContrast) { | |
339 | pal.setColor(QPalette::Window, QRgb(0xffab03)); |
|
339 | pal.setColor(QPalette::Window, QRgb(0xffab03)); | |
340 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); |
|
340 | pal.setColor(QPalette::WindowText, QRgb(0x181818)); | |
341 | } else if (theme == QChart::ChartThemeBlueIcy) { |
|
341 | } else if (theme == QChart::ChartThemeBlueIcy) { | |
342 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); |
|
342 | pal.setColor(QPalette::Window, QRgb(0xcee7f0)); | |
343 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
343 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
344 | } else { |
|
344 | } else { | |
345 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); |
|
345 | pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); | |
346 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); |
|
346 | pal.setColor(QPalette::WindowText, QRgb(0x404044)); | |
347 | } |
|
347 | } | |
348 | window()->setPalette(pal); |
|
348 | window()->setPalette(pal); | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | bool checked = m_antialiasCheckBox->isChecked(); |
|
351 | bool checked = m_antialiasCheckBox->isChecked(); | |
352 | foreach (QChartView *chart, m_charts) |
|
352 | foreach (QChartView *chart, m_charts) | |
353 | chart->setRenderHint(QPainter::Antialiasing, checked); |
|
353 | chart->setRenderHint(QPainter::Antialiasing, checked); | |
354 |
|
354 | |||
355 | QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); |
|
355 | QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); | |
356 | if (m_charts.at(0)->chart()->animationOptions() != options) { |
|
356 | if (m_charts.at(0)->chart()->animationOptions() != options) { | |
357 | foreach (QChartView *chartView, m_charts) |
|
357 | foreach (QChartView *chartView, m_charts) | |
358 | chartView->chart()->setAnimationOptions(options); |
|
358 | chartView->chart()->setAnimationOptions(options); | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | QLegend::Alignments alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); |
|
361 | QLegend::Alignments alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); | |
362 |
|
362 | |||
363 | if (!alignment) { |
|
363 | if (!alignment) { | |
364 | foreach (QChartView *chartView, m_charts) { |
|
364 | foreach (QChartView *chartView, m_charts) { | |
365 | chartView->chart()->legend()->hide(); |
|
365 | chartView->chart()->legend()->hide(); | |
366 | } |
|
366 | } | |
367 | } else { |
|
367 | } else { | |
368 | foreach (QChartView *chartView, m_charts) { |
|
368 | foreach (QChartView *chartView, m_charts) { | |
369 | chartView->chart()->legend()->setAlignment(alignment); |
|
369 | chartView->chart()->legend()->setAlignment(alignment); | |
370 | chartView->chart()->legend()->show(); |
|
370 | chartView->chart()->legend()->show(); | |
371 | } |
|
371 | } | |
372 | } |
|
372 | } | |
373 | } |
|
373 | } | |
374 |
|
374 |
@@ -1,87 +1,87 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QBarSeries> |
|
24 | #include <QBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | int main(int argc, char *argv[]) |
|
30 | int main(int argc, char *argv[]) | |
31 | { |
|
31 | { | |
32 | QApplication a(argc, argv); |
|
32 | QApplication a(argc, argv); | |
33 |
|
33 | |||
34 | //![1] |
|
34 | //![1] | |
35 | QBarCategories categories; |
|
35 | QBarCategories categories; | |
36 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
36 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
37 | //![1] |
|
37 | //![1] | |
38 |
|
38 | |||
39 | //![2] |
|
39 | //![2] | |
40 | QBarSet *set0 = new QBarSet("Jane"); |
|
40 | QBarSet *set0 = new QBarSet("Jane"); | |
41 | QBarSet *set1 = new QBarSet("John"); |
|
41 | QBarSet *set1 = new QBarSet("John"); | |
42 | QBarSet *set2 = new QBarSet("Axel"); |
|
42 | QBarSet *set2 = new QBarSet("Axel"); | |
43 | QBarSet *set3 = new QBarSet("Mary"); |
|
43 | QBarSet *set3 = new QBarSet("Mary"); | |
44 | QBarSet *set4 = new QBarSet("Samantha"); |
|
44 | QBarSet *set4 = new QBarSet("Samantha"); | |
45 |
|
45 | |||
46 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
46 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
47 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
47 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
48 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
48 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
49 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
49 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
50 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
50 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
51 | //![2] |
|
51 | //![2] | |
52 |
|
52 | |||
53 | //![3] |
|
53 | //![3] | |
54 | QBarSeries* series = new QBarSeries(categories); |
|
54 | QBarSeries* series = new QBarSeries(categories); | |
55 | series->appendBarSet(set0); |
|
55 | series->appendBarSet(set0); | |
56 | series->appendBarSet(set1); |
|
56 | series->appendBarSet(set1); | |
57 | series->appendBarSet(set2); |
|
57 | series->appendBarSet(set2); | |
58 | series->appendBarSet(set3); |
|
58 | series->appendBarSet(set3); | |
59 | series->appendBarSet(set4); |
|
59 | series->appendBarSet(set4); | |
60 | //![3] |
|
60 | //![3] | |
61 |
|
61 | |||
62 | //![4] |
|
62 | //![4] | |
63 | QChart* chart = new QChart(); |
|
63 | QChart* chart = new QChart(); | |
64 | chart->addSeries(series); |
|
64 | chart->addSeries(series); | |
65 | chart->setTitle("Simple barchart example"); |
|
65 | chart->setTitle("Simple barchart example"); | |
66 | //![4] |
|
66 | //![4] | |
67 |
|
67 | |||
68 | //![5] |
|
68 | //![5] | |
69 | chart->legend()->setVisible(true); |
|
69 | chart->legend()->setVisible(true); | |
70 | chart->legend()->setAlignment(QLegend::AlignmentBottom); |
|
70 | chart->legend()->setAlignment(QLegend::AlignmentBottom); | |
71 | chart->axisY()->setNiceNumbers(true); |
|
71 | chart->axisY()->setNiceNumbersEnabled(true); | |
72 | //![5] |
|
72 | //![5] | |
73 |
|
73 | |||
74 | //![6] |
|
74 | //![6] | |
75 | QChartView* chartView = new QChartView(chart); |
|
75 | QChartView* chartView = new QChartView(chart); | |
76 | chartView->setRenderHint(QPainter::Antialiasing); |
|
76 | chartView->setRenderHint(QPainter::Antialiasing); | |
77 | //![6] |
|
77 | //![6] | |
78 |
|
78 | |||
79 | //![7] |
|
79 | //![7] | |
80 | QMainWindow window; |
|
80 | QMainWindow window; | |
81 | window.setCentralWidget(chartView); |
|
81 | window.setCentralWidget(chartView); | |
82 | window.resize(400, 300); |
|
82 | window.resize(400, 300); | |
83 | window.show(); |
|
83 | window.show(); | |
84 | //![7] |
|
84 | //![7] | |
85 |
|
85 | |||
86 | return a.exec(); |
|
86 | return a.exec(); | |
87 | } |
|
87 | } |
@@ -1,39 +1,39 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartview.h" |
|
21 | #include "chartview.h" | |
22 | #include <QApplication> |
|
22 | #include <QApplication> | |
23 | #include <QMainWindow> |
|
23 | #include <QMainWindow> | |
24 |
|
24 | |||
25 | int main(int argc, char *argv[]) |
|
25 | int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QApplication a(argc, argv); |
|
27 | QApplication a(argc, argv); | |
28 | QMainWindow window; |
|
28 | QMainWindow window; | |
29 | QChart* chart = new QChart(); |
|
29 | QChart* chart = new QChart(); | |
30 | chart->axisX()->setNiceNumbers(true); |
|
30 | chart->axisX()->setNiceNumbersEnabled(true); | |
31 | chart->axisY()->setNiceNumbers(true); |
|
31 | chart->axisY()->setNiceNumbersEnabled(true); | |
32 | ChartView chartView(chart,&window); |
|
32 | ChartView chartView(chart,&window); | |
33 | chartView.setRenderHint(QPainter::Antialiasing); |
|
33 | chartView.setRenderHint(QPainter::Antialiasing); | |
34 | chart->setAnimationOptions(QChart::AllAnimations); |
|
34 | chart->setAnimationOptions(QChart::AllAnimations); | |
35 | window.setCentralWidget(&chartView); |
|
35 | window.setCentralWidget(&chartView); | |
36 | window.resize(400, 300); |
|
36 | window.resize(400, 300); | |
37 | window.show(); |
|
37 | window.show(); | |
38 | return a.exec(); |
|
38 | return a.exec(); | |
39 | } |
|
39 | } |
@@ -1,88 +1,88 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QStackedBarSeries> |
|
24 | #include <QStackedBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | int main(int argc, char *argv[]) |
|
30 | int main(int argc, char *argv[]) | |
31 | { |
|
31 | { | |
32 | QApplication a(argc, argv); |
|
32 | QApplication a(argc, argv); | |
33 |
|
33 | |||
34 | //![1] |
|
34 | //![1] | |
35 | QBarCategories categories; |
|
35 | QBarCategories categories; | |
36 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
36 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
37 | //![1] |
|
37 | //![1] | |
38 |
|
38 | |||
39 | //![2] |
|
39 | //![2] | |
40 | QBarSet *set0 = new QBarSet("Jane"); |
|
40 | QBarSet *set0 = new QBarSet("Jane"); | |
41 | QBarSet *set1 = new QBarSet("John"); |
|
41 | QBarSet *set1 = new QBarSet("John"); | |
42 | QBarSet *set2 = new QBarSet("Axel"); |
|
42 | QBarSet *set2 = new QBarSet("Axel"); | |
43 | QBarSet *set3 = new QBarSet("Mary"); |
|
43 | QBarSet *set3 = new QBarSet("Mary"); | |
44 | QBarSet *set4 = new QBarSet("Samantha"); |
|
44 | QBarSet *set4 = new QBarSet("Samantha"); | |
45 |
|
45 | |||
46 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
46 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
47 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
47 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
48 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
48 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
49 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
49 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
50 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
50 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
51 | //![2] |
|
51 | //![2] | |
52 |
|
52 | |||
53 | //![3] |
|
53 | //![3] | |
54 | QStackedBarSeries* series = new QStackedBarSeries(categories); |
|
54 | QStackedBarSeries* series = new QStackedBarSeries(categories); | |
55 | series->appendBarSet(set0); |
|
55 | series->appendBarSet(set0); | |
56 | series->appendBarSet(set1); |
|
56 | series->appendBarSet(set1); | |
57 | series->appendBarSet(set2); |
|
57 | series->appendBarSet(set2); | |
58 | series->appendBarSet(set3); |
|
58 | series->appendBarSet(set3); | |
59 | series->appendBarSet(set4); |
|
59 | series->appendBarSet(set4); | |
60 | //![3] |
|
60 | //![3] | |
61 |
|
61 | |||
62 | //![4] |
|
62 | //![4] | |
63 | QChart* chart = new QChart(); |
|
63 | QChart* chart = new QChart(); | |
64 | chart->addSeries(series); |
|
64 | chart->addSeries(series); | |
65 | chart->setTitle("Simple stackedbarchart example"); |
|
65 | chart->setTitle("Simple stackedbarchart example"); | |
66 | //![4] |
|
66 | //![4] | |
67 |
|
67 | |||
68 | //![5] |
|
68 | //![5] | |
69 | chart->legend()->setVisible(true); |
|
69 | chart->legend()->setVisible(true); | |
70 | chart->legend()->setAlignment(QLegend::AlignmentBottom); |
|
70 | chart->legend()->setAlignment(QLegend::AlignmentBottom); | |
71 | chart->axisY()->setNiceNumbers(true); |
|
71 | chart->axisY()->setNiceNumbersEnabled(true); | |
72 | //![5] |
|
72 | //![5] | |
73 |
|
73 | |||
74 | //![6] |
|
74 | //![6] | |
75 | QChartView* chartView = new QChartView(chart); |
|
75 | QChartView* chartView = new QChartView(chart); | |
76 | chartView->setRenderHint(QPainter::Antialiasing); |
|
76 | chartView->setRenderHint(QPainter::Antialiasing); | |
77 | //![6] |
|
77 | //![6] | |
78 |
|
78 | |||
79 | //![7] |
|
79 | //![7] | |
80 | QMainWindow window; |
|
80 | QMainWindow window; | |
81 | window.setCentralWidget(chartView); |
|
81 | window.setCentralWidget(chartView); | |
82 | window.resize(400, 300); |
|
82 | window.resize(400, 300); | |
83 | window.show(); |
|
83 | window.show(); | |
84 | //![7] |
|
84 | //![7] | |
85 |
|
85 | |||
86 | return a.exec(); |
|
86 | return a.exec(); | |
87 | } |
|
87 | } | |
88 |
|
88 |
@@ -1,50 +1,50 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "drilldownchart.h" |
|
21 | #include "drilldownchart.h" | |
22 | #include <QChartAxis> |
|
22 | #include <QChartAxis> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
24 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
25 | |||
26 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
26 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
27 | : QChart(parent, wFlags) |
|
27 | : QChart(parent, wFlags) | |
28 | ,m_currentSeries(0) |
|
28 | ,m_currentSeries(0) | |
29 | { |
|
29 | { | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | void DrilldownChart::changeSeries(QSeries* series) |
|
32 | void DrilldownChart::changeSeries(QSeries* series) | |
33 | { |
|
33 | { | |
34 | if (m_currentSeries) |
|
34 | if (m_currentSeries) | |
35 | removeSeries(m_currentSeries); |
|
35 | removeSeries(m_currentSeries); | |
36 | m_currentSeries = series; |
|
36 | m_currentSeries = series; | |
37 | addSeries(series); |
|
37 | addSeries(series); | |
38 | setTitle(series->name()); |
|
38 | setTitle(series->name()); | |
39 | axisY()->setNiceNumbers(true); |
|
39 | axisY()->setNiceNumbersEnabled(true); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void DrilldownChart::handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button) |
|
42 | void DrilldownChart::handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button) | |
43 | { |
|
43 | { | |
44 | Q_UNUSED(barset) |
|
44 | Q_UNUSED(barset) | |
45 | Q_UNUSED(button) |
|
45 | Q_UNUSED(button) | |
46 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); |
|
46 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); | |
47 | changeSeries(series->drilldownSeries(category)); |
|
47 | changeSeries(series->drilldownSeries(category)); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | #include "moc_drilldownchart.cpp" |
|
50 | #include "moc_drilldownchart.cpp" |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtGui/QApplication> |
|
21 | #include <QtGui/QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QBarSet> |
|
24 | #include <QBarSet> | |
25 | #include <QLegend> |
|
25 | #include <QLegend> | |
26 | #include "drilldownseries.h" |
|
26 | #include "drilldownseries.h" | |
27 | #include "drilldownchart.h" |
|
27 | #include "drilldownchart.h" | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | int main(int argc, char *argv[]) |
|
31 | int main(int argc, char *argv[]) | |
32 | { |
|
32 | { | |
33 | //! [1] |
|
33 | //! [1] | |
34 | QApplication a(argc, argv); |
|
34 | QApplication a(argc, argv); | |
35 | QMainWindow window; |
|
35 | QMainWindow window; | |
36 | //! [1] |
|
36 | //! [1] | |
37 |
|
37 | |||
38 | //! [2] |
|
38 | //! [2] | |
39 | DrilldownChart* drilldownChart = new DrilldownChart(); |
|
39 | DrilldownChart* drilldownChart = new DrilldownChart(); | |
40 | drilldownChart->setTheme(QChart::ChartThemeBlueIcy); |
|
40 | drilldownChart->setTheme(QChart::ChartThemeBlueIcy); | |
41 | drilldownChart->setAnimationOptions(QChart::SeriesAnimations); |
|
41 | drilldownChart->setAnimationOptions(QChart::SeriesAnimations); | |
42 | //! [2] |
|
42 | //! [2] | |
43 |
|
43 | |||
44 | //! [3] |
|
44 | //! [3] | |
45 | // Define categories |
|
45 | // Define categories | |
46 | QStringList months; |
|
46 | QStringList months; | |
47 | months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; |
|
47 | months << "May" << "Jun" << "Jul" << "Aug" << "Sep"; | |
48 | QStringList weeks; |
|
48 | QStringList weeks; | |
49 | weeks << "week 1" << "week 2" << "week 3" << "week 4"; |
|
49 | weeks << "week 1" << "week 2" << "week 3" << "week 4"; | |
50 | QStringList plants; |
|
50 | QStringList plants; | |
51 | plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; |
|
51 | plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo"; | |
52 | //! [3] |
|
52 | //! [3] | |
53 |
|
53 | |||
54 | //! [4] |
|
54 | //! [4] | |
55 | // Create drilldown structure |
|
55 | // Create drilldown structure | |
56 | DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart); |
|
56 | DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart); | |
57 | seasonSeries->setName("Crop by month - Season"); |
|
57 | seasonSeries->setName("Crop by month - Season"); | |
58 |
|
58 | |||
59 | // Each month in season series has drilldown series for weekly data |
|
59 | // Each month in season series has drilldown series for weekly data | |
60 | foreach (QString month, months) { |
|
60 | foreach (QString month, months) { | |
61 |
|
61 | |||
62 | // Create drilldown series for every week |
|
62 | // Create drilldown series for every week | |
63 | DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); |
|
63 | DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart); | |
64 | seasonSeries->mapDrilldownSeries(month, weeklySeries); |
|
64 | seasonSeries->mapDrilldownSeries(month, weeklySeries); | |
65 |
|
65 | |||
66 | // Drilling down from weekly data brings us back to season data. |
|
66 | // Drilling down from weekly data brings us back to season data. | |
67 | foreach (QString week, weeks) { |
|
67 | foreach (QString week, weeks) { | |
68 | weeklySeries->mapDrilldownSeries(week, seasonSeries); |
|
68 | weeklySeries->mapDrilldownSeries(week, seasonSeries); | |
69 | weeklySeries->setName(QString("Crop by week - " + month)); |
|
69 | weeklySeries->setName(QString("Crop by week - " + month)); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | // Use right click signal to implement drilldown |
|
72 | // Use right click signal to implement drilldown | |
73 | QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); |
|
73 | QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | // Enable drilldown from season series using right click. |
|
76 | // Enable drilldown from season series using right click. | |
77 | QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); |
|
77 | QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); | |
78 | //! [4] |
|
78 | //! [4] | |
79 |
|
79 | |||
80 | //! [5] |
|
80 | //! [5] | |
81 | // Fill monthly and weekly series with data |
|
81 | // Fill monthly and weekly series with data | |
82 | foreach (QString plant, plants) { |
|
82 | foreach (QString plant, plants) { | |
83 | QBarSet* monthlyCrop = new QBarSet(plant); |
|
83 | QBarSet* monthlyCrop = new QBarSet(plant); | |
84 | foreach (QString month, months) { |
|
84 | foreach (QString month, months) { | |
85 | QBarSet* weeklyCrop = new QBarSet(plant); |
|
85 | QBarSet* weeklyCrop = new QBarSet(plant); | |
86 | foreach (QString week, weeks ) |
|
86 | foreach (QString week, weeks ) | |
87 | *weeklyCrop << (qrand() % 20); |
|
87 | *weeklyCrop << (qrand() % 20); | |
88 | // Get the drilldown series from season series and add crop to it. |
|
88 | // Get the drilldown series from season series and add crop to it. | |
89 | seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop); |
|
89 | seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop); | |
90 | *monthlyCrop << weeklyCrop->sum(); |
|
90 | *monthlyCrop << weeklyCrop->sum(); | |
91 | } |
|
91 | } | |
92 | seasonSeries->appendBarSet(monthlyCrop); |
|
92 | seasonSeries->appendBarSet(monthlyCrop); | |
93 | } |
|
93 | } | |
94 | //! [5] |
|
94 | //! [5] | |
95 |
|
95 | |||
96 | //! [6] |
|
96 | //! [6] | |
97 | // Show season series in initial view |
|
97 | // Show season series in initial view | |
98 | drilldownChart->changeSeries(seasonSeries); |
|
98 | drilldownChart->changeSeries(seasonSeries); | |
99 | drilldownChart->setTitle(seasonSeries->name()); |
|
99 | drilldownChart->setTitle(seasonSeries->name()); | |
100 | //! [6] |
|
100 | //! [6] | |
101 |
|
101 | |||
102 | //! [7] |
|
102 | //! [7] | |
103 | drilldownChart->axisX()->setGridLineVisible(false); |
|
103 | drilldownChart->axisX()->setGridLineVisible(false); | |
104 | drilldownChart->axisY()->setNiceNumbers(true); |
|
104 | drilldownChart->axisY()->setNiceNumbersEnabled(true); | |
105 | drilldownChart->legend()->setVisible(true); |
|
105 | drilldownChart->legend()->setVisible(true); | |
106 | drilldownChart->legend()->setAlignment(QLegend::AlignmentBottom); |
|
106 | drilldownChart->legend()->setAlignment(QLegend::AlignmentBottom); | |
107 | //! [7] |
|
107 | //! [7] | |
108 |
|
108 | |||
109 | QChartView *chartView = new QChartView(drilldownChart); |
|
109 | QChartView *chartView = new QChartView(drilldownChart); | |
110 | window.setCentralWidget(chartView); |
|
110 | window.setCentralWidget(chartView); | |
111 | window.resize(400, 300); |
|
111 | window.resize(400, 300); | |
112 | window.show(); |
|
112 | window.show(); | |
113 |
|
113 | |||
114 | return a.exec(); |
|
114 | return a.exec(); | |
115 | } |
|
115 | } | |
116 |
|
116 |
@@ -1,71 +1,71 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QAREASERIES_H |
|
21 | #ifndef QAREASERIES_H | |
22 | #define QAREASERIES_H |
|
22 | #define QAREASERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QLineSeries; |
|
30 | class QLineSeries; | |
31 | class QAreaSeriesPrivate; |
|
31 | class QAreaSeriesPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries |
|
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | public: |
|
36 | public: | |
37 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); |
|
37 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); | |
38 | ~QAreaSeries(); |
|
38 | ~QAreaSeries(); | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | QSeries::QSeriesType type() const; |
|
41 | QSeries::QSeriesType type() const; | |
42 |
|
42 | |||
43 | QLineSeries* upperSeries() const; |
|
43 | QLineSeries* upperSeries() const; | |
44 | QLineSeries* lowerSeries() const; |
|
44 | QLineSeries* lowerSeries() const; | |
45 |
|
45 | |||
46 | void setPen(const QPen &pen); |
|
46 | void setPen(const QPen &pen); | |
47 | QPen pen() const; |
|
47 | QPen pen() const; | |
48 |
|
48 | |||
49 | void setBrush(const QBrush &brush); |
|
49 | void setBrush(const QBrush &brush); | |
50 | QBrush brush() const; |
|
50 | QBrush brush() const; | |
51 |
|
51 | |||
52 | void setPointsVisible(bool visible); |
|
52 | void setPointsVisible(bool visible = true); | |
53 | bool pointsVisible() const; |
|
53 | bool pointsVisible() const; | |
54 |
|
54 | |||
55 | bool setModel(QAbstractItemModel* model); |
|
55 | bool setModel(QAbstractItemModel* model); | |
56 | QAbstractItemModel* model() const; |
|
56 | QAbstractItemModel* model() const; | |
57 |
|
57 | |||
58 | Q_SIGNALS: |
|
58 | Q_SIGNALS: | |
59 | void clicked(const QPointF &point); |
|
59 | void clicked(const QPointF &point); | |
60 | void selected(); |
|
60 | void selected(); | |
61 |
|
61 | |||
62 | private: |
|
62 | private: | |
63 | Q_DECLARE_PRIVATE(QAreaSeries); |
|
63 | Q_DECLARE_PRIVATE(QAreaSeries); | |
64 | Q_DISABLE_COPY(QAreaSeries); |
|
64 | Q_DISABLE_COPY(QAreaSeries); | |
65 | friend class AreaLegendMarker; |
|
65 | friend class AreaLegendMarker; | |
66 | friend class AreaChartItem; |
|
66 | friend class AreaChartItem; | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
70 |
|
70 | |||
71 | #endif |
|
71 | #endif |
@@ -1,535 +1,533 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchartaxis.h" |
|
21 | #include "qchartaxis.h" | |
22 | #include "qchartaxis_p.h" |
|
22 | #include "qchartaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QChartAxis |
|
27 | \class QChartAxis | |
28 | \brief The QChartAxis class is used for manipulating chart's axis |
|
28 | \brief The QChartAxis class is used for manipulating chart's axis | |
29 | and for adding optional axes to the chart. |
|
29 | and for adding optional axes to the chart. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | There is only one x Axis, however there can be multiple y axes. |
|
32 | There is only one x Axis, however there can be multiple y axes. | |
33 | Each chart series can be bound to exactly one Y axis and the share common X axis. |
|
33 | Each chart series can be bound to exactly one Y axis and the share common X axis. | |
34 | Axis can be setup to show axis line with ticks, gird lines and shades. |
|
34 | Axis can be setup to show axis line with ticks, gird lines and shades. | |
35 |
|
35 | |||
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | /*! |
|
38 | /*! | |
39 | \fn bool QChartAxis::isAxisVisible() const |
|
39 | \fn bool QChartAxis::isAxisVisible() const | |
40 | \brief Returns if axis is visible |
|
40 | \brief Returns if axis is visible | |
41 | \sa setAxisVisible() |
|
41 | \sa setAxisVisible() | |
42 | */ |
|
42 | */ | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | \fn QPen QChartAxis::axisPen() const |
|
45 | \fn QPen QChartAxis::axisPen() const | |
46 | \brief Returns pen used to draw axis and ticks. |
|
46 | \brief Returns pen used to draw axis and ticks. | |
47 | \sa setAxisPen() |
|
47 | \sa setAxisPen() | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn bool QChartAxis::isGridLineVisible() const |
|
52 | \fn bool QChartAxis::isGridLineVisible() const | |
53 | \brief Returns if grid is visible |
|
53 | \brief Returns if grid is visible | |
54 | \sa setGridLineVisible() |
|
54 | \sa setGridLineVisible() | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \fn QPen QChartAxis::gridLinePen() const |
|
58 | \fn QPen QChartAxis::gridLinePen() const | |
59 | \brief Returns pen used to draw grid. |
|
59 | \brief Returns pen used to draw grid. | |
60 | \sa setGridLinePen() |
|
60 | \sa setGridLinePen() | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \fn bool QChartAxis::labelsVisible() const |
|
64 | \fn bool QChartAxis::labelsVisible() const | |
65 | \brief Returns if grid is visible |
|
65 | \brief Returns if grid is visible | |
66 | \sa setLabelsVisible() |
|
66 | \sa setLabelsVisible() | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \fn QPen QChartAxis::labelsPen() const |
|
70 | \fn QPen QChartAxis::labelsPen() const | |
71 | \brief Returns the pen used to labels. |
|
71 | \brief Returns the pen used to labels. | |
72 | \sa setLabelsPen() |
|
72 | \sa setLabelsPen() | |
73 | */ |
|
73 | */ | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | \fn QBrush QChartAxis::labelsBrush() const |
|
76 | \fn QBrush QChartAxis::labelsBrush() const | |
77 | \brief Returns brush used to draw labels. |
|
77 | \brief Returns brush used to draw labels. | |
78 | \sa setLabelsBrush() |
|
78 | \sa setLabelsBrush() | |
79 | */ |
|
79 | */ | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | \fn QFont QChartAxis::labelsFont() const |
|
82 | \fn QFont QChartAxis::labelsFont() const | |
83 | \brief Returns font used to draw labels. |
|
83 | \brief Returns font used to draw labels. | |
84 | \sa setLabelsFont() |
|
84 | \sa setLabelsFont() | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \fn QFont QChartAxis::labelsAngle() const |
|
88 | \fn QFont QChartAxis::labelsAngle() const | |
89 | \brief Returns angle used to draw labels. |
|
89 | \brief Returns angle used to draw labels. | |
90 | \sa setLabelsAngle() |
|
90 | \sa setLabelsAngle() | |
91 | */ |
|
91 | */ | |
92 |
|
92 | |||
93 | /*! |
|
93 | /*! | |
94 | \fn bool QChartAxis::shadesVisible() const |
|
94 | \fn bool QChartAxis::shadesVisible() const | |
95 | \brief Returns if shades are visible. |
|
95 | \brief Returns if shades are visible. | |
96 | \sa setShadesVisible() |
|
96 | \sa setShadesVisible() | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn qreal QChartAxis::shadesOpacity() const |
|
100 | \fn qreal QChartAxis::shadesOpacity() const | |
101 | \brief Returns opacity of shades. |
|
101 | \brief Returns opacity of shades. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \fn QPen QChartAxis::shadesPen() const |
|
105 | \fn QPen QChartAxis::shadesPen() const | |
106 | \brief Returns pen used to draw shades. |
|
106 | \brief Returns pen used to draw shades. | |
107 | \sa setShadesPen() |
|
107 | \sa setShadesPen() | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \fn QBrush QChartAxis::shadesBrush() const |
|
111 | \fn QBrush QChartAxis::shadesBrush() const | |
112 | \brief Returns brush used to draw shades. |
|
112 | \brief Returns brush used to draw shades. | |
113 | \sa setShadesBrush() |
|
113 | \sa setShadesBrush() | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \fn qreal QChartAxis::min() const |
|
117 | \fn qreal QChartAxis::min() const | |
118 | \brief Returns minimum value on the axis. |
|
118 | \brief Returns minimum value on the axis. | |
119 | \sa setMin() |
|
119 | \sa setMin() | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \fn qreal QChartAxis::max() const |
|
123 | \fn qreal QChartAxis::max() const | |
124 | \brief Returns maximim value on the axis. |
|
124 | \brief Returns maximim value on the axis. | |
125 | \sa setMax() |
|
125 | \sa setMax() | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \fn void QChartAxis::minChanged(qreal min) |
|
129 | \fn void QChartAxis::minChanged(qreal min) | |
130 | \brief Axis emits signal when \a min of axis has changed. |
|
130 | \brief Axis emits signal when \a min of axis has changed. | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | \fn void QChartAxis::maxChanged(qreal max) |
|
134 | \fn void QChartAxis::maxChanged(qreal max) | |
135 | \brief Axis emits signal when \a max of axis has changed. |
|
135 | \brief Axis emits signal when \a max of axis has changed. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QChartAxis::rangeChanged(qreal min, qreal max) |
|
139 | \fn void QChartAxis::rangeChanged(qreal min, qreal max) | |
140 | \brief Axis emits signal when \a min or \a max of axis has changed. |
|
140 | \brief Axis emits signal when \a min or \a max of axis has changed. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \fn int QChartAxis::ticksCount() const |
|
144 | \fn int QChartAxis::ticksCount() const | |
145 | \brief Return number of ticks on the axis |
|
145 | \brief Return number of ticks on the axis | |
146 | \sa setTicksCount() |
|
146 | \sa setTicksCount() | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \fn bool QChartAxis::niceNumbers() const |
|
|||
151 | \brief Returns whether nice numbers are enabled or not. |
|
|||
152 | */ |
|
|||
153 |
|
||||
154 | /*! |
|
|||
155 | \fn QChartAxisCategories* QChartAxis::categories() |
|
150 | \fn QChartAxisCategories* QChartAxis::categories() | |
156 | \brief Returns pointer to the list of categories which correspond to the values on the axis. |
|
151 | \brief Returns pointer to the list of categories which correspond to the values on the axis. | |
157 | */ |
|
152 | */ | |
158 |
|
153 | |||
159 | /*! |
|
154 | /*! | |
160 | \fn void QChartAxis::ticksCountChanged(int count) |
|
155 | \fn void QChartAxis::ticksCountChanged(int count) | |
161 | \brief Emits the new \a count of ticks on the axis |
|
156 | \brief Emits the new \a count of ticks on the axis | |
162 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. |
|
157 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. | |
163 | Parementer count\a count is the new number of ticks on the axis. |
|
158 | Parementer count\a count is the new number of ticks on the axis. | |
164 | */ |
|
159 | */ | |
165 |
|
160 | |||
166 | /*! |
|
161 | /*! | |
167 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
162 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
168 | QChatView or QChart when axis added. |
|
163 | QChatView or QChart when axis added. | |
169 | */ |
|
164 | */ | |
170 |
|
165 | |||
171 | QChartAxis::QChartAxis(QObject *parent) : QObject(parent), |
|
166 | QChartAxis::QChartAxis(QObject *parent) : QObject(parent), | |
172 | d_ptr(new QChartAxisPrivate(this)) |
|
167 | d_ptr(new QChartAxisPrivate(this)) | |
173 | { |
|
168 | { | |
174 |
|
169 | |||
175 | } |
|
170 | } | |
176 |
|
171 | |||
177 | /*! |
|
172 | /*! | |
178 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
173 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
179 | */ |
|
174 | */ | |
180 |
|
175 | |||
181 | QChartAxis::~QChartAxis() |
|
176 | QChartAxis::~QChartAxis() | |
182 | { |
|
177 | { | |
183 | } |
|
178 | } | |
184 |
|
179 | |||
185 | /*! |
|
180 | /*! | |
186 | Sets \a pen used to draw axis line and ticks. |
|
181 | Sets \a pen used to draw axis line and ticks. | |
187 | */ |
|
182 | */ | |
188 | void QChartAxis::setAxisPen(const QPen &pen) |
|
183 | void QChartAxis::setAxisPen(const QPen &pen) | |
189 | { |
|
184 | { | |
190 | if (d_ptr->m_axisPen!=pen) { |
|
185 | if (d_ptr->m_axisPen!=pen) { | |
191 | d_ptr->m_axisPen = pen; |
|
186 | d_ptr->m_axisPen = pen; | |
192 | emit d_ptr->updated(); |
|
187 | emit d_ptr->updated(); | |
193 | } |
|
188 | } | |
194 | } |
|
189 | } | |
195 |
|
190 | |||
196 | QPen QChartAxis::axisPen() const |
|
191 | QPen QChartAxis::axisPen() const | |
197 | { |
|
192 | { | |
198 | return d_ptr->m_axisPen; |
|
193 | return d_ptr->m_axisPen; | |
199 | } |
|
194 | } | |
200 |
|
195 | |||
201 | /*! |
|
196 | /*! | |
202 | Sets if axis and ticks are \a visible. |
|
197 | Sets if axis and ticks are \a visible. | |
203 | */ |
|
198 | */ | |
204 | void QChartAxis::setAxisVisible(bool visible) |
|
199 | void QChartAxis::setAxisVisible(bool visible) | |
205 | { |
|
200 | { | |
206 | if (d_ptr->m_axisVisible != visible) { |
|
201 | if (d_ptr->m_axisVisible != visible) { | |
207 | d_ptr->m_axisVisible = visible; |
|
202 | d_ptr->m_axisVisible = visible; | |
208 | emit d_ptr->updated(); |
|
203 | emit d_ptr->updated(); | |
209 | } |
|
204 | } | |
210 | } |
|
205 | } | |
211 |
|
206 | |||
212 | bool QChartAxis::isAxisVisible() const |
|
207 | bool QChartAxis::isAxisVisible() const | |
213 | { |
|
208 | { | |
214 | return d_ptr->m_axisVisible; |
|
209 | return d_ptr->m_axisVisible; | |
215 | } |
|
210 | } | |
216 |
|
211 | |||
217 | /*! |
|
212 | /*! | |
218 | Sets if grid line is \a visible. |
|
213 | Sets if grid line is \a visible. | |
219 | */ |
|
214 | */ | |
220 | void QChartAxis::setGridLineVisible(bool visible) |
|
215 | void QChartAxis::setGridLineVisible(bool visible) | |
221 | { |
|
216 | { | |
222 | if (d_ptr->m_gridLineVisible != visible) { |
|
217 | if (d_ptr->m_gridLineVisible != visible) { | |
223 | d_ptr->m_gridLineVisible = visible; |
|
218 | d_ptr->m_gridLineVisible = visible; | |
224 | emit d_ptr->updated(); |
|
219 | emit d_ptr->updated(); | |
225 | } |
|
220 | } | |
226 | } |
|
221 | } | |
227 |
|
222 | |||
228 | bool QChartAxis::isGridLineVisible() const |
|
223 | bool QChartAxis::isGridLineVisible() const | |
229 | { |
|
224 | { | |
230 | return d_ptr->m_gridLineVisible; |
|
225 | return d_ptr->m_gridLineVisible; | |
231 | } |
|
226 | } | |
232 | /*! |
|
227 | /*! | |
233 | Sets \a pen used to draw grid line. |
|
228 | Sets \a pen used to draw grid line. | |
234 | */ |
|
229 | */ | |
235 | void QChartAxis::setGridLinePen(const QPen &pen) |
|
230 | void QChartAxis::setGridLinePen(const QPen &pen) | |
236 | { |
|
231 | { | |
237 | if (d_ptr->m_gridLinePen != pen) { |
|
232 | if (d_ptr->m_gridLinePen != pen) { | |
238 | d_ptr->m_gridLinePen = pen; |
|
233 | d_ptr->m_gridLinePen = pen; | |
239 | emit d_ptr->updated(); |
|
234 | emit d_ptr->updated(); | |
240 | } |
|
235 | } | |
241 | } |
|
236 | } | |
242 |
|
237 | |||
243 | QPen QChartAxis::gridLinePen() const |
|
238 | QPen QChartAxis::gridLinePen() const | |
244 | { |
|
239 | { | |
245 | return d_ptr->m_gridLinePen; |
|
240 | return d_ptr->m_gridLinePen; | |
246 | } |
|
241 | } | |
247 |
|
242 | |||
248 | /*! |
|
243 | /*! | |
249 | Sets if axis' labels are \a visible. |
|
244 | Sets if axis' labels are \a visible. | |
250 | */ |
|
245 | */ | |
251 | void QChartAxis::setLabelsVisible(bool visible) |
|
246 | void QChartAxis::setLabelsVisible(bool visible) | |
252 | { |
|
247 | { | |
253 | if (d_ptr->m_labelsVisible != visible) { |
|
248 | if (d_ptr->m_labelsVisible != visible) { | |
254 | d_ptr->m_labelsVisible = visible; |
|
249 | d_ptr->m_labelsVisible = visible; | |
255 | emit d_ptr->updated(); |
|
250 | emit d_ptr->updated(); | |
256 | } |
|
251 | } | |
257 | } |
|
252 | } | |
258 |
|
253 | |||
259 | bool QChartAxis::labelsVisible() const |
|
254 | bool QChartAxis::labelsVisible() const | |
260 | { |
|
255 | { | |
261 | return d_ptr->m_labelsVisible; |
|
256 | return d_ptr->m_labelsVisible; | |
262 | } |
|
257 | } | |
263 | /*! |
|
258 | /*! | |
264 | Sets \a pen used to draw labels. |
|
259 | Sets \a pen used to draw labels. | |
265 | */ |
|
260 | */ | |
266 | void QChartAxis::setLabelsPen(const QPen &pen) |
|
261 | void QChartAxis::setLabelsPen(const QPen &pen) | |
267 | { |
|
262 | { | |
268 | if (d_ptr->m_labelsPen != pen) { |
|
263 | if (d_ptr->m_labelsPen != pen) { | |
269 | d_ptr->m_labelsPen = pen; |
|
264 | d_ptr->m_labelsPen = pen; | |
270 | emit d_ptr->updated(); |
|
265 | emit d_ptr->updated(); | |
271 | } |
|
266 | } | |
272 | } |
|
267 | } | |
273 |
|
268 | |||
274 | QPen QChartAxis::labelsPen() const |
|
269 | QPen QChartAxis::labelsPen() const | |
275 | { |
|
270 | { | |
276 | return d_ptr->m_labelsPen; |
|
271 | return d_ptr->m_labelsPen; | |
277 | } |
|
272 | } | |
278 |
|
273 | |||
279 | /*! |
|
274 | /*! | |
280 | Sets \a brush used to draw labels. |
|
275 | Sets \a brush used to draw labels. | |
281 | */ |
|
276 | */ | |
282 | void QChartAxis::setLabelsBrush(const QBrush &brush) |
|
277 | void QChartAxis::setLabelsBrush(const QBrush &brush) | |
283 | { |
|
278 | { | |
284 | if (d_ptr->m_labelsBrush != brush) { |
|
279 | if (d_ptr->m_labelsBrush != brush) { | |
285 | d_ptr->m_labelsBrush = brush; |
|
280 | d_ptr->m_labelsBrush = brush; | |
286 | emit d_ptr->updated(); |
|
281 | emit d_ptr->updated(); | |
287 | } |
|
282 | } | |
288 | } |
|
283 | } | |
289 |
|
284 | |||
290 | QBrush QChartAxis::labelsBrush() const |
|
285 | QBrush QChartAxis::labelsBrush() const | |
291 | { |
|
286 | { | |
292 | return d_ptr->m_labelsBrush; |
|
287 | return d_ptr->m_labelsBrush; | |
293 | } |
|
288 | } | |
294 |
|
289 | |||
295 | /*! |
|
290 | /*! | |
296 | Sets \a font used to draw labels. |
|
291 | Sets \a font used to draw labels. | |
297 | */ |
|
292 | */ | |
298 | void QChartAxis::setLabelsFont(const QFont &font) |
|
293 | void QChartAxis::setLabelsFont(const QFont &font) | |
299 | { |
|
294 | { | |
300 | if (d_ptr->m_labelsFont != font) { |
|
295 | if (d_ptr->m_labelsFont != font) { | |
301 | d_ptr->m_labelsFont = font; |
|
296 | d_ptr->m_labelsFont = font; | |
302 | emit d_ptr->updated(); |
|
297 | emit d_ptr->updated(); | |
303 | } |
|
298 | } | |
304 | } |
|
299 | } | |
305 |
|
300 | |||
306 | QFont QChartAxis::labelsFont() const |
|
301 | QFont QChartAxis::labelsFont() const | |
307 | { |
|
302 | { | |
308 | return d_ptr->m_labelsFont; |
|
303 | return d_ptr->m_labelsFont; | |
309 | } |
|
304 | } | |
310 |
|
305 | |||
311 | /*! |
|
306 | /*! | |
312 | Sets \a angle for all the labels on given axis. |
|
307 | Sets \a angle for all the labels on given axis. | |
313 | */ |
|
308 | */ | |
314 | void QChartAxis::setLabelsAngle(int angle) |
|
309 | void QChartAxis::setLabelsAngle(int angle) | |
315 | { |
|
310 | { | |
316 | if (d_ptr->m_labelsAngle != angle) { |
|
311 | if (d_ptr->m_labelsAngle != angle) { | |
317 | d_ptr->m_labelsAngle = angle; |
|
312 | d_ptr->m_labelsAngle = angle; | |
318 | emit d_ptr->updated(); |
|
313 | emit d_ptr->updated(); | |
319 | } |
|
314 | } | |
320 | } |
|
315 | } | |
321 |
|
316 | |||
322 | int QChartAxis::labelsAngle() const |
|
317 | int QChartAxis::labelsAngle() const | |
323 | { |
|
318 | { | |
324 | return d_ptr->m_labelsAngle; |
|
319 | return d_ptr->m_labelsAngle; | |
325 | } |
|
320 | } | |
326 |
|
321 | |||
327 | /*! |
|
322 | /*! | |
328 | Sets if shades are \a visible. |
|
323 | Sets if shades are \a visible. | |
329 | */ |
|
324 | */ | |
330 | void QChartAxis::setShadesVisible(bool visible) |
|
325 | void QChartAxis::setShadesVisible(bool visible) | |
331 | { |
|
326 | { | |
332 | if (d_ptr->m_shadesVisible != visible) { |
|
327 | if (d_ptr->m_shadesVisible != visible) { | |
333 | d_ptr->m_shadesVisible = visible; |
|
328 | d_ptr->m_shadesVisible = visible; | |
334 | emit d_ptr->updated(); |
|
329 | emit d_ptr->updated(); | |
335 | } |
|
330 | } | |
336 | } |
|
331 | } | |
337 |
|
332 | |||
338 | bool QChartAxis::shadesVisible() const |
|
333 | bool QChartAxis::shadesVisible() const | |
339 | { |
|
334 | { | |
340 | return d_ptr->m_shadesVisible; |
|
335 | return d_ptr->m_shadesVisible; | |
341 | } |
|
336 | } | |
342 |
|
337 | |||
343 | /*! |
|
338 | /*! | |
344 | Sets \a pen used to draw shades. |
|
339 | Sets \a pen used to draw shades. | |
345 | */ |
|
340 | */ | |
346 | void QChartAxis::setShadesPen(const QPen &pen) |
|
341 | void QChartAxis::setShadesPen(const QPen &pen) | |
347 | { |
|
342 | { | |
348 | if (d_ptr->m_shadesPen != pen) { |
|
343 | if (d_ptr->m_shadesPen != pen) { | |
349 | d_ptr->m_shadesPen = pen; |
|
344 | d_ptr->m_shadesPen = pen; | |
350 | emit d_ptr->updated(); |
|
345 | emit d_ptr->updated(); | |
351 | } |
|
346 | } | |
352 | } |
|
347 | } | |
353 |
|
348 | |||
354 | QPen QChartAxis::shadesPen() const |
|
349 | QPen QChartAxis::shadesPen() const | |
355 | { |
|
350 | { | |
356 | return d_ptr->m_shadesPen; |
|
351 | return d_ptr->m_shadesPen; | |
357 | } |
|
352 | } | |
358 |
|
353 | |||
359 | /*! |
|
354 | /*! | |
360 | Sets \a brush used to draw shades. |
|
355 | Sets \a brush used to draw shades. | |
361 | */ |
|
356 | */ | |
362 | void QChartAxis::setShadesBrush(const QBrush &brush) |
|
357 | void QChartAxis::setShadesBrush(const QBrush &brush) | |
363 | { |
|
358 | { | |
364 | if (d_ptr->m_shadesBrush != brush) { |
|
359 | if (d_ptr->m_shadesBrush != brush) { | |
365 | d_ptr->m_shadesBrush = brush; |
|
360 | d_ptr->m_shadesBrush = brush; | |
366 | emit d_ptr->updated(); |
|
361 | emit d_ptr->updated(); | |
367 | } |
|
362 | } | |
368 | } |
|
363 | } | |
369 |
|
364 | |||
370 | QBrush QChartAxis::shadesBrush() const |
|
365 | QBrush QChartAxis::shadesBrush() const | |
371 | { |
|
366 | { | |
372 | return d_ptr->m_shadesBrush; |
|
367 | return d_ptr->m_shadesBrush; | |
373 | } |
|
368 | } | |
374 |
|
369 | |||
375 | /*! |
|
370 | /*! | |
376 | Sets \a opacity of the shades. |
|
371 | Sets \a opacity of the shades. | |
377 | */ |
|
372 | */ | |
378 | void QChartAxis::setShadesOpacity(qreal opacity) |
|
373 | void QChartAxis::setShadesOpacity(qreal opacity) | |
379 | { |
|
374 | { | |
380 | if (d_ptr->m_shadesOpacity != opacity) { |
|
375 | if (d_ptr->m_shadesOpacity != opacity) { | |
381 | d_ptr->m_shadesOpacity=opacity; |
|
376 | d_ptr->m_shadesOpacity=opacity; | |
382 | emit d_ptr->updated(); |
|
377 | emit d_ptr->updated(); | |
383 | } |
|
378 | } | |
384 | } |
|
379 | } | |
385 |
|
380 | |||
386 | qreal QChartAxis::shadesOpacity() const |
|
381 | qreal QChartAxis::shadesOpacity() const | |
387 | { |
|
382 | { | |
388 | return d_ptr->m_shadesOpacity; |
|
383 | return d_ptr->m_shadesOpacity; | |
389 | } |
|
384 | } | |
390 |
|
385 | |||
391 | /*! |
|
386 | /*! | |
392 | Sets \a min value on the axis. |
|
387 | Sets \a min value on the axis. | |
393 | */ |
|
388 | */ | |
394 | void QChartAxis::setMin(qreal min) |
|
389 | void QChartAxis::setMin(qreal min) | |
395 | { |
|
390 | { | |
396 | setRange(min,d_ptr->m_max); |
|
391 | setRange(min,d_ptr->m_max); | |
397 | } |
|
392 | } | |
398 |
|
393 | |||
399 | qreal QChartAxis::min() const |
|
394 | qreal QChartAxis::min() const | |
400 | { |
|
395 | { | |
401 | return d_ptr->m_min; |
|
396 | return d_ptr->m_min; | |
402 | } |
|
397 | } | |
403 |
|
398 | |||
404 | /*! |
|
399 | /*! | |
405 | Sets \a max value on the axis. |
|
400 | Sets \a max value on the axis. | |
406 | */ |
|
401 | */ | |
407 | void QChartAxis::setMax(qreal max) |
|
402 | void QChartAxis::setMax(qreal max) | |
408 | { |
|
403 | { | |
409 | setRange(d_ptr->m_min,max); |
|
404 | setRange(d_ptr->m_min,max); | |
410 | } |
|
405 | } | |
411 |
|
406 | |||
412 | qreal QChartAxis::max() const |
|
407 | qreal QChartAxis::max() const | |
413 | { |
|
408 | { | |
414 | return d_ptr->m_max; |
|
409 | return d_ptr->m_max; | |
415 | } |
|
410 | } | |
416 |
|
411 | |||
417 | /*! |
|
412 | /*! | |
418 | Sets range from \a min to \a max on the axis. |
|
413 | Sets range from \a min to \a max on the axis. | |
419 | */ |
|
414 | */ | |
420 | void QChartAxis::setRange(qreal min, qreal max) |
|
415 | void QChartAxis::setRange(qreal min, qreal max) | |
421 | { |
|
416 | { | |
422 | bool changed = false; |
|
417 | bool changed = false; | |
423 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { |
|
418 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
424 | d_ptr->m_min = min; |
|
419 | d_ptr->m_min = min; | |
425 | changed = true; |
|
420 | changed = true; | |
426 | emit minChanged(min); |
|
421 | emit minChanged(min); | |
427 | } |
|
422 | } | |
428 |
|
423 | |||
429 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { |
|
424 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
430 | d_ptr->m_max = max; |
|
425 | d_ptr->m_max = max; | |
431 | changed = true; |
|
426 | changed = true; | |
432 | emit maxChanged(max); |
|
427 | emit maxChanged(max); | |
433 | } |
|
428 | } | |
434 |
|
429 | |||
435 | if (changed) { |
|
430 | if (changed) { | |
436 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); |
|
431 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
437 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
432 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
438 | } |
|
433 | } | |
439 | } |
|
434 | } | |
440 |
|
435 | |||
441 | /*! |
|
436 | /*! | |
442 | Sets \a count for ticks on the axis. |
|
437 | Sets \a count for ticks on the axis. | |
443 | */ |
|
438 | */ | |
444 | void QChartAxis::setTicksCount(int count) |
|
439 | void QChartAxis::setTicksCount(int count) | |
445 | { |
|
440 | { | |
446 | if (d_ptr->m_ticksCount != count) { |
|
441 | if (d_ptr->m_ticksCount != count) { | |
447 | d_ptr->m_ticksCount = count; |
|
442 | d_ptr->m_ticksCount = count; | |
448 | emit ticksCountChanged(count); |
|
443 | emit ticksCountChanged(count); | |
449 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
444 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
450 | } |
|
445 | } | |
451 | } |
|
446 | } | |
452 |
|
447 | |||
453 | int QChartAxis::ticksCount() const |
|
448 | int QChartAxis::ticksCount() const | |
454 | { |
|
449 | { | |
455 | return d_ptr->m_ticksCount; |
|
450 | return d_ptr->m_ticksCount; | |
456 | } |
|
451 | } | |
457 |
|
452 | |||
458 | /*! |
|
453 | /*! | |
459 | Sets axis, shades, labels and grid lines to be visible. |
|
454 | Sets axis, shades, labels and grid lines to be visible. | |
460 | */ |
|
455 | */ | |
461 | void QChartAxis::show() |
|
456 | void QChartAxis::show() | |
462 | { |
|
457 | { | |
463 | d_ptr->m_axisVisible=true; |
|
458 | d_ptr->m_axisVisible=true; | |
464 | d_ptr->m_gridLineVisible=true; |
|
459 | d_ptr->m_gridLineVisible=true; | |
465 | d_ptr->m_labelsVisible=true; |
|
460 | d_ptr->m_labelsVisible=true; | |
466 | d_ptr->m_shadesVisible=true; |
|
461 | d_ptr->m_shadesVisible=true; | |
467 | emit d_ptr->updated(); |
|
462 | emit d_ptr->updated(); | |
468 | } |
|
463 | } | |
469 |
|
464 | |||
470 | /*! |
|
465 | /*! | |
471 | Sets axis, shades, labels and grid lines to not be visible. |
|
466 | Sets axis, shades, labels and grid lines to not be visible. | |
472 | */ |
|
467 | */ | |
473 | void QChartAxis::hide() |
|
468 | void QChartAxis::hide() | |
474 | { |
|
469 | { | |
475 | d_ptr->m_axisVisible = false; |
|
470 | d_ptr->m_axisVisible = false; | |
476 | d_ptr->m_gridLineVisible = false; |
|
471 | d_ptr->m_gridLineVisible = false; | |
477 | d_ptr->m_labelsVisible = false; |
|
472 | d_ptr->m_labelsVisible = false; | |
478 | d_ptr->m_shadesVisible = false; |
|
473 | d_ptr->m_shadesVisible = false; | |
479 | emit d_ptr->updated(); |
|
474 | emit d_ptr->updated(); | |
480 | } |
|
475 | } | |
481 |
|
476 | |||
482 | /*! |
|
477 | /*! | |
483 | Sets the nice numbers state to \a enable |
|
478 | Sets the nice numbers state to \a enable | |
484 | */ |
|
479 | */ | |
485 | void QChartAxis::setNiceNumbers(bool enable) |
|
480 | void QChartAxis::setNiceNumbersEnabled(bool enable) | |
486 | { |
|
481 | { | |
487 | if (d_ptr->m_niceNumbers != enable){ |
|
482 | if (d_ptr->m_niceNumbers != enable){ | |
488 | d_ptr->m_niceNumbers = enable; |
|
483 | d_ptr->m_niceNumbers = enable; | |
489 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
484 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
490 | } |
|
485 | } | |
491 | } |
|
486 | } | |
492 |
|
487 | |||
493 | bool QChartAxis::niceNumbers() const |
|
488 | /*! | |
|
489 | Returns whether nice numbers are enabled or not. | |||
|
490 | */ | |||
|
491 | bool QChartAxis::niceNumbersEnabled() const | |||
494 | { |
|
492 | { | |
495 | return d_ptr->m_niceNumbers; |
|
493 | return d_ptr->m_niceNumbers; | |
496 | } |
|
494 | } | |
497 |
|
495 | |||
498 | QChartAxisCategories* QChartAxis::categories() |
|
496 | QChartAxisCategories* QChartAxis::categories() | |
499 | { |
|
497 | { | |
500 | return &d_ptr->m_category; |
|
498 | return &d_ptr->m_category; | |
501 | } |
|
499 | } | |
502 |
|
500 | |||
503 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
501 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
504 |
|
502 | |||
505 | QChartAxisPrivate::QChartAxisPrivate(QChartAxis* q): |
|
503 | QChartAxisPrivate::QChartAxisPrivate(QChartAxis* q): | |
506 | q_ptr(q), |
|
504 | q_ptr(q), | |
507 | m_axisVisible(true), |
|
505 | m_axisVisible(true), | |
508 | m_gridLineVisible(true), |
|
506 | m_gridLineVisible(true), | |
509 | m_labelsVisible(true), |
|
507 | m_labelsVisible(true), | |
510 | m_labelsAngle(0), |
|
508 | m_labelsAngle(0), | |
511 | m_shadesVisible(false), |
|
509 | m_shadesVisible(false), | |
512 | m_shadesOpacity(1.0), |
|
510 | m_shadesOpacity(1.0), | |
513 | m_min(0), |
|
511 | m_min(0), | |
514 | m_max(0), |
|
512 | m_max(0), | |
515 | m_ticksCount(5), |
|
513 | m_ticksCount(5), | |
516 | m_niceNumbers(false) |
|
514 | m_niceNumbers(false) | |
517 | { |
|
515 | { | |
518 |
|
516 | |||
519 | } |
|
517 | } | |
520 |
|
518 | |||
521 | QChartAxisPrivate::~QChartAxisPrivate() |
|
519 | QChartAxisPrivate::~QChartAxisPrivate() | |
522 | { |
|
520 | { | |
523 |
|
521 | |||
524 | } |
|
522 | } | |
525 |
|
523 | |||
526 | void QChartAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
524 | void QChartAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
527 | { |
|
525 | { | |
528 | q_ptr->setRange(min,max); |
|
526 | q_ptr->setRange(min,max); | |
529 | q_ptr->setTicksCount(count); |
|
527 | q_ptr->setTicksCount(count); | |
530 | } |
|
528 | } | |
531 |
|
529 | |||
532 | #include "moc_qchartaxis.cpp" |
|
530 | #include "moc_qchartaxis.cpp" | |
533 | #include "moc_qchartaxis_p.cpp" |
|
531 | #include "moc_qchartaxis_p.cpp" | |
534 |
|
532 | |||
535 | QTCOMMERCIALCHART_END_NAMESPACE |
|
533 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,108 +1,108 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHARTAXIS_H |
|
21 | #ifndef QCHARTAXIS_H | |
22 | #define QCHARTAXIS_H |
|
22 | #define QCHARTAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qchartaxiscategories.h> |
|
25 | #include <qchartaxiscategories.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QChartAxisPrivate; |
|
31 | class QChartAxisPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | public: |
|
36 | public: | |
37 |
|
37 | |||
38 | QChartAxis(QObject *parent =0); |
|
38 | QChartAxis(QObject *parent =0); | |
39 | ~QChartAxis(); |
|
39 | ~QChartAxis(); | |
40 |
|
40 | |||
41 | //axis handling |
|
41 | //axis handling | |
42 | bool isAxisVisible() const; |
|
42 | bool isAxisVisible() const; | |
43 | void setAxisVisible(bool visible); |
|
43 | void setAxisVisible(bool visible = true); | |
44 | void setAxisPen(const QPen &pen); |
|
44 | void setAxisPen(const QPen &pen); | |
45 | QPen axisPen() const; |
|
45 | QPen axisPen() const; | |
46 |
|
46 | |||
47 | //grid handling |
|
47 | //grid handling | |
48 | bool isGridLineVisible() const; |
|
48 | bool isGridLineVisible() const; | |
49 | void setGridLineVisible(bool visible); |
|
49 | void setGridLineVisible(bool visible = true); | |
50 | void setGridLinePen(const QPen &pen); |
|
50 | void setGridLinePen(const QPen &pen); | |
51 | QPen gridLinePen() const; |
|
51 | QPen gridLinePen() const; | |
52 |
|
52 | |||
53 | //labels handling |
|
53 | //labels handling | |
54 | bool labelsVisible() const; |
|
54 | bool labelsVisible() const; | |
55 | void setLabelsVisible(bool visible); |
|
55 | void setLabelsVisible(bool visible = true); | |
56 | void setLabelsPen(const QPen &pen); |
|
56 | void setLabelsPen(const QPen &pen); | |
57 | QPen labelsPen() const; |
|
57 | QPen labelsPen() const; | |
58 | void setLabelsBrush(const QBrush &brush); |
|
58 | void setLabelsBrush(const QBrush &brush); | |
59 | QBrush labelsBrush() const; |
|
59 | QBrush labelsBrush() const; | |
60 | void setLabelsFont(const QFont &font); |
|
60 | void setLabelsFont(const QFont &font); | |
61 | QFont labelsFont() const; |
|
61 | QFont labelsFont() const; | |
62 | void setLabelsAngle(int angle); |
|
62 | void setLabelsAngle(int angle); | |
63 | int labelsAngle() const; |
|
63 | int labelsAngle() const; | |
64 |
|
64 | |||
65 | //shades handling |
|
65 | //shades handling | |
66 | bool shadesVisible() const; |
|
66 | bool shadesVisible() const; | |
67 | void setShadesVisible(bool visible); |
|
67 | void setShadesVisible(bool visible = true); | |
68 | void setShadesPen(const QPen &pen); |
|
68 | void setShadesPen(const QPen &pen); | |
69 | QPen shadesPen() const; |
|
69 | QPen shadesPen() const; | |
70 | void setShadesBrush(const QBrush &brush); |
|
70 | void setShadesBrush(const QBrush &brush); | |
71 | QBrush shadesBrush() const; |
|
71 | QBrush shadesBrush() const; | |
72 | void setShadesOpacity(qreal opacity); |
|
72 | void setShadesOpacity(qreal opacity); | |
73 | qreal shadesOpacity() const; |
|
73 | qreal shadesOpacity() const; | |
74 |
|
74 | |||
75 | //range handling |
|
75 | //range handling | |
76 | void setMin(qreal min); |
|
76 | void setMin(qreal min); | |
77 | qreal min() const; |
|
77 | qreal min() const; | |
78 | void setMax(qreal max); |
|
78 | void setMax(qreal max); | |
79 | qreal max() const; |
|
79 | qreal max() const; | |
80 | void setRange(qreal min, qreal max); |
|
80 | void setRange(qreal min, qreal max); | |
81 |
|
81 | |||
82 | //ticks handling |
|
82 | //ticks handling | |
83 | void setTicksCount(int count); |
|
83 | void setTicksCount(int count); | |
84 | int ticksCount() const; |
|
84 | int ticksCount() const; | |
85 |
|
85 | |||
86 | void setNiceNumbers(bool enable); |
|
86 | void setNiceNumbersEnabled(bool enable = true); | |
87 | bool niceNumbers() const; |
|
87 | bool niceNumbersEnabled() const; | |
88 |
|
88 | |||
89 | QChartAxisCategories* categories(); |
|
89 | QChartAxisCategories* categories(); | |
90 |
|
90 | |||
91 | void show(); |
|
91 | void show(); | |
92 | void hide(); |
|
92 | void hide(); | |
93 |
|
93 | |||
94 | Q_SIGNALS: |
|
94 | Q_SIGNALS: | |
95 | void minChanged(qreal min); |
|
95 | void minChanged(qreal min); | |
96 | void maxChanged(qreal max); |
|
96 | void maxChanged(qreal max); | |
97 | void rangeChanged(qreal min, qreal max); |
|
97 | void rangeChanged(qreal min, qreal max); | |
98 | void ticksCountChanged(int count); |
|
98 | void ticksCountChanged(int count); | |
99 |
|
99 | |||
100 | private: |
|
100 | private: | |
101 | QScopedPointer<QChartAxisPrivate> d_ptr; |
|
101 | QScopedPointer<QChartAxisPrivate> d_ptr; | |
102 | Q_DISABLE_COPY(QChartAxis); |
|
102 | Q_DISABLE_COPY(QChartAxis); | |
103 | friend class ChartDataSet; |
|
103 | friend class ChartDataSet; | |
104 | friend class Axis; |
|
104 | friend class Axis; | |
105 | }; |
|
105 | }; | |
106 |
|
106 | |||
107 | QTCOMMERCIALCHART_END_NAMESPACE |
|
107 | QTCOMMERCIALCHART_END_NAMESPACE | |
108 | #endif /* QCHARTAXIS_H_ */ |
|
108 | #endif /* QCHARTAXIS_H_ */ |
@@ -1,119 +1,119 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QSeries> |
|
24 | #include <QSeries> | |
25 | #include <QLegend> |
|
25 | #include <QLegend> | |
26 | #include <QGraphicsWidget> |
|
26 | #include <QGraphicsWidget> | |
27 |
|
27 | |||
28 | class QGraphicsSceneResizeEvent; |
|
28 | class QGraphicsSceneResizeEvent; | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSeries; |
|
32 | class QSeries; | |
33 | class QChartAxis; |
|
33 | class QChartAxis; | |
34 | class QLegend; |
|
34 | class QLegend; | |
35 | struct QChartPrivate; |
|
35 | struct QChartPrivate; | |
36 |
|
36 | |||
37 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
37 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_ENUMS(ChartTheme) |
|
40 | Q_ENUMS(ChartTheme) | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | enum ChartTheme { |
|
43 | enum ChartTheme { | |
44 | ChartThemeLight = 0, |
|
44 | ChartThemeLight = 0, | |
45 | ChartThemeBlueCerulean, |
|
45 | ChartThemeBlueCerulean, | |
46 | ChartThemeDark, |
|
46 | ChartThemeDark, | |
47 | ChartThemeBrownSand, |
|
47 | ChartThemeBrownSand, | |
48 | ChartThemeBlueNcs, |
|
48 | ChartThemeBlueNcs, | |
49 | ChartThemeHighContrast, |
|
49 | ChartThemeHighContrast, | |
50 | ChartThemeBlueIcy |
|
50 | ChartThemeBlueIcy | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | enum AnimationOption { |
|
53 | enum AnimationOption { | |
54 | NoAnimation = 0x0, |
|
54 | NoAnimation = 0x0, | |
55 | GridAxisAnimations = 0x1, |
|
55 | GridAxisAnimations = 0x1, | |
56 | SeriesAnimations =0x2, |
|
56 | SeriesAnimations =0x2, | |
57 | AllAnimations = 0x3 |
|
57 | AllAnimations = 0x3 | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
60 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
61 |
|
61 | |||
62 | public: |
|
62 | public: | |
63 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
63 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
64 | ~QChart(); |
|
64 | ~QChart(); | |
65 |
|
65 | |||
66 | void addSeries(QSeries *series, QChartAxis *axisY = 0); |
|
66 | void addSeries(QSeries *series, QChartAxis *axisY = 0); | |
67 | void removeSeries(QSeries *series); |
|
67 | void removeSeries(QSeries *series); | |
68 | void removeAllSeries(); |
|
68 | void removeAllSeries(); | |
69 |
|
69 | |||
70 | void setTheme(QChart::ChartTheme theme); |
|
70 | void setTheme(QChart::ChartTheme theme); | |
71 | QChart::ChartTheme theme() const; |
|
71 | QChart::ChartTheme theme() const; | |
72 |
|
72 | |||
73 | void setTitle(const QString& title); |
|
73 | void setTitle(const QString& title); | |
74 | QString title() const; |
|
74 | QString title() const; | |
75 | void setTitleFont(const QFont& font); |
|
75 | void setTitleFont(const QFont& font); | |
76 | QFont titleFont() const; |
|
76 | QFont titleFont() const; | |
77 | void setTitleBrush(const QBrush &brush); |
|
77 | void setTitleBrush(const QBrush &brush); | |
78 | QBrush titleBrush() const; |
|
78 | QBrush titleBrush() const; | |
79 |
|
79 | |||
80 | void setBackgroundBrush(const QBrush &brush); |
|
80 | void setBackgroundBrush(const QBrush &brush); | |
81 | QBrush backgroundBrush() const; |
|
81 | QBrush backgroundBrush() const; | |
82 | void setBackgroundPen(const QPen &pen); |
|
82 | void setBackgroundPen(const QPen &pen); | |
83 | QPen backgroundPen() const; |
|
83 | QPen backgroundPen() const; | |
84 |
|
84 | |||
85 | void setBackgroundVisible(bool visible); |
|
85 | void setBackgroundVisible(bool visible = true); | |
86 | bool isBackgroundVisible() const; |
|
86 | bool isBackgroundVisible() const; | |
87 |
|
87 | |||
88 | void setAnimationOptions(AnimationOptions options); |
|
88 | void setAnimationOptions(AnimationOptions options); | |
89 | AnimationOptions animationOptions() const; |
|
89 | AnimationOptions animationOptions() const; | |
90 |
|
90 | |||
91 | void zoomIn(); |
|
91 | void zoomIn(); | |
92 | void zoomIn(const QRectF &rect); |
|
92 | void zoomIn(const QRectF &rect); | |
93 | void zoomOut(); |
|
93 | void zoomOut(); | |
94 | void scrollLeft(); |
|
94 | void scrollLeft(); | |
95 | void scrollRight(); |
|
95 | void scrollRight(); | |
96 | void scrollUp(); |
|
96 | void scrollUp(); | |
97 | void scrollDown(); |
|
97 | void scrollDown(); | |
98 |
|
98 | |||
99 | QChartAxis* axisX() const; |
|
99 | QChartAxis* axisX() const; | |
100 | QChartAxis* axisY(QSeries* series = 0) const; |
|
100 | QChartAxis* axisY(QSeries* series = 0) const; | |
101 |
|
101 | |||
102 | QLegend* legend() const; |
|
102 | QLegend* legend() const; | |
103 | QRectF margins() const; |
|
103 | QRectF margins() const; | |
104 |
|
104 | |||
105 | protected: |
|
105 | protected: | |
106 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
106 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
107 |
|
107 | |||
108 | protected: |
|
108 | protected: | |
109 | QScopedPointer<QChartPrivate> d_ptr; |
|
109 | QScopedPointer<QChartPrivate> d_ptr; | |
110 | friend class QLegend; |
|
110 | friend class QLegend; | |
111 | friend class ChartPresenter; |
|
111 | friend class ChartPresenter; | |
112 | Q_DISABLE_COPY(QChart) |
|
112 | Q_DISABLE_COPY(QChart) | |
113 | }; |
|
113 | }; | |
114 |
|
114 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
115 | QTCOMMERCIALCHART_END_NAMESPACE | |
116 |
|
116 | |||
117 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
117 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
118 |
|
118 | |||
119 | #endif |
|
119 | #endif |
@@ -1,97 +1,97 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 |
|
34 | |||
35 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries |
|
35 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 | protected: |
|
38 | protected: | |
39 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); |
|
39 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); | |
40 | ~QXYSeries(); |
|
40 | ~QXYSeries(); | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | void append(qreal x, qreal y); |
|
43 | void append(qreal x, qreal y); | |
44 | void append(const QPointF &point); |
|
44 | void append(const QPointF &point); | |
45 | void append(const QList<QPointF> points); |
|
45 | void append(const QList<QPointF> points); | |
46 | void replace(qreal x,qreal y); |
|
46 | void replace(qreal x,qreal y); | |
47 | void replace(const QPointF &point); |
|
47 | void replace(const QPointF &point); | |
48 | void remove(qreal x); |
|
48 | void remove(qreal x); | |
49 | void remove(qreal x, qreal y); |
|
49 | void remove(qreal x, qreal y); | |
50 | void remove(const QPointF &point); |
|
50 | void remove(const QPointF &point); | |
51 | void removeAll(); |
|
51 | void removeAll(); | |
52 |
|
52 | |||
53 | int count() const; |
|
53 | int count() const; | |
54 | qreal x(int pos) const; |
|
54 | qreal x(int pos) const; | |
55 | qreal y(int pos) const; |
|
55 | qreal y(int pos) const; | |
56 | QList<QPointF> data(); |
|
56 | QList<QPointF> data(); | |
57 |
|
57 | |||
58 | QXYSeries& operator << (const QPointF &point); |
|
58 | QXYSeries& operator << (const QPointF &point); | |
59 | QXYSeries& operator << (const QList<QPointF> points); |
|
59 | QXYSeries& operator << (const QList<QPointF> points); | |
60 |
|
60 | |||
61 | void setPen(const QPen &pen); |
|
61 | void setPen(const QPen &pen); | |
62 | QPen pen() const; |
|
62 | QPen pen() const; | |
63 |
|
63 | |||
64 | void setBrush(const QBrush &brush); |
|
64 | void setBrush(const QBrush &brush); | |
65 | QBrush brush() const; |
|
65 | QBrush brush() const; | |
66 |
|
66 | |||
67 | void setPointsVisible(bool visible); |
|
67 | void setPointsVisible(bool visible = true); | |
68 | bool pointsVisible() const; |
|
68 | bool pointsVisible() const; | |
69 |
|
69 | |||
70 | bool setModel(QAbstractItemModel *model); |
|
70 | bool setModel(QAbstractItemModel *model); | |
71 |
|
71 | |||
72 | virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); |
|
72 | virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); | |
73 | virtual void setModelMappingRange(int first, int count = 0); |
|
73 | virtual void setModelMappingRange(int first, int count = 0); | |
74 | int mapFirst() const; |
|
74 | int mapFirst() const; | |
75 | int mapCount() const; |
|
75 | int mapCount() const; | |
76 |
|
76 | |||
77 | private Q_SLOTS: |
|
77 | private Q_SLOTS: | |
78 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
78 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
79 | void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); |
|
79 | void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); | |
80 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
80 | void modelDataAdded(QModelIndex parent, int start, int end); | |
81 | void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); |
|
81 | void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); | |
82 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
82 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
83 |
|
83 | |||
84 | Q_SIGNALS: |
|
84 | Q_SIGNALS: | |
85 | void clicked(const QPointF &point); |
|
85 | void clicked(const QPointF &point); | |
86 | void selected(); |
|
86 | void selected(); | |
87 |
|
87 | |||
88 | private: |
|
88 | private: | |
89 | Q_DECLARE_PRIVATE(QXYSeries); |
|
89 | Q_DECLARE_PRIVATE(QXYSeries); | |
90 | Q_DISABLE_COPY(QXYSeries); |
|
90 | Q_DISABLE_COPY(QXYSeries); | |
91 | friend class XYLegendMarker; |
|
91 | friend class XYLegendMarker; | |
92 | friend class XYChartItem; |
|
92 | friend class XYChartItem; | |
93 | }; |
|
93 | }; | |
94 |
|
94 | |||
95 | QTCOMMERCIALCHART_END_NAMESPACE |
|
95 | QTCOMMERCIALCHART_END_NAMESPACE | |
96 |
|
96 | |||
97 | #endif |
|
97 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now