@@ -40,6 +40,7 | |||||
40 | #include <QGroupBox> |
|
40 | #include <QGroupBox> | |
41 | #include <QLabel> |
|
41 | #include <QLabel> | |
42 | #include <QTime> |
|
42 | #include <QTime> | |
|
43 | #include <QCategoriesAxis> | |||
43 |
|
44 | |||
44 | ThemeWidget::ThemeWidget(QWidget* parent) : |
|
45 | ThemeWidget::ThemeWidget(QWidget* parent) : | |
45 | QWidget(parent), |
|
46 | QWidget(parent), | |
@@ -177,8 +178,8 QComboBox* ThemeWidget::createLegendBox() const | |||||
177 | QChart* ThemeWidget::createAreaChart() const |
|
178 | QChart* ThemeWidget::createAreaChart() const | |
178 | { |
|
179 | { | |
179 | QChart *chart = new QChart(); |
|
180 | QChart *chart = new QChart(); | |
180 | chart->axisX()->setNiceNumbersEnabled(true); |
|
181 | // chart->axisX()->setNiceNumbersEnabled(true); | |
181 | chart->axisY()->setNiceNumbersEnabled(true); |
|
182 | // chart->axisY()->setNiceNumbersEnabled(true); | |
182 | chart->setTitle("Area chart"); |
|
183 | chart->setTitle("Area chart"); | |
183 |
|
184 | |||
184 | // The lower series initialized to zero values |
|
185 | // The lower series initialized to zero values | |
@@ -208,15 +209,16 QChart* ThemeWidget::createAreaChart() const | |||||
208 | QChart* ThemeWidget::createBarChart(int valueCount) const |
|
209 | QChart* ThemeWidget::createBarChart(int valueCount) const | |
209 | { |
|
210 | { | |
210 | QChart* chart = new QChart(); |
|
211 | QChart* chart = new QChart(); | |
211 | chart->axisX()->setNiceNumbersEnabled(true); |
|
212 | //TODO: chart->axisX()->setNiceNumbersEnabled(true); | |
212 | chart->axisY()->setNiceNumbersEnabled(true); |
|
213 | //TODO: chart->axisY()->setNiceNumbersEnabled(true); | |
213 | chart->setTitle("Bar chart"); |
|
214 | chart->setTitle("Bar chart"); | |
214 |
|
215 | |||
215 | QStringList categories; |
|
216 | QStringList categories; | |
216 | for (int i(0); i < valueCount; i++) |
|
217 | for (int i(0); i < valueCount; i++) | |
217 | categories << QString::number(i); |
|
218 | categories << QString::number(i); | |
218 |
|
219 | |||
219 | chart->axisX()->categories()->insert(categories); |
|
220 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
221 | axis->append(categories); | |||
220 |
|
222 | |||
221 | QStackedBarSeries* series = new QStackedBarSeries(chart); |
|
223 | QStackedBarSeries* series = new QStackedBarSeries(chart); | |
222 | for (int i(0); i < m_dataTable.count(); i++) { |
|
224 | for (int i(0); i < m_dataTable.count(); i++) { | |
@@ -226,6 +228,7 QChart* ThemeWidget::createBarChart(int valueCount) const | |||||
226 | series->append(set); |
|
228 | series->append(set); | |
227 | } |
|
229 | } | |
228 | chart->addSeries(series); |
|
230 | chart->addSeries(series); | |
|
231 | chart->setAxisX(series,axis); | |||
229 |
|
232 | |||
230 | return chart; |
|
233 | return chart; | |
231 | } |
|
234 | } | |
@@ -233,8 +236,8 QChart* ThemeWidget::createBarChart(int valueCount) const | |||||
233 | QChart* ThemeWidget::createLineChart() const |
|
236 | QChart* ThemeWidget::createLineChart() const | |
234 | { |
|
237 | { | |
235 | QChart* chart = new QChart(); |
|
238 | QChart* chart = new QChart(); | |
236 | chart->axisX()->setNiceNumbersEnabled(true); |
|
239 | //TODO: chart->axisX()->setNiceNumbersEnabled(true); | |
237 | chart->axisY()->setNiceNumbersEnabled(true); |
|
240 | //TODO: chart->axisY()->setNiceNumbersEnabled(true); | |
238 | chart->setTitle("Line chart"); |
|
241 | chart->setTitle("Line chart"); | |
239 |
|
242 | |||
240 | QString name("Series "); |
|
243 | QString name("Series "); | |
@@ -279,8 +282,8 QChart* ThemeWidget::createPieChart() const | |||||
279 | QChart* ThemeWidget::createSplineChart() const |
|
282 | QChart* ThemeWidget::createSplineChart() const | |
280 | { // spine chart |
|
283 | { // spine chart | |
281 | QChart* chart = new QChart(); |
|
284 | QChart* chart = new QChart(); | |
282 | chart->axisX()->setNiceNumbersEnabled(true); |
|
285 | //TODO: chart->axisX()->setNiceNumbersEnabled(true); | |
283 | chart->axisY()->setNiceNumbersEnabled(true); |
|
286 | //TODO: chart->axisY()->setNiceNumbersEnabled(true); | |
284 | chart->setTitle("Spline chart"); |
|
287 | chart->setTitle("Spline chart"); | |
285 | QString name("Series "); |
|
288 | QString name("Series "); | |
286 | int nameIndex = 0; |
|
289 | int nameIndex = 0; | |
@@ -298,8 +301,8 QChart* ThemeWidget::createSplineChart() const | |||||
298 | QChart* ThemeWidget::createScatterChart() const |
|
301 | QChart* ThemeWidget::createScatterChart() const | |
299 | { // scatter chart |
|
302 | { // scatter chart | |
300 | QChart* chart = new QChart(); |
|
303 | QChart* chart = new QChart(); | |
301 | chart->axisX()->setNiceNumbersEnabled(true); |
|
304 | //TODO: chart->axisX()->setNiceNumbersEnabled(true); | |
302 | chart->axisY()->setNiceNumbersEnabled(true); |
|
305 | //TODO: chart->axisY()->setNiceNumbersEnabled(true); | |
303 | chart->setTitle("Scatter chart"); |
|
306 | chart->setTitle("Scatter chart"); | |
304 | QString name("Series "); |
|
307 | QString name("Series "); | |
305 | int nameIndex = 0; |
|
308 | int nameIndex = 0; |
@@ -19,7 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chart.h" |
|
21 | #include "chart.h" | |
22 | #include <QAxis> |
|
22 | #include <QAbstractAxis> | |
23 | #include <QSplineSeries> |
|
23 | #include <QSplineSeries> | |
24 | #include <QTime> |
|
24 | #include <QTime> | |
25 |
|
25 | |||
@@ -44,7 +44,7 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |||||
44 |
|
44 | |||
45 | axisY()->setRange(-5, 5); |
|
45 | axisY()->setRange(-5, 5); | |
46 | axisX()->setRange(-9, 1); |
|
46 | axisX()->setRange(-9, 1); | |
47 | axisX()->setTicksCount(11); |
|
47 | //TODO:axisX()->setTicksCount(11); | |
48 |
|
48 | |||
49 | m_timer.start(); |
|
49 | m_timer.start(); | |
50 | } |
|
50 | } |
@@ -61,7 +61,6 int main(int argc, char *argv[]) | |||||
61 | //![4] |
|
61 | //![4] | |
62 | chart->legend()->setVisible(true); |
|
62 | chart->legend()->setVisible(true); | |
63 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
63 | chart->legend()->setAlignment(Qt::AlignBottom); | |
64 | chart->axisY()->setNiceNumbersEnabled(true); |
|
|||
65 | //![4] |
|
64 | //![4] | |
66 |
|
65 | |||
67 | //![5] |
|
66 | //![5] |
@@ -30,6 +30,7 | |||||
30 | #include <QBarSet> |
|
30 | #include <QBarSet> | |
31 | #include <QVBarModelMapper> |
|
31 | #include <QVBarModelMapper> | |
32 | #include <QHeaderView> |
|
32 | #include <QHeaderView> | |
|
33 | #include <QCategoriesAxis> | |||
33 |
|
34 | |||
34 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
35 | QTCOMMERCIALCHART_USE_NAMESPACE | |
35 |
|
36 | |||
@@ -87,8 +88,9 TableWidget::TableWidget(QWidget *parent) | |||||
87 | //! [6] |
|
88 | //! [6] | |
88 | QStringList categories; |
|
89 | QStringList categories; | |
89 | categories << "April" << "May" << "June" << "July" << "August"; |
|
90 | categories << "April" << "May" << "June" << "July" << "August"; | |
90 |
|
91 | QCategoriesAxis* axis = new QCategoriesAxis(); | ||
91 |
|
|
92 | axis->append(categories); | |
|
93 | chart->setAxisX(series,axis); | |||
92 | //! [6] |
|
94 | //! [6] | |
93 |
|
95 | |||
94 | //! [7] |
|
96 | //! [7] |
@@ -7,7 +7,7 TEMPLATE = subdirs | |||||
7 | SUBDIRS += \ |
|
7 | SUBDIRS += \ | |
8 | areachart \ |
|
8 | areachart \ | |
9 | barchart \ |
|
9 | barchart \ | |
10 | customchart \ |
|
10 | #customchart \ | |
11 | linechart \ |
|
11 | linechart \ | |
12 | percentbarchart \ |
|
12 | percentbarchart \ | |
13 | piechart \ |
|
13 | piechart \ |
@@ -24,6 +24,7 | |||||
24 | #include <QGroupedBarSeries> |
|
24 | #include <QGroupedBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
|
27 | #include <QCategoriesAxis> | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
30 | |||
@@ -64,13 +65,14 int main(int argc, char *argv[]) | |||||
64 | //![4] |
|
65 | //![4] | |
65 | QStringList categories; |
|
66 | QStringList categories; | |
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
67 | chart->axisX()->categories()->insert(categories); |
|
68 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
69 | axis->append(categories); | |||
|
70 | chart->setAxisX(series,axis); | |||
68 | //![4] |
|
71 | //![4] | |
69 |
|
72 | |||
70 | //![5] |
|
73 | //![5] | |
71 | chart->legend()->setVisible(true); |
|
74 | chart->legend()->setVisible(true); | |
72 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
75 | chart->legend()->setAlignment(Qt::AlignBottom); | |
73 | chart->axisY()->setNiceNumbersEnabled(true); |
|
|||
74 | //![5] |
|
76 | //![5] | |
75 |
|
77 | |||
76 | //![6] |
|
78 | //![6] |
@@ -131,7 +131,7 void MainWidget::createSeries() | |||||
131 | m_chart->legend()->setAlignment(Qt::AlignBottom); |
|
131 | m_chart->legend()->setAlignment(Qt::AlignBottom); | |
132 | //![1] |
|
132 | //![1] | |
133 |
|
133 | |||
134 | m_chart->axisY()->setNiceNumbersEnabled(true); |
|
134 | //TODO:m_chart->axisY()->setNiceNumbersEnabled(true); | |
135 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
135 | m_chartView->setRenderHint(QPainter::Antialiasing); | |
136 | } |
|
136 | } | |
137 |
|
137 |
@@ -24,6 +24,7 | |||||
24 | #include <QPercentBarSeries> |
|
24 | #include <QPercentBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
|
27 | #include <QCategoriesAxis> | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
30 | |||
@@ -63,7 +64,9 int main(int argc, char *argv[]) | |||||
63 | //![4] |
|
64 | //![4] | |
64 | QStringList categories; |
|
65 | QStringList categories; | |
65 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
66 | chart->axisX()->categories()->insert(categories); |
|
67 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
68 | axis->append(categories); | |||
|
69 | chart->setAxisX(series,axis); | |||
67 | //![4] |
|
70 | //![4] | |
68 |
|
71 | |||
69 | //![5] |
|
72 | //![5] |
@@ -27,8 +27,8 int main(int argc, char *argv[]) | |||||
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()->setNiceNumbersEnabled(true); |
|
30 | //TODO: chart->axisX()->setNiceNumbersEnabled(true); | |
31 | chart->axisY()->setNiceNumbersEnabled(true); |
|
31 | //TODO: 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::SeriesAnimations); |
|
34 | chart->setAnimationOptions(QChart::SeriesAnimations); |
@@ -24,6 +24,7 | |||||
24 | #include <QStackedBarSeries> |
|
24 | #include <QStackedBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
|
27 | #include <QCategoriesAxis> | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
30 | |||
@@ -63,13 +64,14 int main(int argc, char *argv[]) | |||||
63 | //![4] |
|
64 | //![4] | |
64 | QStringList categories; |
|
65 | QStringList categories; | |
65 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
66 | chart->axisX()->categories()->insert(categories); |
|
67 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
68 | axis->append(categories); | |||
|
69 | chart->setAxisX(series,axis); | |||
67 | //![4] |
|
70 | //![4] | |
68 |
|
71 | |||
69 | //![5] |
|
72 | //![5] | |
70 | chart->legend()->setVisible(true); |
|
73 | chart->legend()->setVisible(true); | |
71 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
74 | chart->legend()->setAlignment(Qt::AlignBottom); | |
72 | chart->axisY()->setNiceNumbersEnabled(true); |
|
|||
73 | //![5] |
|
75 | //![5] | |
74 |
|
76 | |||
75 | //![6] |
|
77 | //![6] |
@@ -19,7 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "drilldownchart.h" |
|
21 | #include "drilldownchart.h" | |
22 | #include <QAxis> |
|
22 | #include <QCategoriesAxis> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
24 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
25 | |||
@@ -39,11 +39,12 void DrilldownChart::changeSeries(DrilldownBarSeries *series) | |||||
39 |
|
39 | |||
40 | // Reset axis |
|
40 | // Reset axis | |
41 | axisX()->setRange(0,0); |
|
41 | axisX()->setRange(0,0); | |
42 | axisY()->setNiceNumbersEnabled(true); |
|
42 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
43 |
axis |
|
43 | axis->append(m_currentSeries->categories()); | |
44 | axisX()->categories()->insert(m_currentSeries->categories()); |
|
|||
45 |
|
44 | |||
46 | addSeries(series); |
|
45 | addSeries(series); | |
|
46 | setAxisX(series,axis); | |||
|
47 | ||||
47 | setTitle(series->name()); |
|
48 | setTitle(series->name()); | |
48 | } |
|
49 | } | |
49 |
|
50 |
@@ -100,7 +100,7 int main(int argc, char *argv[]) | |||||
100 |
|
100 | |||
101 | //! [6] |
|
101 | //! [6] | |
102 | drilldownChart->axisX()->setGridLineVisible(false); |
|
102 | drilldownChart->axisX()->setGridLineVisible(false); | |
103 | drilldownChart->axisY()->setNiceNumbersEnabled(true); |
|
103 | //TODO: drilldownChart->axisY()->setNiceNumbersEnabled(true); | |
104 | drilldownChart->legend()->setVisible(true); |
|
104 | drilldownChart->legend()->setVisible(true); | |
105 | drilldownChart->legend()->setAlignment(Qt::AlignBottom); |
|
105 | drilldownChart->legend()->setAlignment(Qt::AlignBottom); | |
106 | //! [6] |
|
106 | //! [6] |
@@ -26,6 +26,7 | |||||
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
|
29 | #include "qcategoriesaxis.h" | |||
29 |
|
30 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
32 | |||
@@ -320,12 +321,12 QString DeclarativeChart::title() | |||||
320 | return m_chart->title(); |
|
321 | return m_chart->title(); | |
321 | } |
|
322 | } | |
322 |
|
323 | |||
323 | QAxis *DeclarativeChart::axisX() |
|
324 | QAbstractAxis *DeclarativeChart::axisX() | |
324 | { |
|
325 | { | |
325 | return m_chart->axisX(); |
|
326 | return m_chart->axisX(); | |
326 | } |
|
327 | } | |
327 |
|
328 | |||
328 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
329 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
329 | { |
|
330 | { | |
330 | return m_chart->axisY(series); |
|
331 | return m_chart->axisY(series); | |
331 | } |
|
332 | } | |
@@ -338,28 +339,45 QLegend *DeclarativeChart::legend() | |||||
338 | QVariantList DeclarativeChart::axisXLabels() |
|
339 | QVariantList DeclarativeChart::axisXLabels() | |
339 | { |
|
340 | { | |
340 | QVariantList labels; |
|
341 | QVariantList labels; | |
341 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
342 | ||
342 | labels.append(value); |
|
343 | ||
343 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
344 | if(m_chart->axisX()->type()==QAbstractAxis::AxisTypeCategories) { | |
|
345 | ||||
|
346 | QCategoriesAxis* axis = static_cast<QCategoriesAxis*>(m_chart->axisX()); | |||
|
347 | ||||
|
348 | for(int i=0;i<axis->count();i++){ | |||
|
349 | labels.append(i); | |||
|
350 | labels.append(axis->at(i)); | |||
|
351 | } | |||
|
352 | ||||
344 | } |
|
353 | } | |
345 | return labels; |
|
354 | return labels; | |
|
355 | ||||
346 | } |
|
356 | } | |
347 |
|
357 | |||
348 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
358 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
349 | { |
|
359 | { | |
350 | QVariant value(QVariant::Invalid); |
|
360 | QVariant value(QVariant::Invalid); | |
|
361 | ||||
|
362 | if(m_chart->axisX()->type()==QAbstractAxis::AxisTypeCategories) { | |||
|
363 | QCategoriesAxis* axis = static_cast<QCategoriesAxis*>(m_chart->axisX()); | |||
|
364 | ||||
351 | foreach (QVariant element, list) { |
|
365 | foreach (QVariant element, list) { | |
352 | if (value.isValid() && element.type() == QVariant::String) { |
|
366 | if (value.isValid() && element.type() == QVariant::String) { | |
353 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
367 | axis->append(element.toString()); | |
354 | value = QVariant(QVariant::Invalid); |
|
368 | value = QVariant(QVariant::Invalid); | |
355 |
} |
|
369 | } | |
|
370 | else { | |||
356 | if (element.canConvert(QVariant::Double)) |
|
371 | if (element.canConvert(QVariant::Double)) | |
357 | value = element; |
|
372 | value = element; | |
358 | } |
|
373 | } | |
|
374 | ||||
359 | } |
|
375 | } | |
360 | emit axisLabelsChanged(); |
|
376 | emit axisLabelsChanged(); | |
361 | } |
|
377 | } | |
362 |
|
378 | |||
|
379 | } | |||
|
380 | ||||
363 | void DeclarativeChart::setTitleColor(QColor color) |
|
381 | void DeclarativeChart::setTitleColor(QColor color) | |
364 | { |
|
382 | { | |
365 | QBrush b = m_chart->titleBrush(); |
|
383 | QBrush b = m_chart->titleBrush(); |
@@ -24,7 +24,6 | |||||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 | #include <QAxis> |
|
|||
28 |
|
27 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
29 | |||
@@ -39,8 +38,8 class DeclarativeChart : public QDeclarativeItem | |||||
39 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
38 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
40 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
41 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
42 | Q_PROPERTY(QAxis *axisX READ axisX) |
|
41 | Q_PROPERTY(QAbstractAxis *axisX READ axisX) | |
43 | Q_PROPERTY(QAxis *axisY READ axisY) |
|
42 | Q_PROPERTY(QAbstractAxis *axisY READ axisY) | |
44 | Q_PROPERTY(QLegend *legend READ legend) |
|
43 | Q_PROPERTY(QLegend *legend READ legend) | |
45 | // TODO: how to define axis labels? This is not very convenient |
|
44 | // TODO: how to define axis labels? This is not very convenient | |
46 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) |
|
45 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) | |
@@ -103,7 +102,7 public: | |||||
103 | DeclarativeChart::Animation animationOptions(); |
|
102 | DeclarativeChart::Animation animationOptions(); | |
104 | void setTitle(QString title); |
|
103 | void setTitle(QString title); | |
105 | QString title(); |
|
104 | QString title(); | |
106 | QAxis *axisX(); |
|
105 | QAbstractAxis *axisX(); | |
107 | QLegend *legend(); |
|
106 | QLegend *legend(); | |
108 | QVariantList axisXLabels(); |
|
107 | QVariantList axisXLabels(); | |
109 | void setAxisXLabels(QVariantList list); |
|
108 | void setAxisXLabels(QVariantList list); | |
@@ -125,7 +124,7 public: | |||||
125 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
124 | Q_INVOKABLE QAbstractSeries *series(int index); | |
126 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
125 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
127 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
126 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
128 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); |
|
127 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
129 | Q_INVOKABLE void zoom(qreal factor); |
|
128 | Q_INVOKABLE void zoom(qreal factor); | |
130 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
129 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
131 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
130 | Q_INVOKABLE void scrollRight(qreal pixels); |
@@ -21,6 +21,7 | |||||
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
|
24 | #include "qabstractaxis.h" | |||
24 | #include "qaxiscategories.h" |
|
25 | #include "qaxiscategories.h" | |
25 | #include "declarativechart.h" |
|
26 | #include "declarativechart.h" | |
26 | #include "declarativexypoint.h" |
|
27 | #include "declarativexypoint.h" | |
@@ -87,7 +88,7 public: | |||||
87 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
88 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
88 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
89 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
89 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
90 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
90 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
91 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "Axis", | |
91 | QLatin1String("Trying to create uncreatable: Axis.")); |
|
92 | QLatin1String("Trying to create uncreatable: Axis.")); | |
92 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
93 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
93 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
94 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
@@ -5,7 +5,6 SOURCES += \ | |||||
5 | $$PWD/chartaxis.cpp \ |
|
5 | $$PWD/chartaxis.cpp \ | |
6 | $$PWD/chartaxisx.cpp \ |
|
6 | $$PWD/chartaxisx.cpp \ | |
7 | $$PWD/chartaxisy.cpp \ |
|
7 | $$PWD/chartaxisy.cpp \ | |
8 | $$PWD/qaxis.cpp \ |
|
|||
9 | $$PWD/qaxiscategories.cpp \ |
|
8 | $$PWD/qaxiscategories.cpp \ | |
10 | $$PWD/qcategoriesaxis.cpp \ |
|
9 | $$PWD/qcategoriesaxis.cpp \ | |
11 | $$PWD/qvaluesaxis.cpp \ |
|
10 | $$PWD/qvaluesaxis.cpp \ | |
@@ -15,14 +14,12 PRIVATE_HEADERS += \ | |||||
15 | $$PWD/chartaxis_p.h \ |
|
14 | $$PWD/chartaxis_p.h \ | |
16 | $$PWD/chartaxisx_p.h \ |
|
15 | $$PWD/chartaxisx_p.h \ | |
17 | $$PWD/chartaxisy_p.h \ |
|
16 | $$PWD/chartaxisy_p.h \ | |
18 | $$PWD/qaxis_p.h \ |
|
|||
19 | $$PWD/qaxiscategories_p.h \ |
|
17 | $$PWD/qaxiscategories_p.h \ | |
20 | $$PWD/qcategoriesaxis_p.h \ |
|
18 | $$PWD/qcategoriesaxis_p.h \ | |
21 | $$PWD/qvaluesaxis_p.h \ |
|
19 | $$PWD/qvaluesaxis_p.h \ | |
22 | $$PWD/qabstractaxis_p.h |
|
20 | $$PWD/qabstractaxis_p.h | |
23 |
|
21 | |||
24 | PUBLIC_HEADERS += \ |
|
22 | PUBLIC_HEADERS += \ | |
25 | $$PWD/qaxis.h \ |
|
|||
26 | $$PWD/qaxiscategories.h \ |
|
23 | $$PWD/qaxiscategories.h \ | |
27 | $$PWD/qcategoriesaxis.h \ |
|
24 | $$PWD/qcategoriesaxis.h \ | |
28 | $$PWD/qvaluesaxis.h \ |
|
25 | $$PWD/qvaluesaxis.h \ |
@@ -19,8 +19,8 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartaxis_p.h" |
|
21 | #include "chartaxis_p.h" | |
22 | #include "qaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qaxis_p.h" |
|
23 | #include "qabstractaxis_p.h" | |
24 | #include "qaxiscategories_p.h" |
|
24 | #include "qaxiscategories_p.h" | |
25 | #include "chartpresenter_p.h" |
|
25 | #include "chartpresenter_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
@@ -30,7 +30,7 | |||||
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter), |
|
33 | ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(presenter), | |
34 | m_chartAxis(axis), |
|
34 | m_chartAxis(axis), | |
35 | m_labelsAngle(0), |
|
35 | m_labelsAngle(0), | |
36 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), |
|
36 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), | |
@@ -52,7 +52,6 ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter), | |||||
52 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
52 | m_grid->setZValue(ChartPresenter::GridZValue); | |
53 |
|
53 | |||
54 | QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated())); |
|
54 | QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated())); | |
55 | QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated())); |
|
|||
56 |
|
55 | |||
57 | QGraphicsSimpleTextItem item; |
|
56 | QGraphicsSimpleTextItem item; | |
58 | m_font = item.font(); |
|
57 | m_font = item.font(); | |
@@ -150,7 +149,8 bool ChartAxis::createLabels(QStringList &labels,qreal min, qreal max,int ticks) | |||||
150 | Q_ASSERT(max>min); |
|
149 | Q_ASSERT(max>min); | |
151 | Q_ASSERT(ticks>1); |
|
150 | Q_ASSERT(ticks>1); | |
152 |
|
151 | |||
153 | QAxisCategories* categories = m_chartAxis->categories(); |
|
152 | //TODO:: QAxisCategories* categories = m_chartAxis->categories(); | |
|
153 | QAxisCategories* categories = new QAxisCategories(); | |||
154 |
|
154 | |||
155 | bool category = categories->count()>0; |
|
155 | bool category = categories->count()>0; | |
156 |
|
156 |
@@ -38,7 +38,7 | |||||
38 |
|
38 | |||
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | class QAxis; |
|
41 | class QAbstractAxis; | |
42 | class ChartPresenter; |
|
42 | class ChartPresenter; | |
43 |
|
43 | |||
44 | class ChartAxis : public Chart |
|
44 | class ChartAxis : public Chart | |
@@ -47,7 +47,7 class ChartAxis : public Chart | |||||
47 | public: |
|
47 | public: | |
48 | enum AxisType{ X_AXIS,Y_AXIS }; |
|
48 | enum AxisType{ X_AXIS,Y_AXIS }; | |
49 |
|
49 | |||
50 | ChartAxis(QAxis *axis, ChartPresenter *presenter); |
|
50 | ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter); | |
51 | ~ChartAxis(); |
|
51 | ~ChartAxis(); | |
52 |
|
52 | |||
53 | virtual AxisType axisType() const = 0; |
|
53 | virtual AxisType axisType() const = 0; | |
@@ -107,7 +107,7 private: | |||||
107 | void axisSelected(); |
|
107 | void axisSelected(); | |
108 |
|
108 | |||
109 | protected: |
|
109 | protected: | |
110 | QAxis* m_chartAxis; |
|
110 | QAbstractAxis* m_chartAxis; | |
111 | QRectF m_rect; |
|
111 | QRectF m_rect; | |
112 | int m_labelsAngle; |
|
112 | int m_labelsAngle; | |
113 | QScopedPointer<QGraphicsItemGroup> m_grid; |
|
113 | QScopedPointer<QGraphicsItemGroup> m_grid; |
@@ -19,8 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartaxisx_p.h" |
|
21 | #include "chartaxisx_p.h" | |
22 | #include "qaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qaxis_p.h" |
|
|||
24 | #include "qaxiscategories_p.h" |
|
23 | #include "qaxiscategories_p.h" | |
25 | #include "chartpresenter_p.h" |
|
24 | #include "chartpresenter_p.h" | |
26 | #include "chartanimator_p.h" |
|
25 | #include "chartanimator_p.h" | |
@@ -32,7 +31,7 static int label_padding = 5; | |||||
32 |
|
31 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
33 | |||
35 | ChartAxisX::ChartAxisX(QAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) |
|
34 | ChartAxisX::ChartAxisX(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) | |
36 | { |
|
35 | { | |
37 | } |
|
36 | } | |
38 |
|
37 |
@@ -34,13 +34,13 | |||||
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAxis; |
|
37 | class QAbstractAxis; | |
38 | class ChartPresenter; |
|
38 | class ChartPresenter; | |
39 |
|
39 | |||
40 | class ChartAxisX : public ChartAxis |
|
40 | class ChartAxisX : public ChartAxis | |
41 | { |
|
41 | { | |
42 | public: |
|
42 | public: | |
43 | ChartAxisX(QAxis *axis, ChartPresenter *presenter); |
|
43 | ChartAxisX(QAbstractAxis *axis, ChartPresenter *presenter); | |
44 | ~ChartAxisX(); |
|
44 | ~ChartAxisX(); | |
45 |
|
45 | |||
46 | AxisType axisType() const { return X_AXIS;} |
|
46 | AxisType axisType() const { return X_AXIS;} |
@@ -19,8 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartaxisy_p.h" |
|
21 | #include "chartaxisy_p.h" | |
22 | #include "qaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qaxis_p.h" |
|
|||
24 | #include "qaxiscategories_p.h" |
|
23 | #include "qaxiscategories_p.h" | |
25 | #include "chartpresenter_p.h" |
|
24 | #include "chartpresenter_p.h" | |
26 | #include "chartanimator_p.h" |
|
25 | #include "chartanimator_p.h" | |
@@ -32,7 +31,7 static int label_padding = 5; | |||||
32 |
|
31 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
33 | |||
35 | ChartAxisY::ChartAxisY(QAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) |
|
34 | ChartAxisY::ChartAxisY(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter) | |
36 | { |
|
35 | { | |
37 | } |
|
36 | } | |
38 |
|
37 |
@@ -34,13 +34,13 | |||||
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAxis; |
|
37 | class QAbstractAxis; | |
38 | class ChartPresenter; |
|
38 | class ChartPresenter; | |
39 |
|
39 | |||
40 | class ChartAxisY : public ChartAxis |
|
40 | class ChartAxisY : public ChartAxis | |
41 | { |
|
41 | { | |
42 | public: |
|
42 | public: | |
43 | ChartAxisY(QAxis *axis, ChartPresenter *presenter); |
|
43 | ChartAxisY(QAbstractAxis *axis, ChartPresenter *presenter); | |
44 | ~ChartAxisY(); |
|
44 | ~ChartAxisY(); | |
45 |
|
45 | |||
46 | AxisType axisType() const { return Y_AXIS;} |
|
46 | AxisType axisType() const { return Y_AXIS;} |
@@ -24,6 +24,7 | |||||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QFont> |
|
26 | #include <QFont> | |
|
27 | #include <QVariant> | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
30 | |||
@@ -101,7 +102,12 public: | |||||
101 | void setShadesBorderColor(QColor color); |
|
102 | void setShadesBorderColor(QColor color); | |
102 | QColor shadesBorderColor() const; |
|
103 | QColor shadesBorderColor() const; | |
103 |
|
104 | |||
104 | int ticksCount() const; |
|
105 | //range handling | |
|
106 | virtual void setMin(QVariant min) = 0; | |||
|
107 | virtual void setMax(QVariant max) = 0 ; | |||
|
108 | virtual void setRange(QVariant min, QVariant max) = 0; | |||
|
109 | ||||
|
110 | virtual int ticksCount() const = 0; | |||
105 |
|
111 | |||
106 | void show(); |
|
112 | void show(); | |
107 | void hide(); |
|
113 | void hide(); | |
@@ -110,18 +116,17 Q_SIGNALS: | |||||
110 | void visibleChanged(bool visible); |
|
116 | void visibleChanged(bool visible); | |
111 | void labelsVisibleChanged(bool visible); |
|
117 | void labelsVisibleChanged(bool visible); | |
112 | void gridVisibleChanged(bool visible); |
|
118 | void gridVisibleChanged(bool visible); | |
113 | void rangeChanged(); |
|
|||
114 | void colorChanged(QColor color); |
|
119 | void colorChanged(QColor color); | |
115 | void labelsColorChanged(QColor color); |
|
120 | void labelsColorChanged(QColor color); | |
116 | void shadesVisibleChanged(bool visible); |
|
121 | void shadesVisibleChanged(bool visible); | |
117 | void shadesColorChanged(QColor color); |
|
122 | void shadesColorChanged(QColor color); | |
118 | void shadesBorderColorChanged(QColor color); |
|
123 | void shadesBorderColorChanged(QColor color); | |
119 | void minChanged(); |
|
|||
120 | void maxChanged(); |
|
|||
121 |
|
124 | |||
122 | protected: |
|
125 | protected: | |
123 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
126 | QScopedPointer<QAbstractAxisPrivate> d_ptr; | |
124 | Q_DISABLE_COPY(QAbstractAxis) |
|
127 | Q_DISABLE_COPY(QAbstractAxis); | |
|
128 | friend class ChartDataSet; | |||
|
129 | friend class ChartAxis; | |||
125 | }; |
|
130 | }; | |
126 |
|
131 | |||
127 | QTCOMMERCIALCHART_END_NAMESPACE |
|
132 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -42,7 +42,7 QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbs | |||||
42 | /*! |
|
42 | /*! | |
43 | Appends \a categories to axis |
|
43 | Appends \a categories to axis | |
44 | */ |
|
44 | */ | |
45 | void QCategoriesAxis::append(QStringList &categories) |
|
45 | void QCategoriesAxis::append(const QStringList &categories) | |
46 | { |
|
46 | { | |
47 | Q_D(QCategoriesAxis); |
|
47 | Q_D(QCategoriesAxis); | |
48 | d->m_categories.append(categories); |
|
48 | d->m_categories.append(categories); | |
@@ -94,9 +94,9 void QCategoriesAxis::clear() | |||||
94 | /*! |
|
94 | /*! | |
95 | Returns number of categories. |
|
95 | Returns number of categories. | |
96 | */ |
|
96 | */ | |
97 | int QCategoriesAxis::count() |
|
97 | int QCategoriesAxis::count() const | |
98 | { |
|
98 | { | |
99 | Q_D(QCategoriesAxis); |
|
99 | Q_D(const QCategoriesAxis); | |
100 | return d->m_categories.count(); |
|
100 | return d->m_categories.count(); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
@@ -153,7 +153,25 QAbstractAxis::AxisType QCategoriesAxis::type() const | |||||
153 | return AxisTypeCategories; |
|
153 | return AxisTypeCategories; | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
|
156 | void QCategoriesAxis::setMin(QVariant min) | |||
|
157 | { | |||
|
158 | setMin(min.toString()); | |||
|
159 | } | |||
|
160 | ||||
|
161 | void QCategoriesAxis::setMax(QVariant max) | |||
|
162 | { | |||
|
163 | setMax(max.toString()); | |||
|
164 | } | |||
|
165 | ||||
|
166 | void QCategoriesAxis::setRange(QVariant min, QVariant max) | |||
|
167 | { | |||
|
168 | setRange(min.toString(),max.toString()); | |||
|
169 | } | |||
156 |
|
170 | |||
|
171 | int QCategoriesAxis::ticksCount() const | |||
|
172 | { | |||
|
173 | return count(); | |||
|
174 | } | |||
157 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
158 |
|
176 | |||
159 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
|
177 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
@@ -40,12 +40,12 protected: | |||||
40 |
|
40 | |||
41 | public: |
|
41 | public: | |
42 | AxisType type() const; |
|
42 | AxisType type() const; | |
43 | void append(QStringList &categories); |
|
43 | void append(const QStringList &categories); | |
44 | void append(const QString &category); |
|
44 | void append(const QString &category); | |
45 | void remove(const QString &category); |
|
45 | void remove(const QString &category); | |
46 | void insert(int index, const QString &category); |
|
46 | void insert(int index, const QString &category); | |
47 | void clear(); |
|
47 | void clear(); | |
48 | int count(); |
|
48 | int count() const; | |
49 |
|
49 | |||
50 | QString at(int index) const; |
|
50 | QString at(int index) const; | |
51 |
|
51 | |||
@@ -54,6 +54,13 public: | |||||
54 | void setMax(QString maxCategory); |
|
54 | void setMax(QString maxCategory); | |
55 | void setRange(QString minCategory, QString maxCategory); |
|
55 | void setRange(QString minCategory, QString maxCategory); | |
56 |
|
56 | |||
|
57 | private: | |||
|
58 | //range handling | |||
|
59 | void setMin(QVariant min); | |||
|
60 | void setMax(QVariant max); | |||
|
61 | void setRange(QVariant min, QVariant max); | |||
|
62 | int ticksCount() const; | |||
|
63 | ||||
57 | Q_SIGNALS: |
|
64 | Q_SIGNALS: | |
58 | void categoriesChanged(); |
|
65 | void categoriesChanged(); | |
59 |
|
66 |
@@ -130,6 +130,30 QAbstractAxis::AxisType QValuesAxis::type() const | |||||
130 | return AxisTypeValues; |
|
130 | return AxisTypeValues; | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
|
133 | void QValuesAxis::setMin(QVariant min) | |||
|
134 | { | |||
|
135 | bool ok; | |||
|
136 | qreal value = min.toReal(&ok); | |||
|
137 | if(ok) setMin(value); | |||
|
138 | } | |||
|
139 | ||||
|
140 | void QValuesAxis::setMax(QVariant max) | |||
|
141 | { | |||
|
142 | bool ok; | |||
|
143 | qreal value = max.toReal(&ok); | |||
|
144 | if(ok) setMax(value); | |||
|
145 | } | |||
|
146 | ||||
|
147 | void QValuesAxis::setRange(QVariant min, QVariant max) | |||
|
148 | { | |||
|
149 | bool ok1; | |||
|
150 | bool ok2; | |||
|
151 | qreal value1 = min.toReal(&ok1); | |||
|
152 | qreal value2 = max.toReal(&ok2); | |||
|
153 | if(ok1&&ok2) setRange(value1,value2); | |||
|
154 | } | |||
|
155 | ||||
|
156 | ||||
133 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
157 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
134 |
|
158 | |||
135 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
|
159 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
@@ -59,6 +59,12 public: | |||||
59 | void setNiceNumbersEnabled(bool enable = true); |
|
59 | void setNiceNumbersEnabled(bool enable = true); | |
60 | bool niceNumbersEnabled() const; |
|
60 | bool niceNumbersEnabled() const; | |
61 |
|
61 | |||
|
62 | private: | |||
|
63 | //range handling | |||
|
64 | void setMin(QVariant min); | |||
|
65 | void setMax(QVariant max); | |||
|
66 | void setRange(QVariant min, QVariant max); | |||
|
67 | ||||
62 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
63 | void minChanged(qreal min); |
|
69 | void minChanged(qreal min); | |
64 | void maxChanged(qreal max); |
|
70 | void maxChanged(qreal max); |
@@ -20,8 +20,8 | |||||
20 |
|
20 | |||
21 | #include "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qaxis.h" |
|
23 | #include "qvaluesaxis.h" | |
24 | #include "qaxis_p.h" |
|
24 | #include "qvaluesaxis_p.h" | |
25 | #include "qabstractseries_p.h" |
|
25 | #include "qabstractseries_p.h" | |
26 | #include "qbarseries.h" |
|
26 | #include "qbarseries.h" | |
27 | #include "qstackedbarseries.h" |
|
27 | #include "qstackedbarseries.h" | |
@@ -31,8 +31,8 | |||||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent), |
|
33 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent), | |
34 | m_axisX(new QAxis(this)), |
|
34 | m_axisX(new QValuesAxis(this)), | |
35 | m_axisY(new QAxis(this)), |
|
35 | m_axisY(new QValuesAxis(this)), | |
36 | m_domainIndex(0), |
|
36 | m_domainIndex(0), | |
37 | m_axisXInitialized(false), |
|
37 | m_axisXInitialized(false), | |
38 | m_axisYInitialized(false) |
|
38 | m_axisYInitialized(false) | |
@@ -51,11 +51,12 ChartDataSet::~ChartDataSet() | |||||
51 | removeAllSeries(); |
|
51 | removeAllSeries(); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 |
void ChartDataSet::addSeries(QAbstractSeries* series |
|
54 | void ChartDataSet::addSeries(QAbstractSeries* series) | |
55 | { |
|
55 | { | |
56 | if(axisY==0) axisY = m_axisY; |
|
56 | //TODO: if(axisY==0) axisY = m_axisY; | |
|
57 | QAbstractAxis* axisY = m_axisY; | |||
57 |
|
58 | |||
58 | QAxis* axis = m_seriesAxisMap.value(series); |
|
59 | QAbstractAxis* axis = m_seriesAxisMap.value(series); | |
59 |
|
60 | |||
60 | if(axis) { |
|
61 | if(axis) { | |
61 | qWarning() << "Can not add series. Series already on the chart"; |
|
62 | qWarning() << "Can not add series. Series already on the chart"; | |
@@ -116,9 +117,9 void ChartDataSet::addSeries(QAbstractSeries* series, QAxis *axisY) | |||||
116 |
|
117 | |||
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | QAxis* ChartDataSet::removeSeries(QAbstractSeries* series) |
|
120 | QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series) | |
120 | { |
|
121 | { | |
121 | QAxis* axis = m_seriesAxisMap.value(series); |
|
122 | QAbstractAxis* axis = m_seriesAxisMap.value(series); | |
122 |
|
123 | |||
123 | if(!axis){ |
|
124 | if(!axis){ | |
124 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
125 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
@@ -137,7 +138,7 QAxis* ChartDataSet::removeSeries(QAbstractSeries* series) | |||||
137 | series->d_ptr->m_chart = 0; |
|
138 | series->d_ptr->m_chart = 0; | |
138 | series->d_ptr->m_dataset = 0; |
|
139 | series->d_ptr->m_dataset = 0; | |
139 |
|
140 | |||
140 | QList<QAxis*> axes = m_seriesAxisMap.values(); |
|
141 | QList<QAbstractAxis*> axes = m_seriesAxisMap.values(); | |
141 |
|
142 | |||
142 | int i = axes.indexOf(axis); |
|
143 | int i = axes.indexOf(axis); | |
143 |
|
144 | |||
@@ -165,9 +166,9 QAxis* ChartDataSet::removeSeries(QAbstractSeries* series) | |||||
165 | void ChartDataSet::removeAllSeries() |
|
166 | void ChartDataSet::removeAllSeries() | |
166 | { |
|
167 | { | |
167 | QList<QAbstractSeries*> series = m_seriesAxisMap.keys(); |
|
168 | QList<QAbstractSeries*> series = m_seriesAxisMap.keys(); | |
168 | QList<QAxis*> axes; |
|
169 | QList<QAbstractAxis*> axes; | |
169 | foreach(QAbstractSeries *s , series) { |
|
170 | foreach(QAbstractSeries *s , series) { | |
170 | QAxis* axis = removeSeries(s); |
|
171 | QAbstractAxis* axis = removeSeries(s); | |
171 | if(axis==axisY()) continue; |
|
172 | if(axis==axisY()) continue; | |
172 | int i = axes.indexOf(axis); |
|
173 | int i = axes.indexOf(axis); | |
173 | if(i==-1){ |
|
174 | if(i==-1){ | |
@@ -184,7 +185,7 void ChartDataSet::removeAllSeries() | |||||
184 |
|
185 | |||
185 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
186 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
186 | { |
|
187 | { | |
187 | QMapIterator<QAxis*, Domain*> i(m_axisDomainMap); |
|
188 | QMapIterator<QAbstractAxis*, Domain*> i(m_axisDomainMap); | |
188 | //main domain has to be the last one; |
|
189 | //main domain has to be the last one; | |
189 | Domain *domain = m_axisDomainMap.value(axisY()); |
|
190 | Domain *domain = m_axisDomainMap.value(axisY()); | |
190 | Q_ASSERT(domain); |
|
191 | Q_ASSERT(domain); | |
@@ -198,7 +199,7 void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |||||
198 |
|
199 | |||
199 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
200 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
200 | { |
|
201 | { | |
201 | QMapIterator<QAxis*, Domain*> i(m_axisDomainMap); |
|
202 | QMapIterator<QAbstractAxis*, Domain*> i(m_axisDomainMap); | |
202 | //main domain has to be the last one; |
|
203 | //main domain has to be the last one; | |
203 | Domain *domain = m_axisDomainMap.value(axisY()); |
|
204 | Domain *domain = m_axisDomainMap.value(axisY()); | |
204 | Q_ASSERT(domain); |
|
205 | Q_ASSERT(domain); | |
@@ -213,7 +214,7 void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |||||
213 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
|
214 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |
214 | { |
|
215 | { | |
215 | int count=0; |
|
216 | int count=0; | |
216 | QMapIterator<QAbstractSeries*, QAxis*> i(m_seriesAxisMap); |
|
217 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisMap); | |
217 | while (i.hasNext()) { |
|
218 | while (i.hasNext()) { | |
218 | i.next(); |
|
219 | i.next(); | |
219 | if(i.key()->type()==type) count++; |
|
220 | if(i.key()->type()==type) count++; | |
@@ -232,7 +233,7 int ChartDataSet::seriesIndex(QAbstractSeries *series) | |||||
232 | return -1; |
|
233 | return -1; | |
233 | } |
|
234 | } | |
234 |
|
235 | |||
235 | QAxis* ChartDataSet::axisY(QAbstractSeries *series) const |
|
236 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |
236 | { |
|
237 | { | |
237 | if(series == 0) return m_axisY; |
|
238 | if(series == 0) return m_axisY; | |
238 | return m_seriesAxisMap.value(series); |
|
239 | return m_seriesAxisMap.value(series); | |
@@ -240,14 +241,14 QAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |||||
240 |
|
241 | |||
241 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
|
242 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
242 | { |
|
243 | { | |
243 |
|
|
244 | QAbstractAxis* axis = m_seriesAxisMap.value(series); | |
244 | if(axis){ |
|
245 | if(axis){ | |
245 | return m_axisDomainMap.value(axis); |
|
246 | return m_axisDomainMap.value(axis); | |
246 | }else |
|
247 | }else | |
247 | return 0; |
|
248 | return 0; | |
248 | } |
|
249 | } | |
249 |
|
250 | |||
250 | Domain* ChartDataSet::domain(QAxis* axis) const |
|
251 | Domain* ChartDataSet::domain(QAbstractAxis* axis) const | |
251 | { |
|
252 | { | |
252 | if(!axis || axis==axisX()) { |
|
253 | if(!axis || axis==axisX()) { | |
253 | return m_axisDomainMap.value(axisY()); |
|
254 | return m_axisDomainMap.value(axisY()); | |
@@ -259,7 +260,7 Domain* ChartDataSet::domain(QAxis* axis) const | |||||
259 |
|
260 | |||
260 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
261 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) | |
261 | { |
|
262 | { | |
262 | QMapIterator<QAxis*, Domain*> i( m_axisDomainMap); |
|
263 | QMapIterator<QAbstractAxis*, Domain*> i( m_axisDomainMap); | |
263 | //main domain has to be the last one; |
|
264 | //main domain has to be the last one; | |
264 | Domain *domain = m_axisDomainMap.value(axisY()); |
|
265 | Domain *domain = m_axisDomainMap.value(axisY()); | |
265 | while (i.hasNext()) { |
|
266 | while (i.hasNext()) { |
@@ -36,7 +36,7 | |||||
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QAxis; |
|
39 | class QAbstractAxis; | |
40 |
|
40 | |||
41 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject |
|
41 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject | |
42 | { |
|
42 | { | |
@@ -45,8 +45,8 public: | |||||
45 | ChartDataSet(QChart* parent=0); |
|
45 | ChartDataSet(QChart* parent=0); | |
46 | virtual ~ChartDataSet(); |
|
46 | virtual ~ChartDataSet(); | |
47 |
|
47 | |||
48 |
void addSeries(QAbstractSeries* series |
|
48 | void addSeries(QAbstractSeries* series); | |
49 | QAxis* removeSeries(QAbstractSeries* series); |
|
49 | QAbstractAxis* removeSeries(QAbstractSeries* series); | |
50 | void removeAllSeries(); |
|
50 | void removeAllSeries(); | |
51 | void updateSeries(QAbstractSeries* series); |
|
51 | void updateSeries(QAbstractSeries* series); | |
52 |
|
52 | |||
@@ -58,10 +58,10 public: | |||||
58 | int seriesIndex(QAbstractSeries *series); |
|
58 | int seriesIndex(QAbstractSeries *series); | |
59 |
|
59 | |||
60 | Domain* domain(QAbstractSeries* series) const; |
|
60 | Domain* domain(QAbstractSeries* series) const; | |
61 | Domain* domain(QAxis* axis) const; |
|
61 | Domain* domain(QAbstractAxis* axis) const; | |
62 |
|
62 | |||
63 | QAxis* axisX() const { return m_axisX; } |
|
63 | QAbstractAxis* axisX() const { return m_axisX; } | |
64 | QAxis* axisY(QAbstractSeries *series = 0) const; |
|
64 | QAbstractAxis* axisY(QAbstractSeries *series = 0) const; | |
65 |
|
65 | |||
66 | QList<QAbstractSeries*> series() const; |
|
66 | QList<QAbstractSeries*> series() const; | |
67 |
|
67 | |||
@@ -69,19 +69,19 Q_SIGNALS: | |||||
69 | void seriesAdded(QAbstractSeries* series, Domain* domain); |
|
69 | void seriesAdded(QAbstractSeries* series, Domain* domain); | |
70 | void seriesRemoved(QAbstractSeries* series); |
|
70 | void seriesRemoved(QAbstractSeries* series); | |
71 | void seriesUpdated(QAbstractSeries* series); |
|
71 | void seriesUpdated(QAbstractSeries* series); | |
72 | void axisAdded(QAxis* axis,Domain* domain); |
|
72 | void axisAdded(QAbstractAxis* axis,Domain* domain); | |
73 | void axisRemoved(QAxis* axis); |
|
73 | void axisRemoved(QAbstractAxis* axis); | |
74 |
|
74 | |||
75 | private: |
|
75 | private: | |
76 | QStringList createLabels(QAxis* axis,qreal min, qreal max); |
|
76 | QStringList createLabels(QAbstractAxis* axis,qreal min, qreal max); | |
77 | void calculateDomain(QAbstractSeries* series,Domain* domain); |
|
77 | void calculateDomain(QAbstractSeries* series,Domain* domain); | |
78 |
|
78 | |||
79 | private: |
|
79 | private: | |
80 |
QMap<QAbstractSeries |
|
80 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisMap; | |
81 |
QMap<QAxis*, Domain |
|
81 | QMap<QAbstractAxis*, Domain*> m_axisDomainMap; | |
82 |
QMap<int, QAbstractSeries |
|
82 | QMap<int, QAbstractSeries*> m_indexSeriesMap; | |
83 | QAxis* m_axisX; |
|
83 | QAbstractAxis* m_axisX; | |
84 | QAxis* m_axisY; |
|
84 | QAbstractAxis* m_axisY; | |
85 |
|
85 | |||
86 | int m_domainIndex; |
|
86 | int m_domainIndex; | |
87 | bool m_axisXInitialized; |
|
87 | bool m_axisXInitialized; |
@@ -20,7 +20,7 | |||||
20 | #include "chartpresenter_p.h" |
|
20 | #include "chartpresenter_p.h" | |
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "qaxis.h" |
|
23 | #include "qabstractaxis.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
@@ -67,7 +67,7 void ChartPresenter::setGeometry(const QRectF& rect) | |||||
67 | } |
|
67 | } | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | void ChartPresenter::handleAxisAdded(QAxis* axis,Domain* domain) |
|
70 | void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) | |
71 | { |
|
71 | { | |
72 | ChartAxis* item; |
|
72 | ChartAxis* item; | |
73 |
|
73 | |||
@@ -102,7 +102,7 void ChartPresenter::handleAxisAdded(QAxis* axis,Domain* domain) | |||||
102 | m_axisItems.insert(axis, item); |
|
102 | m_axisItems.insert(axis, item); | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | void ChartPresenter::handleAxisRemoved(QAxis* axis) |
|
105 | void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis) | |
106 | { |
|
106 | { | |
107 | ChartAxis* item = m_axisItems.take(axis); |
|
107 | ChartAxis* item = m_axisItems.take(axis); | |
108 | Q_ASSERT(item); |
|
108 | Q_ASSERT(item); | |
@@ -177,10 +177,10 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | |||||
177 |
|
177 | |||
178 | void ChartPresenter::resetAllElements() |
|
178 | void ChartPresenter::resetAllElements() | |
179 | { |
|
179 | { | |
180 |
QList<QAxis |
|
180 | QList<QAbstractAxis*> axisList = m_axisItems.uniqueKeys(); | |
181 | QList<QAbstractSeries *> seriesList = m_chartItems.uniqueKeys(); |
|
181 | QList<QAbstractSeries *> seriesList = m_chartItems.uniqueKeys(); | |
182 |
|
182 | |||
183 | foreach(QAxis *axis, axisList) { |
|
183 | foreach(QAbstractAxis *axis, axisList) { | |
184 | handleAxisRemoved(axis); |
|
184 | handleAxisRemoved(axis); | |
185 | handleAxisAdded(axis,m_dataset->domain(axis)); |
|
185 | handleAxisAdded(axis,m_dataset->domain(axis)); | |
186 | } |
|
186 | } |
@@ -141,8 +141,8 private: | |||||
141 | public Q_SLOTS: |
|
141 | public Q_SLOTS: | |
142 | void handleSeriesAdded(QAbstractSeries* series,Domain* domain); |
|
142 | void handleSeriesAdded(QAbstractSeries* series,Domain* domain); | |
143 | void handleSeriesRemoved(QAbstractSeries* series); |
|
143 | void handleSeriesRemoved(QAbstractSeries* series); | |
144 | void handleAxisAdded(QAxis* axis,Domain* domain); |
|
144 | void handleAxisAdded(QAbstractAxis* axis,Domain* domain); | |
145 | void handleAxisRemoved(QAxis* axis); |
|
145 | void handleAxisRemoved(QAbstractAxis* axis); | |
146 |
|
146 | |||
147 | private Q_SLOTS: |
|
147 | private Q_SLOTS: | |
148 | void handleAnimationFinished(); |
|
148 | void handleAnimationFinished(); | |
@@ -158,7 +158,7 private: | |||||
158 | ChartDataSet* m_dataset; |
|
158 | ChartDataSet* m_dataset; | |
159 | ChartTheme *m_chartTheme; |
|
159 | ChartTheme *m_chartTheme; | |
160 |
QMap<QAbstractSeries |
|
160 | QMap<QAbstractSeries*, Chart*> m_chartItems; | |
161 |
QMap<QAxis |
|
161 | QMap<QAbstractAxis*, ChartAxis*> m_axisItems; | |
162 | QRectF m_rect; |
|
162 | QRectF m_rect; | |
163 | QChart::AnimationOptions m_options; |
|
163 | QChart::AnimationOptions m_options; | |
164 | State m_state; |
|
164 | State m_state; |
@@ -23,7 +23,7 | |||||
23 | #include "qchart_p.h" |
|
23 | #include "qchart_p.h" | |
24 | #include "qchartview.h" |
|
24 | #include "qchartview.h" | |
25 | #include "qlegend.h" |
|
25 | #include "qlegend.h" | |
26 | #include "qaxis.h" |
|
26 | #include "qabstractaxis.h" | |
27 | #include <QTime> |
|
27 | #include <QTime> | |
28 |
|
28 | |||
29 | //series |
|
29 | //series | |
@@ -256,7 +256,7 void ChartTheme::decorate(QSplineSeries *series, int index) | |||||
256 | } |
|
256 | } | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 | void ChartTheme::decorate(QAxis *axis,bool axisX) |
|
259 | void ChartTheme::decorate(QAbstractAxis *axis,bool axisX) | |
260 | { |
|
260 | { | |
261 | QPen pen; |
|
261 | QPen pen; | |
262 | QBrush brush; |
|
262 | QBrush brush; |
@@ -78,7 +78,7 public: | |||||
78 | void decorate(QScatterSeries *series, int index); |
|
78 | void decorate(QScatterSeries *series, int index); | |
79 | void decorate(QPieSeries *series, int index); |
|
79 | void decorate(QPieSeries *series, int index); | |
80 | void decorate(QSplineSeries *series, int index); |
|
80 | void decorate(QSplineSeries *series, int index); | |
81 | void decorate(QAxis *axis, bool axisX); |
|
81 | void decorate(QAbstractAxis *axis, bool axisX); | |
82 | void setForced(bool enabled); |
|
82 | void setForced(bool enabled); | |
83 | bool isForced() { return m_force; } |
|
83 | bool isForced() { return m_force; } | |
84 |
|
84 |
@@ -23,7 +23,7 | |||||
23 | #include "legendscroller_p.h" |
|
23 | #include "legendscroller_p.h" | |
24 | #include "qlegend_p.h" |
|
24 | #include "qlegend_p.h" | |
25 | #include "chartbackground_p.h" |
|
25 | #include "chartbackground_p.h" | |
26 | #include "qaxis.h" |
|
26 | #include "qabstractaxis.h" | |
27 | #include <QGraphicsScene> |
|
27 | #include <QGraphicsScene> | |
28 | #include <QGraphicsSceneResizeEvent> |
|
28 | #include <QGraphicsSceneResizeEvent> | |
29 | #include <QGraphicsLayout> |
|
29 | #include <QGraphicsLayout> | |
@@ -140,10 +140,10 QChart::~QChart() | |||||
140 |
|
140 | |||
141 | \sa removeSeries(), removeAllSeries() |
|
141 | \sa removeSeries(), removeAllSeries() | |
142 | */ |
|
142 | */ | |
143 |
void QChart::addSeries(QAbstractSeries *series |
|
143 | void QChart::addSeries(QAbstractSeries *series) | |
144 | { |
|
144 | { | |
145 | Q_ASSERT(series); |
|
145 | Q_ASSERT(series); | |
146 |
d_ptr->m_dataset->addSeries(series |
|
146 | d_ptr->m_dataset->addSeries(series); | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
@@ -308,7 +308,7 void QChart::zoom(qreal factor) | |||||
308 | /*! |
|
308 | /*! | |
309 | Returns the pointer to the x axis object of the chart |
|
309 | Returns the pointer to the x axis object of the chart | |
310 | */ |
|
310 | */ | |
311 | QAxis* QChart::axisX() const |
|
311 | QAbstractAxis* QChart::axisX() const | |
312 | { |
|
312 | { | |
313 | return d_ptr->m_dataset->axisX(); |
|
313 | return d_ptr->m_dataset->axisX(); | |
314 | } |
|
314 | } | |
@@ -317,7 +317,7 QAxis* QChart::axisX() const | |||||
317 | Returns the pointer to the y axis object of the \a series |
|
317 | Returns the pointer to the y axis object of the \a series | |
318 | If no \a series is provided then default Y axis of the chart is returned. |
|
318 | If no \a series is provided then default Y axis of the chart is returned. | |
319 | */ |
|
319 | */ | |
320 | QAxis* QChart::axisY(QAbstractSeries *series) const |
|
320 | QAbstractAxis* QChart::axisY(QAbstractSeries *series) const | |
321 | { |
|
321 | { | |
322 | return d_ptr->m_dataset->axisY(series); |
|
322 | return d_ptr->m_dataset->axisY(series); | |
323 | } |
|
323 | } | |
@@ -428,6 +428,18 void QChart::setMarginsMinimum(const QRectF& margins) | |||||
428 | d_ptr->m_presenter->setMarginsMinimum(margins); |
|
428 | d_ptr->m_presenter->setMarginsMinimum(margins); | |
429 | } |
|
429 | } | |
430 |
|
430 | |||
|
431 | void QChart::setAxisX(QAbstractSeries *series, QAbstractAxis* axis) | |||
|
432 | { | |||
|
433 | Q_UNUSED(series); | |||
|
434 | Q_UNUSED(axis); | |||
|
435 | } | |||
|
436 | ||||
|
437 | void QChart::setAxisY(QAbstractSeries *series, QAbstractAxis* axis) | |||
|
438 | { | |||
|
439 | Q_UNUSED(series); | |||
|
440 | Q_UNUSED(axis); | |||
|
441 | } | |||
|
442 | ||||
431 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
443 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
432 |
|
444 | |||
433 | QChartPrivate::QChartPrivate(): |
|
445 | QChartPrivate::QChartPrivate(): | |
@@ -447,8 +459,8 void QChartPrivate::createConnections() | |||||
447 | { |
|
459 | { | |
448 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
460 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
449 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
461 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
450 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAxis*,Domain*))); |
|
462 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*))); | |
451 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAxis*)),m_presenter,SLOT(handleAxisRemoved(QAxis*))); |
|
463 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*))); | |
452 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); |
|
464 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); | |
453 | } |
|
465 | } | |
454 |
|
466 |
@@ -30,7 +30,7 class QGraphicsSceneResizeEvent; | |||||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QAbstractSeries; |
|
32 | class QAbstractSeries; | |
33 | class QAxis; |
|
33 | class QAbstractAxis; | |
34 | class QLegend; |
|
34 | class QLegend; | |
35 | struct QChartPrivate; |
|
35 | struct QChartPrivate; | |
36 |
|
36 | |||
@@ -70,11 +70,14 public: | |||||
70 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
70 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
71 | ~QChart(); |
|
71 | ~QChart(); | |
72 |
|
72 | |||
73 |
void addSeries(QAbstractSeries *series |
|
73 | void addSeries(QAbstractSeries *series); | |
74 | void removeSeries(QAbstractSeries *series); |
|
74 | void removeSeries(QAbstractSeries *series); | |
75 | void removeAllSeries(); |
|
75 | void removeAllSeries(); | |
76 | QList<QAbstractSeries*> series() const; |
|
76 | QList<QAbstractSeries*> series() const; | |
77 |
|
77 | |||
|
78 | void setAxisX(QAbstractSeries *series, QAbstractAxis* axis); | |||
|
79 | void setAxisY(QAbstractSeries *series, QAbstractAxis* axis); | |||
|
80 | ||||
78 | void setTheme(QChart::ChartTheme theme); |
|
81 | void setTheme(QChart::ChartTheme theme); | |
79 | QChart::ChartTheme theme() const; |
|
82 | QChart::ChartTheme theme() const; | |
80 |
|
83 | |||
@@ -107,8 +110,8 public: | |||||
107 | void scrollDown(); |
|
110 | void scrollDown(); | |
108 | void scroll(const QPointF &delta); |
|
111 | void scroll(const QPointF &delta); | |
109 |
|
112 | |||
110 | QAxis* axisX() const; |
|
113 | QAbstractAxis* axisX() const; | |
111 | QAxis* axisY(QAbstractSeries* series = 0) const; |
|
114 | QAbstractAxis* axisY(QAbstractSeries* series = 0) const; | |
112 |
|
115 | |||
113 | QLegend* legend() const; |
|
116 | QLegend* legend() const; | |
114 |
|
117 |
@@ -21,7 +21,7 | |||||
21 | #ifndef QCHARTVIEW_H |
|
21 | #ifndef QCHARTVIEW_H | |
22 | #define QCHARTVIEW_H |
|
22 | #define QCHARTVIEW_H | |
23 |
|
23 | |||
24 | #include <QAxis> |
|
24 | #include <QAbstractAxis> | |
25 | #include <QAbstractSeries> |
|
25 | #include <QAbstractSeries> | |
26 | #include <QChart> |
|
26 | #include <QChart> | |
27 | #include <QGraphicsView> |
|
27 | #include <QGraphicsView> |
@@ -6,5 +6,5 TEMPLATE = subdirs | |||||
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper qsplineseries qscatterseries qxymodelmapper qbarmodelmapper |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper qsplineseries qscatterseries qxymodelmapper qbarmodelmapper | |
7 |
|
7 | |||
8 | test_private:{ |
|
8 | test_private:{ | |
9 |
SUBDIRS += chartdataset |
|
9 | SUBDIRS += domain #chartdataset | |
10 | } |
|
10 | } |
@@ -19,7 +19,7 | |||||
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qaxis.h> |
|
22 | #include <qabstractaxis.h> | |
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <private/chartdataset_p.h> |
|
24 | #include <private/chartdataset_p.h> | |
25 | #include <private/domain_p.h> |
|
25 | #include <private/domain_p.h> | |
@@ -28,7 +28,7 | |||||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | Q_DECLARE_METATYPE(Domain *) |
|
30 | Q_DECLARE_METATYPE(Domain *) | |
31 | Q_DECLARE_METATYPE(QAxis *) |
|
31 | Q_DECLARE_METATYPE(QAbstractAxis *) | |
32 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
32 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
33 | Q_DECLARE_METATYPE(QLineSeries *) |
|
33 | Q_DECLARE_METATYPE(QLineSeries *) | |
34 |
|
34 |
@@ -20,7 +20,6 | |||||
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <private/domain_p.h> |
|
22 | #include <private/domain_p.h> | |
23 | #include <qaxis.h> |
|
|||
24 | #include <tst_definitions.h> |
|
23 | #include <tst_definitions.h> | |
25 |
|
24 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
@@ -28,10 +28,12 | |||||
28 | #include <qbarseries.h> |
|
28 | #include <qbarseries.h> | |
29 | #include <qpercentbarseries.h> |
|
29 | #include <qpercentbarseries.h> | |
30 | #include <qstackedbarseries.h> |
|
30 | #include <qstackedbarseries.h> | |
|
31 | #include <qvaluesaxis.h> | |||
31 |
|
32 | |||
32 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
33 | QTCOMMERCIALCHART_USE_NAMESPACE | |
33 |
|
34 | |||
34 | Q_DECLARE_METATYPE(QAxis *) |
|
35 | Q_DECLARE_METATYPE(QAbstractAxis *) | |
|
36 | Q_DECLARE_METATYPE(QValuesAxis *) | |||
35 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
37 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
36 | Q_DECLARE_METATYPE(QChart::AnimationOption) |
|
38 | Q_DECLARE_METATYPE(QChart::AnimationOption) | |
37 | Q_DECLARE_METATYPE(QBrush) |
|
39 | Q_DECLARE_METATYPE(QBrush) | |
@@ -177,7 +179,7 void tst_QChart::qchart() | |||||
177 | void tst_QChart::addSeries_data() |
|
179 | void tst_QChart::addSeries_data() | |
178 | { |
|
180 | { | |
179 | QTest::addColumn<QAbstractSeries *>("series"); |
|
181 | QTest::addColumn<QAbstractSeries *>("series"); | |
180 | QTest::addColumn<QAxis *>("axis"); |
|
182 | QTest::addColumn<QAbstractAxis *>("axis"); | |
181 |
|
183 | |||
182 | QAbstractSeries* series0 = new QLineSeries(this); |
|
184 | QAbstractSeries* series0 = new QLineSeries(this); | |
183 | QAbstractSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); |
|
185 | QAbstractSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); | |
@@ -188,23 +190,23 void tst_QChart::addSeries_data() | |||||
188 | QAbstractSeries* series6 = new QPercentBarSeries(this); |
|
190 | QAbstractSeries* series6 = new QPercentBarSeries(this); | |
189 | QAbstractSeries* series7 = new QStackedBarSeries(this); |
|
191 | QAbstractSeries* series7 = new QStackedBarSeries(this); | |
190 |
|
192 | |||
191 | QAxis* axis = new QAxis(this); |
|
193 | QValuesAxis* axis = new QValuesAxis(this); | |
192 |
|
194 | |||
193 | QTest::newRow("default axis: lineSeries") << series0 << (QAxis*) 0; |
|
195 | QTest::newRow("default axis: lineSeries") << series0 << (QAbstractAxis*) 0; | |
194 | QTest::newRow("axis0: lineSeries") << series0 << axis; |
|
196 | QTest::newRow("axis0: lineSeries") << series0 << axis; | |
195 | QTest::newRow("default axis: areaSeries") << series1 << (QAxis*) 0; |
|
197 | QTest::newRow("default axis: areaSeries") << series1 << (QAbstractAxis*) 0; | |
196 | QTest::newRow("axis: areaSeries") << series1 << axis; |
|
198 | QTest::newRow("axis: areaSeries") << series1 << axis; | |
197 | QTest::newRow("default axis: scatterSeries") << series2 << (QAxis*) 0; |
|
199 | QTest::newRow("default axis: scatterSeries") << series2 << (QAbstractAxis*) 0; | |
198 | QTest::newRow("axis1: scatterSeries") << series2 << axis; |
|
200 | QTest::newRow("axis1: scatterSeries") << series2 << axis; | |
199 | QTest::newRow("default axis: splineSeries") << series3 << (QAxis*) 0; |
|
201 | QTest::newRow("default axis: splineSeries") << series3 << (QAbstractAxis*) 0; | |
200 | QTest::newRow("axis: splineSeries") << series3 << axis; |
|
202 | QTest::newRow("axis: splineSeries") << series3 << axis; | |
201 | QTest::newRow("default axis: pieSeries") << series4 << (QAxis*) 0; |
|
203 | QTest::newRow("default axis: pieSeries") << series4 << (QAbstractAxis*) 0; | |
202 | QTest::newRow("axis: pieSeries") << series4 << axis; |
|
204 | QTest::newRow("axis: pieSeries") << series4 << axis; | |
203 | QTest::newRow("default axis: barSeries") << series5 << (QAxis*) 0; |
|
205 | QTest::newRow("default axis: barSeries") << series5 << (QAbstractAxis*) 0; | |
204 | QTest::newRow("axis: barSeries") << series5 << axis; |
|
206 | QTest::newRow("axis: barSeries") << series5 << axis; | |
205 | QTest::newRow("default axis: percentBarSeries") << series6 << (QAxis*) 0; |
|
207 | QTest::newRow("default axis: percentBarSeries") << series6 << (QAbstractAxis*) 0; | |
206 | QTest::newRow("axis: barSeries") << series6 << axis; |
|
208 | QTest::newRow("axis: barSeries") << series6 << axis; | |
207 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QAxis*) 0; |
|
209 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QAbstractAxis*) 0; | |
208 | QTest::newRow("axis: barSeries") << series7 << axis; |
|
210 | QTest::newRow("axis: barSeries") << series7 << axis; | |
209 |
|
211 | |||
210 | } |
|
212 | } | |
@@ -212,13 +214,14 void tst_QChart::addSeries_data() | |||||
212 | void tst_QChart::addSeries() |
|
214 | void tst_QChart::addSeries() | |
213 | { |
|
215 | { | |
214 | QFETCH(QAbstractSeries *, series); |
|
216 | QFETCH(QAbstractSeries *, series); | |
215 | QFETCH(QAxis *, axis); |
|
217 | QFETCH(QAbstractAxis *, axis); | |
216 | m_view->show(); |
|
218 | m_view->show(); | |
217 | QTest::qWaitForWindowShown(m_view); |
|
219 | QTest::qWaitForWindowShown(m_view); | |
218 | if(!axis) axis = m_chart->axisY(); |
|
220 | if(!axis) axis = m_chart->axisY(); | |
219 | QVERIFY(!series->chart()); |
|
221 | QVERIFY(!series->chart()); | |
220 | QCOMPARE(m_chart->series().count(), 0); |
|
222 | QCOMPARE(m_chart->series().count(), 0); | |
221 |
m_chart->addSeries(series |
|
223 | m_chart->addSeries(series); | |
|
224 | m_chart->setAxisY(series,axis); | |||
222 | QCOMPARE(m_chart->series().count(), 1); |
|
225 | QCOMPARE(m_chart->series().count(), 1); | |
223 | QCOMPARE(m_chart->series().first(), series); |
|
226 | QCOMPARE(m_chart->series().first(), series); | |
224 | QVERIFY(series->chart() == m_chart); |
|
227 | QVERIFY(series->chart() == m_chart); | |
@@ -253,7 +256,7 void tst_QChart::axisX_data() | |||||
253 | void tst_QChart::axisX() |
|
256 | void tst_QChart::axisX() | |
254 | { |
|
257 | { | |
255 | QVERIFY(m_chart->axisX()); |
|
258 | QVERIFY(m_chart->axisX()); | |
256 | QAxis* axis = m_chart->axisX(); |
|
259 | QAbstractAxis* axis = m_chart->axisX(); | |
257 | createTestData(); |
|
260 | createTestData(); | |
258 | //it should be the same axis |
|
261 | //it should be the same axis | |
259 | QCOMPARE(axis,m_chart->axisX()); |
|
262 | QCOMPARE(axis,m_chart->axisX()); | |
@@ -261,32 +264,35 void tst_QChart::axisX() | |||||
261 |
|
264 | |||
262 | void tst_QChart::axisY_data() |
|
265 | void tst_QChart::axisY_data() | |
263 | { |
|
266 | { | |
264 | QTest::addColumn<QAxis*>("axis0"); |
|
267 | QTest::addColumn<QAbstractAxis*>("axis0"); | |
265 | QTest::addColumn<QAxis*>("axis1"); |
|
268 | QTest::addColumn<QAbstractAxis*>("axis1"); | |
266 | QTest::addColumn<QAxis*>("axis2"); |
|
269 | QTest::addColumn<QAbstractAxis*>("axis2"); | |
267 | QTest::newRow("1 defualt, 2 optional") << (QAxis*)0 << new QAxis() << new QAxis(); |
|
270 | QTest::newRow("1 defualt, 2 optional") << (QAbstractAxis*)0 << new QValuesAxis() << new QValuesAxis(); | |
268 | QTest::newRow("3 optional") << new QAxis() << new QAxis() << new QAxis(); |
|
271 | QTest::newRow("3 optional") << new QValuesAxis() << new QValuesAxis() << new QValuesAxis(); | |
269 | } |
|
272 | } | |
270 |
|
273 | |||
271 |
|
274 | |||
272 | void tst_QChart::axisY() |
|
275 | void tst_QChart::axisY() | |
273 | { |
|
276 | { | |
274 | QFETCH(QAxis*, axis0); |
|
277 | QFETCH(QAbstractAxis*, axis0); | |
275 | QFETCH(QAxis*, axis1); |
|
278 | QFETCH(QAbstractAxis*, axis1); | |
276 | QFETCH(QAxis*, axis2); |
|
279 | QFETCH(QAbstractAxis*, axis2); | |
277 |
|
280 | |||
278 | QAxis* defaultAxisY = m_chart->axisY(); |
|
281 | QAbstractAxis* defaultAxisY = m_chart->axisY(); | |
279 |
|
282 | |||
280 | QVERIFY2(defaultAxisY, "Missing axisY."); |
|
283 | QVERIFY2(defaultAxisY, "Missing axisY."); | |
281 |
|
284 | |||
282 | QLineSeries* series0 = new QLineSeries(); |
|
285 | QLineSeries* series0 = new QLineSeries(); | |
283 |
m_chart->addSeries(series0 |
|
286 | m_chart->addSeries(series0); | |
|
287 | m_chart->setAxisY(series0,axis0); | |||
284 |
|
288 | |||
285 | QLineSeries* series1 = new QLineSeries(); |
|
289 | QLineSeries* series1 = new QLineSeries(); | |
286 |
m_chart->addSeries(series1 |
|
290 | m_chart->addSeries(series1); | |
|
291 | m_chart->setAxisY(series1,axis1); | |||
287 |
|
292 | |||
288 | QLineSeries* series2 = new QLineSeries(); |
|
293 | QLineSeries* series2 = new QLineSeries(); | |
289 |
m_chart->addSeries(series2 |
|
294 | m_chart->addSeries(series2); | |
|
295 | m_chart->setAxisY(series2,axis2); | |||
290 |
|
296 | |||
291 | if (!axis0) |
|
297 | if (!axis0) | |
292 | axis0 = defaultAxisY; |
|
298 | axis0 = defaultAxisY; | |
@@ -412,12 +418,13 void tst_QChart::removeSeries_data() | |||||
412 | void tst_QChart::removeSeries() |
|
418 | void tst_QChart::removeSeries() | |
413 | { |
|
419 | { | |
414 | QFETCH(QAbstractSeries *, series); |
|
420 | QFETCH(QAbstractSeries *, series); | |
415 | QFETCH(QAxis *, axis); |
|
421 | QFETCH(QAbstractAxis *, axis); | |
416 | QSignalSpy deleteSpy(series, SIGNAL(destroyed())); |
|
422 | QSignalSpy deleteSpy(series, SIGNAL(destroyed())); | |
417 | m_view->show(); |
|
423 | m_view->show(); | |
418 | QTest::qWaitForWindowShown(m_view); |
|
424 | QTest::qWaitForWindowShown(m_view); | |
419 | if(!axis) axis = m_chart->axisY(); |
|
425 | if(!axis) axis = m_chart->axisY(); | |
420 |
m_chart->addSeries(series |
|
426 | m_chart->addSeries(series); | |
|
427 | m_chart->setAxisY(series,axis); | |||
421 | QCOMPARE(m_chart->axisY(series),axis); |
|
428 | QCOMPARE(m_chart->axisY(series),axis); | |
422 | m_chart->removeSeries(series); |
|
429 | m_chart->removeSeries(series); | |
423 | QVERIFY(m_chart->axisY(series)==0); |
|
430 | QVERIFY(m_chart->axisY(series)==0); | |
@@ -431,10 +438,11 void tst_QChart::scrollDown_data() | |||||
431 |
|
438 | |||
432 | void tst_QChart::scrollDown() |
|
439 | void tst_QChart::scrollDown() | |
433 | { |
|
440 | { | |
|
441 | qFatal("implement me"); | |||
434 | createTestData(); |
|
442 | createTestData(); | |
435 | qreal min = m_chart->axisY()->min(); |
|
443 | //TODO qreal min = m_chart->axisY()->min(); | |
436 | m_chart->scrollDown(); |
|
444 | m_chart->scrollDown(); | |
437 | QVERIFY(m_chart->axisY()->min()<min); |
|
445 | //TODO QVERIFY(m_chart->axisY()->min()<min); | |
438 | } |
|
446 | } | |
439 |
|
447 | |||
440 | void tst_QChart::scrollLeft_data() |
|
448 | void tst_QChart::scrollLeft_data() | |
@@ -444,10 +452,11 void tst_QChart::scrollLeft_data() | |||||
444 |
|
452 | |||
445 | void tst_QChart::scrollLeft() |
|
453 | void tst_QChart::scrollLeft() | |
446 | { |
|
454 | { | |
|
455 | qFatal("implement me"); | |||
447 | createTestData(); |
|
456 | createTestData(); | |
448 | qreal min = m_chart->axisX()->min(); |
|
457 | //TODO qreal min = m_chart->axisX()->min(); | |
449 | m_chart->scrollLeft(); |
|
458 | m_chart->scrollLeft(); | |
450 | QVERIFY(m_chart->axisX()->min()<min); |
|
459 | //TODO QVERIFY(m_chart->axisX()->min()<min); | |
451 | } |
|
460 | } | |
452 |
|
461 | |||
453 | void tst_QChart::scrollRight_data() |
|
462 | void tst_QChart::scrollRight_data() | |
@@ -457,10 +466,11 void tst_QChart::scrollRight_data() | |||||
457 |
|
466 | |||
458 | void tst_QChart::scrollRight() |
|
467 | void tst_QChart::scrollRight() | |
459 | { |
|
468 | { | |
|
469 | qFatal("implement me"); | |||
460 | createTestData(); |
|
470 | createTestData(); | |
461 | qreal min = m_chart->axisX()->min(); |
|
471 | //TODO qreal min = m_chart->axisX()->min(); | |
462 | m_chart->scrollRight(); |
|
472 | m_chart->scrollRight(); | |
463 | QVERIFY(m_chart->axisX()->min()>min); |
|
473 | //TODO QVERIFY(m_chart->axisX()->min()>min); | |
464 | } |
|
474 | } | |
465 |
|
475 | |||
466 | void tst_QChart::scrollUp_data() |
|
476 | void tst_QChart::scrollUp_data() | |
@@ -470,10 +480,11 void tst_QChart::scrollUp_data() | |||||
470 |
|
480 | |||
471 | void tst_QChart::scrollUp() |
|
481 | void tst_QChart::scrollUp() | |
472 | { |
|
482 | { | |
|
483 | qFatal("implement me"); | |||
473 | createTestData(); |
|
484 | createTestData(); | |
474 | qreal min = m_chart->axisY()->min(); |
|
485 | //TODO qreal min = m_chart->axisY()->min(); | |
475 | m_chart->scrollUp(); |
|
486 | m_chart->scrollUp(); | |
476 | QVERIFY(m_chart->axisY()->min()>min); |
|
487 | //TODO QVERIFY(m_chart->axisY()->min()>min); | |
477 | } |
|
488 | } | |
478 |
|
489 | |||
479 | void tst_QChart::theme_data() |
|
490 | void tst_QChart::theme_data() | |
@@ -551,6 +562,8 void tst_QChart::zoomIn_data() | |||||
551 |
|
562 | |||
552 | void tst_QChart::zoomIn() |
|
563 | void tst_QChart::zoomIn() | |
553 | { |
|
564 | { | |
|
565 | qFatal("implement me"); | |||
|
566 | /* | |||
554 | QFETCH(QRectF, rect); |
|
567 | QFETCH(QRectF, rect); | |
555 | createTestData(); |
|
568 | createTestData(); | |
556 | QRectF marigns = m_chart->margins(); |
|
569 | QRectF marigns = m_chart->margins(); | |
@@ -566,6 +579,7 void tst_QChart::zoomIn() | |||||
566 | QVERIFY(minY<m_chart->axisY()->min()); |
|
579 | QVERIFY(minY<m_chart->axisY()->min()); | |
567 | QVERIFY(maxY>m_chart->axisY()->max()); |
|
580 | QVERIFY(maxY>m_chart->axisY()->max()); | |
568 | } |
|
581 | } | |
|
582 | */ | |||
569 | } |
|
583 | } | |
570 |
|
584 | |||
571 | void tst_QChart::zoomOut_data() |
|
585 | void tst_QChart::zoomOut_data() | |
@@ -575,7 +589,9 void tst_QChart::zoomOut_data() | |||||
575 |
|
589 | |||
576 | void tst_QChart::zoomOut() |
|
590 | void tst_QChart::zoomOut() | |
577 | { |
|
591 | { | |
|
592 | qFatal("implement me"); | |||
578 | createTestData(); |
|
593 | createTestData(); | |
|
594 | /* | |||
579 | qreal minX = m_chart->axisX()->min(); |
|
595 | qreal minX = m_chart->axisX()->min(); | |
580 | qreal minY = m_chart->axisY()->min(); |
|
596 | qreal minY = m_chart->axisY()->min(); | |
581 | qreal maxX = m_chart->axisX()->max(); |
|
597 | qreal maxX = m_chart->axisX()->max(); | |
@@ -604,6 +620,7 void tst_QChart::zoomOut() | |||||
604 |
|
|
620 | ||
605 | QVERIFY(maxX == m_chart->axisX()->max()); |
|
621 | QVERIFY(maxX == m_chart->axisX()->max()); | |
606 | QVERIFY(maxY == m_chart->axisY()->max()); |
|
622 | QVERIFY(maxY == m_chart->axisY()->max()); | |
|
623 | */ | |||
607 | } |
|
624 | } | |
608 |
|
625 | |||
609 | QTEST_MAIN(tst_QChart) |
|
626 | QTEST_MAIN(tst_QChart) |
@@ -149,9 +149,9 void tst_QChartView::rubberBand() | |||||
149 | //this is hack since view does not get events otherwise |
|
149 | //this is hack since view does not get events otherwise | |
150 | m_view->setMouseTracking(true); |
|
150 | m_view->setMouseTracking(true); | |
151 |
|
151 | |||
152 | QAxis* axisY = m_view->chart()->axisY(); |
|
152 | QAbstractAxis* axisY = m_view->chart()->axisY(); | |
153 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal))); |
|
153 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal))); | |
154 | QAxis* axisX = m_view->chart()->axisX(); |
|
154 | QAbstractAxis* axisX = m_view->chart()->axisX(); | |
155 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal))); |
|
155 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal))); | |
156 |
|
156 | |||
157 | QTest::qWaitForWindowShown(m_view); |
|
157 | QTest::qWaitForWindowShown(m_view); | |
@@ -166,10 +166,11 void tst_QChartView::rubberBand() | |||||
166 | //this is hack since view does not get events otherwise |
|
166 | //this is hack since view does not get events otherwise | |
167 | m_view->setMouseTracking(false); |
|
167 | m_view->setMouseTracking(false); | |
168 |
|
168 | |||
169 | QVERIFY(axisX->min() - minX < 1); |
|
169 | //TODO: QVERIFY(axisX->min() - minX < 1); | |
170 | QVERIFY(axisX->max() - maxX < 1); |
|
170 | //TODO: QVERIFY(axisX->max() - maxX < 1); | |
171 | QVERIFY(axisY->min() - minY < 1); |
|
171 | //TODO: QVERIFY(axisY->min() - minY < 1); | |
172 | QVERIFY(axisY->max() - maxY < 1); |
|
172 | //TODO: QVERIFY(axisY->max() - maxY < 1); | |
|
173 | qFatal("implement TODO"); | |||
173 | } |
|
174 | } | |
174 |
|
175 | |||
175 | QTEST_MAIN(tst_QChartView) |
|
176 | QTEST_MAIN(tst_QChartView) |
@@ -43,6 +43,7 | |||||
43 | #include <cmath> |
|
43 | #include <cmath> | |
44 | #include <QDebug> |
|
44 | #include <QDebug> | |
45 | #include <QStandardItemModel> |
|
45 | #include <QStandardItemModel> | |
|
46 | #include <QCategoriesAxis> | |||
46 |
|
47 | |||
47 |
|
48 | |||
48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
49 | QTCOMMERCIALCHART_USE_NAMESPACE | |
@@ -276,16 +277,24 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS | |||||
276 | QBarSeries* series = 0; |
|
277 | QBarSeries* series = 0; | |
277 | if (seriesName == "Bar") { |
|
278 | if (seriesName == "Bar") { | |
278 | series = new QBarSeries(this); |
|
279 | series = new QBarSeries(this); | |
279 | m_chart->axisX()->categories()->insert(category); |
|
280 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
281 | axis->append(category); | |||
|
282 | m_chart->setAxisX(series,axis); | |||
280 | } else if (seriesName == "Grouped bar") { |
|
283 | } else if (seriesName == "Grouped bar") { | |
281 | series = new QGroupedBarSeries(this); |
|
284 | series = new QGroupedBarSeries(this); | |
282 | m_chart->axisX()->categories()->insert(category); |
|
285 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
286 | axis->append(category); | |||
|
287 | m_chart->setAxisX(series,axis); | |||
283 | } else if (seriesName == "Stacked bar") { |
|
288 | } else if (seriesName == "Stacked bar") { | |
284 | series = new QStackedBarSeries(this); |
|
289 | series = new QStackedBarSeries(this); | |
285 | m_chart->axisX()->categories()->insert(category); |
|
290 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
291 | axis->append(category); | |||
|
292 | m_chart->setAxisX(series,axis); | |||
286 | } else { |
|
293 | } else { | |
287 | series = new QPercentBarSeries(this); |
|
294 | series = new QPercentBarSeries(this); | |
288 | m_chart->axisX()->categories()->insert(category); |
|
295 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
296 | axis->append(category); | |||
|
297 | m_chart->setAxisX(series,axis); | |||
289 | } |
|
298 | } | |
290 |
|
299 | |||
291 | for (int j(0); j < data.count(); j++) { |
|
300 | for (int j(0); j < data.count(); j++) { |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed | ||
This diff has been collapsed as it changes many lines, (680 lines changed) Show them Hide them |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now