##// END OF EJS Templates
Added few properties to QAbstractAxis. Some are still missing. Its needs to be decided how the Brush and Pen should be supported
Marek Rosa -
r2203:edb022f7374a
parent child
Show More
@@ -1,181 +1,183
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 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.1
22 import QtCommercial.Chart 1.1
23 import QmlCustomModel 1.0
23 import QmlCustomModel 1.0
24
24
25 Rectangle {
25 Rectangle {
26 anchors.fill: parent
26 anchors.fill: parent
27
27
28 //![1]
28 //![1]
29 ChartView {
29 ChartView {
30 id: chartView
30 id: chartView
31 title: "Top-5 car brand shares in Finland"
31 title: "Top-5 car brand shares in Finland"
32 anchors.fill: parent
32 anchors.fill: parent
33 animationOptions: ChartView.SeriesAnimations
33 animationOptions: ChartView.SeriesAnimations
34
34
35 BarCategoriesAxis {
35 BarCategoriesAxis {
36 id: categoriesAxis
36 id: categoriesAxis
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
37 categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ]
38 min: "2007"
38 min: "2007"
39 max: "2014"
39 max: "2014"
40 title: "Year"
40 }
41 }
41
42
42 ValueAxis {
43 ValueAxis {
43 id: valueAxis
44 id: valueAxis
44 min: 0
45 min: 0
45 max: 60
46 max: 60
47 title: "Sales count [ku]"
46 }
48 }
47 // ...
49 // ...
48 //![1]
50 //![1]
49
51
50 //![2]
52 //![2]
51 CustomModel {
53 CustomModel {
52 id: customModel
54 id: customModel
53 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
55 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
54 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
56 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
55 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
57 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
56 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
58 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
57 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
59 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
58 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
60 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
59 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
61 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
60 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
62 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
61 }
63 }
62 //![2]
64 //![2]
63
65
64 //![5]
66 //![5]
65 BarSeries {
67 BarSeries {
66 id: myBarSeries
68 id: myBarSeries
67 name: "Others"
69 name: "Others"
68 axisX: categoriesAxis
70 axisX: categoriesAxis
69 axisY: valueAxis
71 axisY: valueAxis
70 barWidth: 0.9
72 barWidth: 0.9
71 visible: false
73 visible: false
72 HBarModelMapper {
74 HBarModelMapper {
73 model: customModel
75 model: customModel
74 firstBarSetRow: 6
76 firstBarSetRow: 6
75 lastBarSetRow: 6
77 lastBarSetRow: 6
76 firstColumn: 2
78 firstColumn: 2
77 }
79 }
78 }
80 }
79 //![5]
81 //![5]
80
82
81 //![4]
83 //![4]
82 LineSeries {
84 LineSeries {
83 id: lineSeries1
85 id: lineSeries1
84 name: "Volkswagen"
86 name: "Volkswagen"
85 axisX: categoriesAxis
87 axisX: categoriesAxis
86 axisY: valueAxis
88 axisY: valueAxis
87 visible: false
89 visible: false
88 HXYModelMapper {
90 HXYModelMapper {
89 model: customModel
91 model: customModel
90 xRow: 0
92 xRow: 0
91 yRow: 1
93 yRow: 1
92 firstColumn: 2
94 firstColumn: 2
93 }
95 }
94 }
96 }
95 //![4]
97 //![4]
96
98
97 LineSeries {
99 LineSeries {
98 id: lineSeries2
100 id: lineSeries2
99 name: "Toyota"
101 name: "Toyota"
100 axisX: categoriesAxis
102 axisX: categoriesAxis
101 axisY: valueAxis
103 axisY: valueAxis
102 visible: false
104 visible: false
103 HXYModelMapper {
105 HXYModelMapper {
104 model: customModel
106 model: customModel
105 xRow: 0
107 xRow: 0
106 yRow: 2
108 yRow: 2
107 firstColumn: 2
109 firstColumn: 2
108 }
110 }
109 }
111 }
110
112
111 LineSeries {
113 LineSeries {
112 id: lineSeries3
114 id: lineSeries3
113 name: "Ford"
115 name: "Ford"
114 axisX: categoriesAxis
116 axisX: categoriesAxis
115 axisY: valueAxis
117 axisY: valueAxis
116 visible: false
118 visible: false
117 HXYModelMapper {
119 HXYModelMapper {
118 model: customModel
120 model: customModel
119 xRow: 0
121 xRow: 0
120 yRow: 3
122 yRow: 3
121 firstColumn: 2
123 firstColumn: 2
122 }
124 }
123 }
125 }
124
126
125 LineSeries {
127 LineSeries {
126 id: lineSeries4
128 id: lineSeries4
127 name: "Skoda"
129 name: "Skoda"
128 axisX: categoriesAxis
130 axisX: categoriesAxis
129 axisY: valueAxis
131 axisY: valueAxis
130 visible: false
132 visible: false
131 HXYModelMapper {
133 HXYModelMapper {
132 model: customModel
134 model: customModel
133 xRow: 0
135 xRow: 0
134 yRow: 4
136 yRow: 4
135 firstColumn: 2
137 firstColumn: 2
136 }
138 }
137 }
139 }
138
140
139 LineSeries {
141 LineSeries {
140 id: lineSeries5
142 id: lineSeries5
141 name: "Volvo"
143 name: "Volvo"
142 axisX: categoriesAxis
144 axisX: categoriesAxis
143 axisY: valueAxis
145 axisY: valueAxis
144 visible: false
146 visible: false
145 HXYModelMapper {
147 HXYModelMapper {
146 model: customModel
148 model: customModel
147 xRow: 0
149 xRow: 0
148 yRow: 5
150 yRow: 5
149 firstColumn: 2
151 firstColumn: 2
150 }
152 }
151 }
153 }
152
154
153 //![3]
155 //![3]
154 PieSeries {
156 PieSeries {
155 id: pieSeries
157 id: pieSeries
156 size: 0.4
158 size: 0.4
157 horizontalPosition: 0.85
159 horizontalPosition: 0.85
158 verticalPosition: 0.4
160 verticalPosition: 0.4
159 onClicked: {
161 onClicked: {
160 // Show the selection by exploding the slice
162 // Show the selection by exploding the slice
161 slice.exploded = !slice.exploded;
163 slice.exploded = !slice.exploded;
162
164
163 // Update the line series to show the yearly data for this slice
165 // Update the line series to show the yearly data for this slice
164 for (var i = 0; i < chartView.count; i++) {
166 for (var i = 0; i < chartView.count; i++) {
165 if (chartView.series(i).name == slice.label) {
167 if (chartView.series(i).name == slice.label) {
166 chartView.series(i).visible = slice.exploded;
168 chartView.series(i).visible = slice.exploded;
167 }
169 }
168 }
170 }
169 }
171 }
170
172
171 }
173 }
172 VPieModelMapper {
174 VPieModelMapper {
173 model: customModel
175 model: customModel
174 series: pieSeries
176 series: pieSeries
175 labelsColumn: 1
177 labelsColumn: 1
176 valuesColumn: 2
178 valuesColumn: 2
177 firstRow: 1
179 firstRow: 1
178 }
180 }
179 //![3]
181 //![3]
180 }
182 }
181 }
183 }
@@ -1,159 +1,162
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 QABSTRACTAXIS_H
21 #ifndef QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <QPen>
25 #include <QPen>
26 #include <QFont>
26 #include <QFont>
27 #include <QVariant>
27 #include <QVariant>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QAbstractAxisPrivate;
31 class QAbstractAxisPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
37 Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
37 Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
38 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
38 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
39 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
40 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
40 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
41 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
41 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
42 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
42 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
43 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
43 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
44 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
44 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
45 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
45 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
46 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
46 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
47 Q_PROPERTY(bool titleVisible READ titleVisible WRITE setTitleVisible)
48 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
49 Q_PROPERTY(QString title READ title WRITE setTitle)
47
50
48 public:
51 public:
49
52
50 enum AxisType {
53 enum AxisType {
51 AxisTypeNoAxis = 0x0,
54 AxisTypeNoAxis = 0x0,
52 AxisTypeValue = 0x1,
55 AxisTypeValue = 0x1,
53 AxisTypeBarCategory = 0x2,
56 AxisTypeBarCategory = 0x2,
54 AxisTypeCategory = 0x3,
57 AxisTypeCategory = 0x3,
55 AxisTypeDateTime = 0x4
58 AxisTypeDateTime = 0x4
56 };
59 };
57
60
58 Q_DECLARE_FLAGS(AxisTypes, AxisType)
61 Q_DECLARE_FLAGS(AxisTypes, AxisType)
59
62
60 protected:
63 protected:
61 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
64 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
62
65
63 public:
66 public:
64 ~QAbstractAxis();
67 ~QAbstractAxis();
65
68
66 virtual AxisType type() const = 0;
69 virtual AxisType type() const = 0;
67
70
68 //visibilty handling
71 //visibilty handling
69 bool isVisible() const;
72 bool isVisible() const;
70 void setVisible(bool visible = true);
73 void setVisible(bool visible = true);
71
74
72
75
73 //axis handling
76 //axis handling
74 bool isLineVisible() const;
77 bool isLineVisible() const;
75 void setLineVisible(bool visible = true);
78 void setLineVisible(bool visible = true);
76 void setLinePen(const QPen &pen);
79 void setLinePen(const QPen &pen);
77 QPen linePen() const;
80 QPen linePen() const;
78 void setLinePenColor(QColor color);
81 void setLinePenColor(QColor color);
79 QColor linePenColor() const;
82 QColor linePenColor() const;
80
83
81 //grid handling
84 //grid handling
82 bool isGridLineVisible() const;
85 bool isGridLineVisible() const;
83 void setGridLineVisible(bool visible = true);
86 void setGridLineVisible(bool visible = true);
84 void setGridLinePen(const QPen &pen);
87 void setGridLinePen(const QPen &pen);
85 QPen gridLinePen() const;
88 QPen gridLinePen() const;
86
89
87 //labels handling
90 //labels handling
88 bool labelsVisible() const;
91 bool labelsVisible() const;
89 void setLabelsVisible(bool visible = true);
92 void setLabelsVisible(bool visible = true);
90 void setLabelsPen(const QPen &pen);
93 void setLabelsPen(const QPen &pen);
91 QPen labelsPen() const;
94 QPen labelsPen() const;
92 void setLabelsBrush(const QBrush &brush);
95 void setLabelsBrush(const QBrush &brush);
93 QBrush labelsBrush() const;
96 QBrush labelsBrush() const;
94 void setLabelsFont(const QFont &font);
97 void setLabelsFont(const QFont &font);
95 QFont labelsFont() const;
98 QFont labelsFont() const;
96 void setLabelsAngle(int angle);
99 void setLabelsAngle(int angle);
97 int labelsAngle() const;
100 int labelsAngle() const;
98 void setLabelsColor(QColor color);
101 void setLabelsColor(QColor color);
99 QColor labelsColor() const;
102 QColor labelsColor() const;
100
103
101 //title handling
104 //title handling
102 bool titleVisible() const;
105 bool titleVisible() const;
103 void setTitleVisible(bool visible = true);
106 void setTitleVisible(bool visible = true);
104 void setTitlePen(const QPen &pen);
107 void setTitlePen(const QPen &pen);
105 QPen titlePen() const;
108 QPen titlePen() const;
106 void setTitleBrush(const QBrush &brush);
109 void setTitleBrush(const QBrush &brush);
107 QBrush titleBrush() const;
110 QBrush titleBrush() const;
108 void setTitleFont(const QFont &font);
111 void setTitleFont(const QFont &font);
109 QFont titleFont() const;
112 QFont titleFont() const;
110 void setTitle(const QString &title);
113 void setTitle(const QString &title);
111 QString title() const;
114 QString title() const;
112
115
113
116
114 //shades handling
117 //shades handling
115 bool shadesVisible() const;
118 bool shadesVisible() const;
116 void setShadesVisible(bool visible = true);
119 void setShadesVisible(bool visible = true);
117 void setShadesPen(const QPen &pen);
120 void setShadesPen(const QPen &pen);
118 QPen shadesPen() const;
121 QPen shadesPen() const;
119 void setShadesBrush(const QBrush &brush);
122 void setShadesBrush(const QBrush &brush);
120 QBrush shadesBrush() const;
123 QBrush shadesBrush() const;
121 void setShadesColor(QColor color);
124 void setShadesColor(QColor color);
122 QColor shadesColor() const;
125 QColor shadesColor() const;
123 void setShadesBorderColor(QColor color);
126 void setShadesBorderColor(QColor color);
124 QColor shadesBorderColor() const;
127 QColor shadesBorderColor() const;
125
128
126 Qt::Orientation orientation() const;
129 Qt::Orientation orientation() const;
127 Qt::Alignment alignment() const;
130 Qt::Alignment alignment() const;
128 void setAlignment(Qt::Alignment alignment);
131 void setAlignment(Qt::Alignment alignment);
129
132
130 //range handling
133 //range handling
131 void setMin(const QVariant &min);
134 void setMin(const QVariant &min);
132 void setMax(const QVariant &max);
135 void setMax(const QVariant &max);
133 void setRange(const QVariant &min, const QVariant &max);
136 void setRange(const QVariant &min, const QVariant &max);
134
137
135 void show();
138 void show();
136 void hide();
139 void hide();
137
140
138 Q_SIGNALS:
141 Q_SIGNALS:
139 void visibleChanged(bool visible);
142 void visibleChanged(bool visible);
140 void lineVisibleChanged(bool visible);
143 void lineVisibleChanged(bool visible);
141 void labelsVisibleChanged(bool visible);
144 void labelsVisibleChanged(bool visible);
142 void gridVisibleChanged(bool visible);
145 void gridVisibleChanged(bool visible);
143 void colorChanged(QColor color);
146 void colorChanged(QColor color);
144 void labelsColorChanged(QColor color);
147 void labelsColorChanged(QColor color);
145 void shadesVisibleChanged(bool visible);
148 void shadesVisibleChanged(bool visible);
146 void shadesColorChanged(QColor color);
149 void shadesColorChanged(QColor color);
147 void shadesBorderColorChanged(QColor color);
150 void shadesBorderColorChanged(QColor color);
148
151
149 protected:
152 protected:
150 QScopedPointer<QAbstractAxisPrivate> d_ptr;
153 QScopedPointer<QAbstractAxisPrivate> d_ptr;
151 Q_DISABLE_COPY(QAbstractAxis)
154 Q_DISABLE_COPY(QAbstractAxis)
152 friend class ChartDataSet;
155 friend class ChartDataSet;
153 friend class ChartAxis;
156 friend class ChartAxis;
154 friend class ChartPresenter;
157 friend class ChartPresenter;
155 };
158 };
156
159
157 QTCOMMERCIALCHART_END_NAMESPACE
160 QTCOMMERCIALCHART_END_NAMESPACE
158
161
159 #endif // QABSTRACTAXIS_H
162 #endif // QABSTRACTAXIS_H
General Comments 0
You need to be logged in to leave comments. Login now