@@ -1,59 +1,60 | |||||
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 <QBarCategoryAxis> |
|
22 | #include <QBarCategoryAxis> | |
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(DrilldownBarSeries *series) |
|
32 | void DrilldownChart::changeSeries(DrilldownBarSeries *series) | |
33 | { |
|
33 | { | |
34 | if (m_currentSeries) { |
|
34 | if (m_currentSeries) { | |
35 | removeSeries(m_currentSeries); |
|
35 | removeSeries(m_currentSeries); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | m_currentSeries = series; |
|
38 | m_currentSeries = series; | |
39 |
|
39 | |||
40 | // Reset axis |
|
40 | // Reset axis | |
41 | QBarCategoryAxis *axis = new QBarCategoryAxis(); |
|
41 | QBarCategoryAxis *axis = new QBarCategoryAxis(); | |
42 | axis->append(m_currentSeries->categories()); |
|
42 | axis->append(m_currentSeries->categories()); | |
43 |
|
43 | |||
44 | addSeries(series); |
|
44 | addSeries(series); | |
45 |
|
45 | |||
46 | createDefaultAxes(); |
|
46 | createDefaultAxes(); | |
47 | setAxisX(axis, series); |
|
47 | setAxisX(axis, series); | |
|
48 | axisY()->setTitle("Crops"); | |||
48 |
|
49 | |||
49 | setTitle(series->name()); |
|
50 | setTitle(series->name()); | |
50 | } |
|
51 | } | |
51 |
|
52 | |||
52 | void DrilldownChart::handleClicked(int index, QBarSet *barset) |
|
53 | void DrilldownChart::handleClicked(int index, QBarSet *barset) | |
53 | { |
|
54 | { | |
54 | Q_UNUSED(barset) |
|
55 | Q_UNUSED(barset) | |
55 | DrilldownBarSeries *series = static_cast<DrilldownBarSeries *>(sender()); |
|
56 | DrilldownBarSeries *series = static_cast<DrilldownBarSeries *>(sender()); | |
56 | changeSeries(series->drilldownSeries(index)); |
|
57 | changeSeries(series->drilldownSeries(index)); | |
57 | } |
|
58 | } | |
58 |
|
59 | |||
59 | #include "moc_drilldownchart.cpp" |
|
60 | #include "moc_drilldownchart.cpp" |
General Comments 0
You need to be logged in to leave comments.
Login now