@@ -29,7 +29,7 Rectangle { | |||||
29 | title: "Bar series" |
|
29 | title: "Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id:myAxis |
|
33 | id:myAxis | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
35 | } |
|
35 | } |
@@ -29,7 +29,7 Rectangle { | |||||
29 | title: "Stacked Bar series" |
|
29 | title: "Stacked Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id: myAxis; |
|
33 | id: myAxis; | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
35 | } |
|
35 | } |
@@ -29,7 +29,7 Rectangle { | |||||
29 | title: "Percent Bar series" |
|
29 | title: "Percent Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id: myAxis |
|
33 | id: myAxis | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
35 | } |
|
35 | } |
@@ -32,7 +32,7 Rectangle { | |||||
32 | anchors.fill: parent |
|
32 | anchors.fill: parent | |
33 | animationOptions: ChartView.SeriesAnimations |
|
33 | animationOptions: ChartView.SeriesAnimations | |
34 |
|
34 | |||
35 | CategoriesAxis { |
|
35 | BarCategoriesAxis { | |
36 | id: categoryAxis |
|
36 | id: categoryAxis | |
37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
38 | } |
|
38 | } |
@@ -66,7 +66,7 int main(int argc, char *argv[]) | |||||
66 | //![4] |
|
66 | //![4] | |
67 | QStringList categories; |
|
67 | QStringList categories; | |
68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
69 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
69 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
70 | axis->append(categories); |
|
70 | axis->append(categories); | |
71 | chart->setAxisX(axis,series); |
|
71 | chart->setAxisX(axis,series); | |
72 | //![4] |
|
72 | //![4] |
@@ -88,7 +88,7 TableWidget::TableWidget(QWidget *parent) | |||||
88 | //! [6] |
|
88 | //! [6] | |
89 | QStringList categories; |
|
89 | QStringList categories; | |
90 | categories << "April" << "May" << "June" << "July" << "August"; |
|
90 | categories << "April" << "May" << "June" << "July" << "August"; | |
91 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
91 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
92 | axis->append(categories); |
|
92 | axis->append(categories); | |
93 | chart->createDefaultAxes(); |
|
93 | chart->createDefaultAxes(); | |
94 | chart->setAxisX(axis, series); |
|
94 | chart->setAxisX(axis, series); |
@@ -64,7 +64,7 int main(int argc, char *argv[]) | |||||
64 | //![4] |
|
64 | //![4] | |
65 | QStringList categories; |
|
65 | QStringList categories; | |
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
67 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
67 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
68 | axis->append(categories); |
|
68 | axis->append(categories); | |
69 | chart->createDefaultAxes(); |
|
69 | chart->createDefaultAxes(); | |
70 | chart->setAxisX(axis,series); |
|
70 | chart->setAxisX(axis,series); |
@@ -65,7 +65,7 int main(int argc, char *argv[]) | |||||
65 | //![4] |
|
65 | //![4] | |
66 | QStringList categories; |
|
66 | QStringList categories; | |
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
68 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
68 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
69 | axis->append(categories); |
|
69 | axis->append(categories); | |
70 | chart->setAxisX(axis,series); |
|
70 | chart->setAxisX(axis,series); | |
71 | //![4] |
|
71 | //![4] |
@@ -38,7 +38,7 void DrilldownChart::changeSeries(DrilldownBarSeries *series) | |||||
38 | m_currentSeries = series; |
|
38 | m_currentSeries = series; | |
39 |
|
39 | |||
40 | // Reset axis |
|
40 | // Reset axis | |
41 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
41 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
42 | axis->append(m_currentSeries->categories()); |
|
42 | axis->append(m_currentSeries->categories()); | |
43 |
|
43 | |||
44 | addSeries(series); |
|
44 | addSeries(series); |
@@ -68,7 +68,7 public: | |||||
68 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
68 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
69 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
69 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
70 | qmlRegisterType<QValuesAxis>(uri, 1, 0, "ValuesAxis"); |
|
70 | qmlRegisterType<QValuesAxis>(uri, 1, 0, "ValuesAxis"); | |
71 | qmlRegisterType<QCategoriesAxis>(uri, 1, 0, "CategoriesAxis"); |
|
71 | qmlRegisterType<QBarCategoriesAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
72 |
|
72 | |||
73 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
73 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
74 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
74 | QLatin1String("Trying to create uncreatable: Legend.")); |
@@ -31,7 +31,7 static int label_padding = 5; | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | ChartCategoriesAxisX::ChartCategoriesAxisX(QCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), |
|
34 | ChartCategoriesAxisX::ChartCategoriesAxisX(QBarCategoriesAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter), | |
35 | m_categoriesAxis(axis) |
|
35 | m_categoriesAxis(axis) | |
36 | { |
|
36 | { | |
37 |
|
37 |
@@ -36,12 +36,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
36 |
|
36 | |||
37 | class QAbstractAxis; |
|
37 | class QAbstractAxis; | |
38 | class ChartPresenter; |
|
38 | class ChartPresenter; | |
39 | class QCategoriesAxis; |
|
39 | class QBarCategoriesAxis; | |
40 |
|
40 | |||
41 | class ChartCategoriesAxisX : public ChartAxis |
|
41 | class ChartCategoriesAxisX : public ChartAxis | |
42 | { |
|
42 | { | |
43 | public: |
|
43 | public: | |
44 | ChartCategoriesAxisX(QCategoriesAxis *axis, ChartPresenter *presenter); |
|
44 | ChartCategoriesAxisX(QBarCategoriesAxis *axis, ChartPresenter *presenter); | |
45 | ~ChartCategoriesAxisX(); |
|
45 | ~ChartCategoriesAxisX(); | |
46 |
|
46 | |||
47 | AxisType axisType() const { return X_AXIS;} |
|
47 | AxisType axisType() const { return X_AXIS;} | |
@@ -51,7 +51,7 protected: | |||||
51 | void updateGeometry(); |
|
51 | void updateGeometry(); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | QCategoriesAxis *m_categoriesAxis; |
|
54 | QBarCategoriesAxis *m_categoriesAxis; | |
55 | }; |
|
55 | }; | |
56 |
|
56 | |||
57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
57 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -35,7 +35,7 | |||||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAbstractAxis; |
|
37 | class QAbstractAxis; | |
38 | class QCategoriesAxis; |
|
38 | class QBarCategoriesAxis; | |
39 | class ChartPresenter; |
|
39 | class ChartPresenter; | |
40 |
|
40 | |||
41 | class ChartCategoriesAxisY : public ChartAxis |
|
41 | class ChartCategoriesAxisY : public ChartAxis | |
@@ -51,7 +51,7 protected: | |||||
51 | void updateGeometry(); |
|
51 | void updateGeometry(); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | QCategoriesAxis *m_categoriesAxis; |
|
54 | QBarCategoriesAxis *m_categoriesAxis; | |
55 | }; |
|
55 | }; | |
56 |
|
56 | |||
57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
57 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -27,16 +27,16 | |||||
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | QCategoriesAxis::QCategoriesAxis(QObject *parent): |
|
30 | QBarCategoriesAxis::QBarCategoriesAxis(QObject *parent): | |
31 | QAbstractAxis(*new QCategoriesAxisPrivate(this),parent) |
|
31 | QAbstractAxis(*new QBarCategoriesAxisPrivate(this),parent) | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | QCategoriesAxis::~QCategoriesAxis() |
|
35 | QBarCategoriesAxis::~QBarCategoriesAxis() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) |
|
39 | QBarCategoriesAxis::QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent) | |
40 | { |
|
40 | { | |
41 |
|
41 | |||
42 | } |
|
42 | } | |
@@ -44,9 +44,9 QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbs | |||||
44 | /*! |
|
44 | /*! | |
45 | Appends \a categories to axis |
|
45 | Appends \a categories to axis | |
46 | */ |
|
46 | */ | |
47 | void QCategoriesAxis::append(const QStringList &categories) |
|
47 | void QBarCategoriesAxis::append(const QStringList &categories) | |
48 | { |
|
48 | { | |
49 | Q_D(QCategoriesAxis); |
|
49 | Q_D(QBarCategoriesAxis); | |
50 | if (d->m_categories.isEmpty()) { |
|
50 | if (d->m_categories.isEmpty()) { | |
51 | d->m_categories.append(categories); |
|
51 | d->m_categories.append(categories); | |
52 | setRange(categories.first(),categories.last()); |
|
52 | setRange(categories.first(),categories.last()); | |
@@ -60,9 +60,9 void QCategoriesAxis::append(const QStringList &categories) | |||||
60 | /*! |
|
60 | /*! | |
61 | Appends \a category to axis |
|
61 | Appends \a category to axis | |
62 | */ |
|
62 | */ | |
63 | void QCategoriesAxis::append(const QString &category) |
|
63 | void QBarCategoriesAxis::append(const QString &category) | |
64 | { |
|
64 | { | |
65 | Q_D(QCategoriesAxis); |
|
65 | Q_D(QBarCategoriesAxis); | |
66 | if (d->m_categories.isEmpty()) { |
|
66 | if (d->m_categories.isEmpty()) { | |
67 | d->m_categories.append(category); |
|
67 | d->m_categories.append(category); | |
68 | setRange(category,category); |
|
68 | setRange(category,category); | |
@@ -75,9 +75,9 void QCategoriesAxis::append(const QString &category) | |||||
75 | /*! |
|
75 | /*! | |
76 | Removes \a category from axis |
|
76 | Removes \a category from axis | |
77 | */ |
|
77 | */ | |
78 | void QCategoriesAxis::remove(const QString &category) |
|
78 | void QBarCategoriesAxis::remove(const QString &category) | |
79 | { |
|
79 | { | |
80 | Q_D(QCategoriesAxis); |
|
80 | Q_D(QBarCategoriesAxis); | |
81 | if (d->m_categories.contains(category)) { |
|
81 | if (d->m_categories.contains(category)) { | |
82 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
82 | d->m_categories.removeAt(d->m_categories.indexOf(category)); | |
83 | setRange(d->m_categories.first(),d->m_categories.last()); |
|
83 | setRange(d->m_categories.first(),d->m_categories.last()); | |
@@ -88,9 +88,9 void QCategoriesAxis::remove(const QString &category) | |||||
88 | /*! |
|
88 | /*! | |
89 | Inserts \a category to axis at \a index |
|
89 | Inserts \a category to axis at \a index | |
90 | */ |
|
90 | */ | |
91 | void QCategoriesAxis::insert(int index, const QString &category) |
|
91 | void QBarCategoriesAxis::insert(int index, const QString &category) | |
92 | { |
|
92 | { | |
93 | Q_D(QCategoriesAxis); |
|
93 | Q_D(QBarCategoriesAxis); | |
94 | if (d->m_categories.isEmpty()) { |
|
94 | if (d->m_categories.isEmpty()) { | |
95 | d->m_categories.insert(index,category); |
|
95 | d->m_categories.insert(index,category); | |
96 | setRange(category,category); |
|
96 | setRange(category,category); | |
@@ -103,17 +103,17 void QCategoriesAxis::insert(int index, const QString &category) | |||||
103 | /*! |
|
103 | /*! | |
104 | Removes all categories. |
|
104 | Removes all categories. | |
105 | */ |
|
105 | */ | |
106 | void QCategoriesAxis::clear() |
|
106 | void QBarCategoriesAxis::clear() | |
107 | { |
|
107 | { | |
108 | Q_D(QCategoriesAxis); |
|
108 | Q_D(QBarCategoriesAxis); | |
109 | d->m_categories.clear(); |
|
109 | d->m_categories.clear(); | |
110 | setRange(QString::null,QString::null); |
|
110 | setRange(QString::null,QString::null); | |
111 | emit categoriesChanged(); |
|
111 | emit categoriesChanged(); | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | void QCategoriesAxis::setCategories(const QStringList &categories) |
|
114 | void QBarCategoriesAxis::setCategories(const QStringList &categories) | |
115 | { |
|
115 | { | |
116 | Q_D(QCategoriesAxis); |
|
116 | Q_D(QBarCategoriesAxis); | |
117 | if(d->m_categories!=categories){ |
|
117 | if(d->m_categories!=categories){ | |
118 | d->m_categories = categories; |
|
118 | d->m_categories = categories; | |
119 | setRange(categories.first(),categories.last()); |
|
119 | setRange(categories.first(),categories.last()); | |
@@ -121,72 +121,72 void QCategoriesAxis::setCategories(const QStringList &categories) | |||||
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | QStringList QCategoriesAxis::categories() |
|
124 | QStringList QBarCategoriesAxis::categories() | |
125 | { |
|
125 | { | |
126 | Q_D(QCategoriesAxis); |
|
126 | Q_D(QBarCategoriesAxis); | |
127 | return d->m_categories; |
|
127 | return d->m_categories; | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | Returns number of categories. |
|
131 | Returns number of categories. | |
132 | */ |
|
132 | */ | |
133 | int QCategoriesAxis::count() const |
|
133 | int QBarCategoriesAxis::count() const | |
134 | { |
|
134 | { | |
135 | Q_D(const QCategoriesAxis); |
|
135 | Q_D(const QBarCategoriesAxis); | |
136 | return d->m_categories.count(); |
|
136 | return d->m_categories.count(); | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | Returns category at \a index. Index must be valid. |
|
140 | Returns category at \a index. Index must be valid. | |
141 | */ |
|
141 | */ | |
142 | QString QCategoriesAxis::at(int index) const |
|
142 | QString QBarCategoriesAxis::at(int index) const | |
143 | { |
|
143 | { | |
144 | Q_D(const QCategoriesAxis); |
|
144 | Q_D(const QBarCategoriesAxis); | |
145 | return d->m_categories.at(index); |
|
145 | return d->m_categories.at(index); | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | Sets minimum category to \a min. |
|
149 | Sets minimum category to \a min. | |
150 | */ |
|
150 | */ | |
151 | void QCategoriesAxis::setMin(const QString& min) |
|
151 | void QBarCategoriesAxis::setMin(const QString& min) | |
152 | { |
|
152 | { | |
153 | Q_D(QCategoriesAxis); |
|
153 | Q_D(QBarCategoriesAxis); | |
154 | setRange(min,d->m_maxCategory); |
|
154 | setRange(min,d->m_maxCategory); | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | /*! |
|
157 | /*! | |
158 | Returns minimum category. |
|
158 | Returns minimum category. | |
159 | */ |
|
159 | */ | |
160 | QString QCategoriesAxis::min() const |
|
160 | QString QBarCategoriesAxis::min() const | |
161 | { |
|
161 | { | |
162 | Q_D(const QCategoriesAxis); |
|
162 | Q_D(const QBarCategoriesAxis); | |
163 | return d->m_minCategory; |
|
163 | return d->m_minCategory; | |
164 | } |
|
164 | } | |
165 |
|
165 | |||
166 | /*! |
|
166 | /*! | |
167 | Sets maximum category to \a max. |
|
167 | Sets maximum category to \a max. | |
168 | */ |
|
168 | */ | |
169 | void QCategoriesAxis::setMax(const QString& max) |
|
169 | void QBarCategoriesAxis::setMax(const QString& max) | |
170 | { |
|
170 | { | |
171 | Q_D(QCategoriesAxis); |
|
171 | Q_D(QBarCategoriesAxis); | |
172 | setRange(d->m_minCategory,max); |
|
172 | setRange(d->m_minCategory,max); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | /*! |
|
175 | /*! | |
176 | Returns maximum category |
|
176 | Returns maximum category | |
177 | */ |
|
177 | */ | |
178 | QString QCategoriesAxis::max() const |
|
178 | QString QBarCategoriesAxis::max() const | |
179 | { |
|
179 | { | |
180 | Q_D(const QCategoriesAxis); |
|
180 | Q_D(const QBarCategoriesAxis); | |
181 | return d->m_maxCategory; |
|
181 | return d->m_maxCategory; | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | Sets range from \a minCategory to \a maxCategory |
|
185 | Sets range from \a minCategory to \a maxCategory | |
186 | */ |
|
186 | */ | |
187 | void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) |
|
187 | void QBarCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |
188 | { |
|
188 | { | |
189 | Q_D(QCategoriesAxis); |
|
189 | Q_D(QBarCategoriesAxis); | |
190 |
|
190 | |||
191 | int minIndex = d->m_categories.indexOf(minCategory); |
|
191 | int minIndex = d->m_categories.indexOf(minCategory); | |
192 | if (minIndex == -1) { |
|
192 | if (minIndex == -1) { | |
@@ -224,57 +224,57 void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCat | |||||
224 | /*! |
|
224 | /*! | |
225 | Returns the type of axis. |
|
225 | Returns the type of axis. | |
226 | */ |
|
226 | */ | |
227 | QAbstractAxis::AxisType QCategoriesAxis::type() const |
|
227 | QAbstractAxis::AxisType QBarCategoriesAxis::type() const | |
228 | { |
|
228 | { | |
229 | return AxisTypeCategories; |
|
229 | return AxisTypeCategories; | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
232 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
233 |
|
233 | |||
234 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
|
234 | QBarCategoriesAxisPrivate::QBarCategoriesAxisPrivate(QBarCategoriesAxis* q): | |
235 | QAbstractAxisPrivate(q) |
|
235 | QAbstractAxisPrivate(q) | |
236 | { |
|
236 | { | |
237 |
|
237 | |||
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() |
|
240 | QBarCategoriesAxisPrivate::~QBarCategoriesAxisPrivate() | |
241 | { |
|
241 | { | |
242 |
|
242 | |||
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 | void QCategoriesAxisPrivate::setMin(const QVariant &min) |
|
245 | void QBarCategoriesAxisPrivate::setMin(const QVariant &min) | |
246 | { |
|
246 | { | |
247 | setRange(min,m_maxCategory); |
|
247 | setRange(min,m_maxCategory); | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | void QCategoriesAxisPrivate::setMax(const QVariant &max) |
|
250 | void QBarCategoriesAxisPrivate::setMax(const QVariant &max) | |
251 | { |
|
251 | { | |
252 | setRange(m_minCategory,max); |
|
252 | setRange(m_minCategory,max); | |
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | void QCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
255 | void QBarCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
256 | { |
|
256 | { | |
257 | Q_Q(QCategoriesAxis); |
|
257 | Q_Q(QBarCategoriesAxis); | |
258 | QString value1 = min.toString(); |
|
258 | QString value1 = min.toString(); | |
259 | QString value2 = max.toString(); |
|
259 | QString value2 = max.toString(); | |
260 | q->setRange(value1,value2); |
|
260 | q->setRange(value1,value2); | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | int QCategoriesAxisPrivate::ticksCount() const |
|
263 | int QBarCategoriesAxisPrivate::ticksCount() const | |
264 | { |
|
264 | { | |
265 | return m_categories.count()+1; |
|
265 | return m_categories.count()+1; | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | void QCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
268 | void QBarCategoriesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
269 | { |
|
269 | { | |
270 | m_min = min; |
|
270 | m_min = min; | |
271 | m_max = max; |
|
271 | m_max = max; | |
272 | m_ticksCount = count; |
|
272 | m_ticksCount = count; | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
275 | ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
276 | { |
|
276 | { | |
277 | Q_Q( QCategoriesAxis); |
|
277 | Q_Q( QBarCategoriesAxis); | |
278 | if(m_orientation == Qt::Vertical){ |
|
278 | if(m_orientation == Qt::Vertical){ | |
279 | return new ChartCategoriesAxisY(q,presenter); |
|
279 | return new ChartCategoriesAxisY(q,presenter); | |
280 | }else{ |
|
280 | }else{ | |
@@ -282,9 +282,9 ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||||
282 | } |
|
282 | } | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | void QCategoriesAxisPrivate::emitRange() |
|
285 | void QBarCategoriesAxisPrivate::emitRange() | |
286 | { |
|
286 | { | |
287 | Q_Q( QCategoriesAxis); |
|
287 | Q_Q( QBarCategoriesAxis); | |
288 | if(!q->signalsBlocked()) { |
|
288 | if(!q->signalsBlocked()) { | |
289 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); |
|
289 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); | |
290 | } |
|
290 | } |
@@ -25,9 +25,9 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QCategoriesAxisPrivate; |
|
28 | class QBarCategoriesAxisPrivate; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis |
|
30 | class QTCOMMERCIALCHART_EXPORT QBarCategoriesAxis : public QAbstractAxis | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |
@@ -35,11 +35,11 class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis | |||||
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) |
|
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) | |
36 |
|
36 | |||
37 | public: |
|
37 | public: | |
38 | explicit QCategoriesAxis(QObject *parent = 0); |
|
38 | explicit QBarCategoriesAxis(QObject *parent = 0); | |
39 | ~QCategoriesAxis(); |
|
39 | ~QBarCategoriesAxis(); | |
40 |
|
40 | |||
41 | protected: |
|
41 | protected: | |
42 | QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent = 0); |
|
42 | QBarCategoriesAxis(QBarCategoriesAxisPrivate &d,QObject *parent = 0); | |
43 |
|
43 | |||
44 | public: |
|
44 | public: | |
45 | AxisType type() const; |
|
45 | AxisType type() const; | |
@@ -67,8 +67,8 Q_SIGNALS: | |||||
67 | void rangeChanged(const QString &min, const QString &max); |
|
67 | void rangeChanged(const QString &min, const QString &max); | |
68 |
|
68 | |||
69 | private: |
|
69 | private: | |
70 | Q_DECLARE_PRIVATE(QCategoriesAxis) |
|
70 | Q_DECLARE_PRIVATE(QBarCategoriesAxis) | |
71 | Q_DISABLE_COPY(QCategoriesAxis) |
|
71 | Q_DISABLE_COPY(QBarCategoriesAxis) | |
72 | }; |
|
72 | }; | |
73 |
|
73 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
74 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -35,13 +35,13 | |||||
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 | class QCategoriesAxisPrivate : public QAbstractAxisPrivate |
|
38 | class QBarCategoriesAxisPrivate : public QAbstractAxisPrivate | |
39 | { |
|
39 | { | |
40 | Q_OBJECT |
|
40 | Q_OBJECT | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | QCategoriesAxisPrivate(QCategoriesAxis *q); |
|
43 | QBarCategoriesAxisPrivate(QBarCategoriesAxis *q); | |
44 | ~QCategoriesAxisPrivate(); |
|
44 | ~QBarCategoriesAxisPrivate(); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
@@ -66,7 +66,7 private: | |||||
66 | QString m_maxCategory; |
|
66 | QString m_maxCategory; | |
67 |
|
67 | |||
68 | private: |
|
68 | private: | |
69 | Q_DECLARE_PUBLIC(QCategoriesAxis) |
|
69 | Q_DECLARE_PUBLIC(QBarCategoriesAxis) | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | QTCOMMERCIALCHART_END_NAMESPACE |
|
72 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -712,7 +712,7 void QAbstractBarSeriesPrivate::initializeAxisX(QAbstractAxis* axis) | |||||
712 | { |
|
712 | { | |
713 | if(axis->type()==QAbstractAxis::AxisTypeCategories) |
|
713 | if(axis->type()==QAbstractAxis::AxisTypeCategories) | |
714 | { |
|
714 | { | |
715 | QCategoriesAxis* cataxis = qobject_cast<QCategoriesAxis*>(axis); |
|
715 | QBarCategoriesAxis* cataxis = qobject_cast<QBarCategoriesAxis*>(axis); | |
716 | Q_ASSERT(cataxis); |
|
716 | Q_ASSERT(cataxis); | |
717 | QStringList categories; |
|
717 | QStringList categories; | |
718 | for (int i(1); i < categoryCount()+1; i++) |
|
718 | for (int i(1); i < categoryCount()+1; i++) |
@@ -163,7 +163,7 QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type) | |||||
163 | axis = new QValuesAxis(this); |
|
163 | axis = new QValuesAxis(this); | |
164 | break; |
|
164 | break; | |
165 | case QAbstractAxis::AxisTypeCategories: |
|
165 | case QAbstractAxis::AxisTypeCategories: | |
166 | axis = new QCategoriesAxis(this); |
|
166 | axis = new QBarCategoriesAxis(this); | |
167 | break; |
|
167 | break; | |
168 | default: |
|
168 | default: | |
169 | axis = 0; |
|
169 | axis = 0; |
@@ -275,17 +275,17 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS | |||||
275 | QAbstractBarSeries* series = 0; |
|
275 | QAbstractBarSeries* series = 0; | |
276 | if (seriesName == "Bar") { |
|
276 | if (seriesName == "Bar") { | |
277 | series = new QBarSeries(this); |
|
277 | series = new QBarSeries(this); | |
278 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
278 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
279 | axis->append(category); |
|
279 | axis->append(category); | |
280 | m_chart->setAxisX(axis,series); |
|
280 | m_chart->setAxisX(axis,series); | |
281 | } else if (seriesName == "Stacked bar") { |
|
281 | } else if (seriesName == "Stacked bar") { | |
282 | series = new QStackedBarSeries(this); |
|
282 | series = new QStackedBarSeries(this); | |
283 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
283 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
284 | axis->append(category); |
|
284 | axis->append(category); | |
285 | m_chart->setAxisX(axis,series); |
|
285 | m_chart->setAxisX(axis,series); | |
286 | } else { |
|
286 | } else { | |
287 | series = new QPercentBarSeries(this); |
|
287 | series = new QPercentBarSeries(this); | |
288 | QCategoriesAxis* axis = new QCategoriesAxis(); |
|
288 | QBarCategoriesAxis* axis = new QBarCategoriesAxis(); | |
289 | axis->append(category); |
|
289 | axis->append(category); | |
290 | m_chart->setAxisX(axis,series); |
|
290 | m_chart->setAxisX(axis,series); | |
291 | } |
|
291 | } |
@@ -29,7 +29,7 ChartView { | |||||
29 |
|
29 | |||
30 | property variant series: mySeries |
|
30 | property variant series: mySeries | |
31 |
|
31 | |||
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id:myAxis; |
|
33 | id:myAxis; | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |
35 |
|
35 |
@@ -29,7 +29,7 ChartView { | |||||
29 |
|
29 | |||
30 | property variant series: mySeries |
|
30 | property variant series: mySeries | |
31 |
|
31 | |||
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id: myAxis |
|
33 | id: myAxis | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
35 | } |
|
35 | } |
@@ -29,7 +29,7 ChartView { | |||||
29 |
|
29 | |||
30 | property variant series: mySeries |
|
30 | property variant series: mySeries | |
31 |
|
31 | |||
32 | CategoriesAxis { |
|
32 | BarCategoriesAxis { | |
33 | id: myAxis |
|
33 | id: myAxis | |
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |
35 | } |
|
35 | } |
General Comments 0
You need to be logged in to leave comments.
Login now