|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,40 | |||
|
1 | /*! | |
|
2 | \example examples/groupedbarchart | |
|
3 | \title GroupedBarChart Example | |
|
4 | \subtitle | |
|
5 | ||
|
6 | The example shows how to create simple bar chart. GroupedBarChart shows the data in sets as separate bars, which are grouped in categories. | |
|
7 | ||
|
8 | \image examples_groupedbarchart.png | |
|
9 | ||
|
10 | First we define categories. | |
|
11 | ||
|
12 | \snippet ../examples/groupedbarchart/main.cpp 1 | |
|
13 | ||
|
14 | Data that groupedbarchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | |
|
15 | we want to visualize to them. | |
|
16 | ||
|
17 | \snippet ../examples/groupedbarchart/main.cpp 2 | |
|
18 | ||
|
19 | To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating | |
|
20 | the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets | |
|
21 | are added to series here. | |
|
22 | ||
|
23 | \snippet ../examples/groupedbarchart/main.cpp 3 | |
|
24 | ||
|
25 | Then we create a chart and add the series to it. | |
|
26 | ||
|
27 | \snippet ../examples/groupedbarchart/main.cpp 4 | |
|
28 | ||
|
29 | And we also want to show the legend, so that the data is easier to read. | |
|
30 | ||
|
31 | \snippet ../examples/groupedbarchart/main.cpp 5 | |
|
32 | ||
|
33 | Finally we add the chart onto a view. | |
|
34 | ||
|
35 | \snippet ../examples/groupedbarchart/main.cpp 6 | |
|
36 | ||
|
37 | And it is ready to be shown in a window. | |
|
38 | ||
|
39 | \snippet ../examples/groupedbarchart/main.cpp 7 | |
|
40 | */ |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -3,38 +3,32 | |||
|
3 | 3 | \title BarChart Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
|
6 |
The example shows how to create simple bar chart. Barchart shows the data in sets as separate bars, which are |
|
|
6 | The example shows how to create simple bar chart. Barchart shows the data in sets as separate bars, which are drawn at the x-axis to the position defined by data. | |
|
7 | 7 | |
|
8 | 8 | \image examples_barchart.png |
|
9 | 9 | |
|
10 | First we define categories. | |
|
10 | Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | |
|
11 | we want to visualize to them. Note that first and third QPointF in each set have smaller intervals at their x coordinates. This will be reflected in the chart. | |
|
11 | 12 | |
|
12 | 13 | \snippet ../examples/barchart/main.cpp 1 |
|
13 | 14 | |
|
14 | Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | |
|
15 | we want to visualize to them. | |
|
15 | To combine the sets to a chart, we need to create QBarSeries instance. Then we append our barsets to the series. | |
|
16 | 16 | |
|
17 | 17 | \snippet ../examples/barchart/main.cpp 2 |
|
18 | ||
|
19 | To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating | |
|
20 | the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets | |
|
21 | are added to series here. | |
|
22 | ||
|
23 | \snippet ../examples/barchart/main.cpp 3 | |
|
24 | 18 | |
|
25 |
|
|
|
19 | Next we create a chart and add the series to it. | |
|
26 | 20 | |
|
27 |
\snippet ../examples/barchart/main.cpp |
|
|
21 | \snippet ../examples/barchart/main.cpp 3 | |
|
28 | 22 | |
|
29 | And we also want to show the legend, so that the data is easier to read. | |
|
23 | We want to have the legend displayed at the bottom of the chart. Also we turn on the nice numbers algorithm on for y-axis. | |
|
30 | 24 | |
|
31 |
\snippet ../examples/barchart/main.cpp |
|
|
25 | \snippet ../examples/barchart/main.cpp 4 | |
|
32 | 26 | |
|
33 | 27 | Finally we add the chart onto a view. |
|
34 | 28 | |
|
35 |
\snippet ../examples/barchart/main.cpp |
|
|
29 | \snippet ../examples/barchart/main.cpp 5 | |
|
36 | 30 | |
|
37 | 31 | And it is ready to be shown in a window. |
|
38 | 32 | |
|
39 |
\snippet ../examples/percentbarchart/main.cpp |
|
|
33 | \snippet ../examples/percentbarchart/main.cpp 6 | |
|
40 | 34 | */ |
@@ -16,6 +16,7 | |||
|
16 | 16 | <li><a href="examples-areachart.html">Area chart</a></li> |
|
17 | 17 | <li><a href="examples-barchart.html">Bar chart</a></li> |
|
18 | 18 | <li><a href="examples-customchart.html">Custom chart</a></li> |
|
19 | <li><a href="examples-groupedbarchart.html">Grouped bar chart</a></li> | |
|
19 | 20 | <li><a href="examples-linechart.html">Line chart</a></li> |
|
20 | 21 | <li><a href="examples-modeldata.html">Model data</a></li> |
|
21 | 22 | <li><a href="examples-percentbarchart.html">Percent bar chart</a></li> |
@@ -24,19 +24,20 | |||
|
24 | 24 | <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="440" alt="barchart" /></a></td> |
|
25 | 25 | </tr> |
|
26 | 26 | <tr> |
|
27 | <td><a href="examples-groupedbarchart.html"><img src="images/examples_groupedbarchart.png" width="440" alt="groupedbarcchart" /></a></td> | |
|
27 | 28 | <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="440" alt="stackedbarchart" /></a></td> |
|
28 | <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="440" alt="percentbarcchart" /></a></td> | |
|
29 | 29 | </tr> |
|
30 | 30 | <tr> |
|
31 | <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="440" alt="percentbarcchart" /></a></td> | |
|
31 | 32 | <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="440" alt="linechart" /></a></td> |
|
32 | <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="440" alt="piechart" /></a></td> | |
|
33 | 33 | </tr> |
|
34 | 34 | <tr> |
|
35 | 35 | <td><a href="examples-customchart.html"><img src="images/examples_customchart.png" width="440" alt="customerchart" /></a></td> |
|
36 |
<td><a href="examples- |
|
|
36 | <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="440" alt="piechart" /></a></td> | |
|
37 | 37 | </tr> |
|
38 | 38 | <tr> |
|
39 | 39 | <td><a href="demos-chartthemes.html"><img src="images/demo_chartthemes_blue_cerulean.png" width=440 alt="charttheme" /></a></td> |
|
40 | <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart2.png" width="440" alt="zoomlinechart" /></a></td> | |
|
40 | 41 | </tr> |
|
41 | 42 | </table> |
|
42 | 43 | </div> |
@@ -32,11 +32,6 int main(int argc, char *argv[]) | |||
|
32 | 32 | QApplication a(argc, argv); |
|
33 | 33 | |
|
34 | 34 | //![1] |
|
35 | QBarCategories categories; | |
|
36 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
|
37 | //![1] | |
|
38 | ||
|
39 | //![2] | |
|
40 | 35 | QBarSet *set0 = new QBarSet("Jane"); |
|
41 | 36 | QBarSet *set1 = new QBarSet("John"); |
|
42 | 37 | QBarSet *set2 = new QBarSet("Axel"); |
@@ -48,42 +43,40 int main(int argc, char *argv[]) | |||
|
48 | 43 | *set2 << QPointF(0.2, 3) << QPointF(1.4, 4) << QPointF(2.50, 5) << QPointF(3.4, 6) << QPointF(4.4, 7) << QPointF(5.4, 8); |
|
49 | 44 | *set3 << QPointF(0.3, 4) << QPointF(1.6, 5) << QPointF(2.55, 6) << QPointF(3.6, 7) << QPointF(4.6, 8) << QPointF(5.6, 9); |
|
50 | 45 | *set4 << QPointF(0.4, 5) << QPointF(1.8, 6) << QPointF(2.6, 7) << QPointF(3.8, 8) << QPointF(4.8, 9) << QPointF(5.8, 10); |
|
51 |
//![ |
|
|
46 | //![1] | |
|
52 | 47 | |
|
53 |
//![ |
|
|
48 | //![2] | |
|
54 | 49 | QBarSeries* series = new QBarSeries(); |
|
55 | series->setCategories(categories); | |
|
56 | 50 | series->append(set0); |
|
57 | 51 | series->append(set1); |
|
58 | 52 | series->append(set2); |
|
59 | 53 | series->append(set3); |
|
60 | 54 | series->append(set4); |
|
55 | //![2] | |
|
61 | 56 | |
|
62 | 57 | //![3] |
|
63 | ||
|
64 | //![4] | |
|
65 | 58 | QChart* chart = new QChart(); |
|
66 | 59 | chart->addSeries(series); |
|
67 | 60 | chart->setTitle("Simple barchart example"); |
|
68 |
//![ |
|
|
61 | //![3] | |
|
69 | 62 | |
|
70 |
//![ |
|
|
63 | //![4] | |
|
71 | 64 | chart->legend()->setVisible(true); |
|
72 | 65 | chart->legend()->setAlignment(QLegend::AlignmentBottom); |
|
73 | 66 | chart->axisY()->setNiceNumbersEnabled(true); |
|
74 |
//![ |
|
|
67 | //![4] | |
|
75 | 68 | |
|
76 |
//![ |
|
|
69 | //![5] | |
|
77 | 70 | QChartView* chartView = new QChartView(chart); |
|
78 | 71 | chartView->setRenderHint(QPainter::Antialiasing); |
|
79 |
//![ |
|
|
72 | //![5] | |
|
80 | 73 | |
|
81 |
//![ |
|
|
74 | //![6] | |
|
82 | 75 | QMainWindow window; |
|
83 | 76 | window.setCentralWidget(chartView); |
|
84 | 77 | window.resize(400, 300); |
|
85 | 78 | window.show(); |
|
86 |
//![ |
|
|
79 | //![6] | |
|
87 | 80 | |
|
88 | 81 | return a.exec(); |
|
89 | 82 | } |
@@ -39,9 +39,10 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
39 | 39 | \brief part of QtCommercial chart API. |
|
40 | 40 | \mainclass |
|
41 | 41 | |
|
42 |
QBarSeries represents a series of data shown as bars. |
|
|
43 | QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined | |
|
44 | by QStringList. | |
|
42 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to | |
|
43 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar | |
|
44 | and y-value is the height of the bar. The category names are ignored with this series and x-axis | |
|
45 | shows the x-values. | |
|
45 | 46 | |
|
46 | 47 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
47 | 48 | \image examples_barchart.png |
@@ -65,11 +66,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
65 | 66 | */ |
|
66 | 67 | |
|
67 | 68 | /*! |
|
68 | Constructs empty QBarSeries. Parameter \a categories defines the categories for chart. | |
|
69 | Constructs empty QBarSeries. | |
|
69 | 70 | QBarSeries is QObject which is a child of a \a parent. |
|
70 | 71 | */ |
|
71 |
QBarSeries::QBarSeries( |
|
|
72 |
QAbstractSeries(*new QBarSeriesPrivate( |
|
|
72 | QBarSeries::QBarSeries(QObject *parent) : | |
|
73 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) | |
|
73 | 74 | { |
|
74 | 75 | } |
|
75 | 76 | |
@@ -97,6 +98,9 QAbstractSeries::SeriesType QBarSeries::type() const | |||
|
97 | 98 | return QAbstractSeries::SeriesTypeBar; |
|
98 | 99 | } |
|
99 | 100 | |
|
101 | /*! | |
|
102 | Sets the \a categories, which are used to to group the data. | |
|
103 | */ | |
|
100 | 104 | void QBarSeries::setCategories(QBarCategories categories) |
|
101 | 105 | { |
|
102 | 106 | Q_D(QBarSeries); |
@@ -105,7 +109,9 void QBarSeries::setCategories(QBarCategories categories) | |||
|
105 | 109 | } |
|
106 | 110 | |
|
107 | 111 | /*! |
|
108 | Adds a set of bars to series. Takes ownership of \a set. | |
|
112 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
|
113 | Returns true, if appending succeeded. | |
|
114 | ||
|
109 | 115 | */ |
|
110 | 116 | bool QBarSeries::append(QBarSet *set) |
|
111 | 117 | { |
@@ -122,6 +128,7 bool QBarSeries::append(QBarSet *set) | |||
|
122 | 128 | |
|
123 | 129 | /*! |
|
124 | 130 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
131 | Returns true, if set was removed. | |
|
125 | 132 | */ |
|
126 | 133 | bool QBarSeries::remove(QBarSet *set) |
|
127 | 134 | { |
@@ -138,6 +145,9 bool QBarSeries::remove(QBarSet *set) | |||
|
138 | 145 | |
|
139 | 146 | /*! |
|
140 | 147 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
148 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, | |
|
149 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended | |
|
150 | and function returns false. | |
|
141 | 151 | */ |
|
142 | 152 | bool QBarSeries::append(QList<QBarSet* > sets) |
|
143 | 153 | { |
@@ -198,7 +208,7 int QBarSeries::barsetCount() const | |||
|
198 | 208 | int QBarSeries::categoryCount() const |
|
199 | 209 | { |
|
200 | 210 | Q_D(const QBarSeries); |
|
201 |
return d-> |
|
|
211 | return d->categoryCount(); | |
|
202 | 212 | } |
|
203 | 213 | |
|
204 | 214 | /*! |
@@ -276,7 +286,7 QBarModelMapper* QBarSeries::modelMapper() const | |||
|
276 | 286 | QBarCategories QBarSeries::categories() const |
|
277 | 287 | { |
|
278 | 288 | Q_D(const QBarSeries); |
|
279 |
return d-> |
|
|
289 | return d->categories(); | |
|
280 | 290 | } |
|
281 | 291 | |
|
282 | 292 | /*! |
@@ -295,7 +305,6 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : | |||
|
295 | 305 | QAbstractSeriesPrivate(q), |
|
296 | 306 | m_barMargin(0.05), // Default value is 5% of category width |
|
297 | 307 | m_mapper(0) |
|
298 | // m_categories(categories), | |
|
299 | 308 | { |
|
300 | 309 | } |
|
301 | 310 | |
@@ -304,6 +313,51 void QBarSeriesPrivate::setCategories(QBarCategories categories) | |||
|
304 | 313 | m_categories = categories; |
|
305 | 314 | } |
|
306 | 315 | |
|
316 | void QBarSeriesPrivate::insertCategory(int index, const QString category) | |
|
317 | { | |
|
318 | m_categories.insert(index, category); | |
|
319 | emit categoriesUpdated(); | |
|
320 | } | |
|
321 | ||
|
322 | void QBarSeriesPrivate::removeCategory(int index) | |
|
323 | { | |
|
324 | m_categories.removeAt(index); | |
|
325 | emit categoriesUpdated(); | |
|
326 | } | |
|
327 | ||
|
328 | int QBarSeriesPrivate::categoryCount() const | |
|
329 | { | |
|
330 | if (m_categories.count() > 0) { | |
|
331 | return m_categories.count(); | |
|
332 | } | |
|
333 | ||
|
334 | // No categories defined. return count of longest set. | |
|
335 | int count = 0; | |
|
336 | for (int i=0; i<m_barSets.count(); i++) { | |
|
337 | if (m_barSets.at(i)->count() > count) { | |
|
338 | count = m_barSets.at(i)->count(); | |
|
339 | } | |
|
340 | } | |
|
341 | ||
|
342 | return count; | |
|
343 | } | |
|
344 | ||
|
345 | QBarCategories QBarSeriesPrivate::categories() const | |
|
346 | { | |
|
347 | if (m_categories.count() > 0) { | |
|
348 | return m_categories; | |
|
349 | } | |
|
350 | ||
|
351 | // No categories defined. retun list of indices. | |
|
352 | QBarCategories categories; | |
|
353 | ||
|
354 | int count = categoryCount(); | |
|
355 | for (int i = 0; i < count; i++) { | |
|
356 | categories.append(QString::number(i)); | |
|
357 | } | |
|
358 | return categories; | |
|
359 | } | |
|
360 | ||
|
307 | 361 | void QBarSeriesPrivate::setBarMargin(qreal margin) |
|
308 | 362 | { |
|
309 | 363 | if (margin > 1.0) { |
@@ -328,7 +382,11 QBarSet* QBarSeriesPrivate::barsetAt(int index) | |||
|
328 | 382 | |
|
329 | 383 | QString QBarSeriesPrivate::categoryName(int category) |
|
330 | 384 | { |
|
331 | return m_categories.at(category); | |
|
385 | if ((category > 0) && (category < m_categories.count())) { | |
|
386 | return m_categories.at(category); | |
|
387 | } | |
|
388 | ||
|
389 | return QString::number(category); | |
|
332 | 390 | } |
|
333 | 391 | |
|
334 | 392 | qreal QBarSeriesPrivate::min() |
@@ -425,7 +483,7 qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |||
|
425 | 483 | qreal QBarSeriesPrivate::maxCategorySum() |
|
426 | 484 | { |
|
427 | 485 | qreal max = INT_MIN; |
|
428 |
int count = |
|
|
486 | int count = categoryCount(); | |
|
429 | 487 | for (int i = 0; i < count; i++) { |
|
430 | 488 | qreal sum = categorySum(i); |
|
431 | 489 | if (sum > max) |
@@ -540,18 +598,6 void QBarSeriesPrivate::initializeDataFromModel() | |||
|
540 | 598 | // emit updatedBars(); |
|
541 | 599 | } |
|
542 | 600 | |
|
543 | void QBarSeriesPrivate::insertCategory(int index, const QString category) | |
|
544 | { | |
|
545 | m_categories.insert(index, category); | |
|
546 | emit categoriesUpdated(); | |
|
547 | } | |
|
548 | ||
|
549 | void QBarSeriesPrivate::removeCategory(int index) | |
|
550 | { | |
|
551 | m_categories.removeAt(index); | |
|
552 | emit categoriesUpdated(); | |
|
553 | } | |
|
554 | ||
|
555 | 601 | void QBarSeriesPrivate::barsetChanged() |
|
556 | 602 | { |
|
557 | 603 | emit updatedBars(); |
@@ -566,7 +612,7 void QBarSeriesPrivate::scaleDomain(Domain& domain) | |||
|
566 | 612 | int tickXCount(domain.tickXCount()); |
|
567 | 613 | int tickYCount(domain.tickYCount()); |
|
568 | 614 | |
|
569 |
qreal x = |
|
|
615 | qreal x = categoryCount(); | |
|
570 | 616 | qreal y = max(); |
|
571 | 617 | minX = qMin(minX, x); |
|
572 | 618 | minY = qMin(minY, y); |
@@ -46,8 +46,8 public: | |||
|
46 | 46 | QAbstractSeries::SeriesType type() const; |
|
47 | 47 | void setCategories(QBarCategories categories); |
|
48 | 48 | |
|
49 |
bool append(QBarSet *set); |
|
|
50 | bool remove(QBarSet *set); // Releases ownership, doesn't delete set | |
|
49 | bool append(QBarSet *set); | |
|
50 | bool remove(QBarSet *set); | |
|
51 | 51 | bool append(QList<QBarSet* > sets); |
|
52 | 52 | bool remove(QList<QBarSet* > sets); |
|
53 | 53 | int barsetCount() const; |
@@ -19,6 +19,11 class QBarSeriesPrivate : public QAbstractSeriesPrivate | |||
|
19 | 19 | public: |
|
20 | 20 | QBarSeriesPrivate(QBarSeries *parent); |
|
21 | 21 | void setCategories(QBarCategories categories); |
|
22 | void insertCategory(int index, const QString category); | |
|
23 | void removeCategory(int index); | |
|
24 | int categoryCount() const; | |
|
25 | QBarCategories categories() const; | |
|
26 | ||
|
22 | 27 | void setBarMargin(qreal margin); |
|
23 | 28 | qreal barMargin(); |
|
24 | 29 | |
@@ -26,9 +31,6 public: | |||
|
26 | 31 | Chart* createGraphics(ChartPresenter* presenter); |
|
27 | 32 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
28 | 33 | |
|
29 | void insertCategory(int index, const QString category); | |
|
30 | void removeCategory(int index); | |
|
31 | ||
|
32 | 34 | QBarSet* barsetAt(int index); |
|
33 | 35 | QString categoryName(int category); |
|
34 | 36 | qreal min(); |
@@ -34,7 +34,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
34 | 34 | |
|
35 | 35 | \mainclass |
|
36 | 36 | |
|
37 | \sa QBarSeries, QStackedBarSeries, QPercentBarSeries | |
|
37 | \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries | |
|
38 | 38 | */ |
|
39 | 39 | |
|
40 | 40 | /*! |
@@ -84,13 +84,22 QString QBarSet::name() const | |||
|
84 | 84 | return d_ptr->m_name; |
|
85 | 85 | } |
|
86 | 86 | |
|
87 | /*! | |
|
88 | Appends a point to set. Parameter \a value x coordinate defines the | |
|
89 | position in x-axis and y coordinate defines the height of bar. | |
|
90 | Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries) | |
|
91 | the x values are used or ignored. | |
|
92 | */ | |
|
87 | 93 | void QBarSet::append(const QPointF value) |
|
88 | 94 | { |
|
89 | 95 | d_ptr->m_values.append(value); |
|
90 | 96 | emit d_ptr->restructuredBars(); |
|
91 | 97 | } |
|
92 | 98 | |
|
93 | ||
|
99 | /*! | |
|
100 | Appends a list of \a points to set. Works like append with single point. | |
|
101 | \sa append() | |
|
102 | */ | |
|
94 | 103 | void QBarSet::append(const QList<QPointF> values) |
|
95 | 104 | { |
|
96 | 105 | for (int i=0; i<values.count(); i++) { |
@@ -100,15 +109,19 void QBarSet::append(const QList<QPointF> values) | |||
|
100 | 109 | } |
|
101 | 110 | |
|
102 | 111 | /*! |
|
103 | Appends new value \a value to the end of set. | |
|
112 | Appends new value \a value to the end of set. Internally the value is converted to QPointF, | |
|
113 | with x coordinate being the index of appended value and y coordinate is the value. | |
|
104 | 114 | */ |
|
105 | 115 | void QBarSet::append(const qreal value) |
|
106 | 116 | { |
|
107 | 117 | append(QPointF(d_ptr->m_values.count(), value)); |
|
108 | // d_ptr->m_values.append(value); | |
|
109 | 118 | } |
|
110 | 119 | |
|
111 | ||
|
120 | /*! | |
|
121 | Appends a list of reals to set. Works like append with single real value. The values in list | |
|
122 | are converted to QPointF, where x coordinate is the index of point and y coordinate is the value. | |
|
123 | \sa append() | |
|
124 | */ | |
|
112 | 125 | void QBarSet::append(const QList<qreal> values) |
|
113 | 126 | { |
|
114 | 127 | int index = d_ptr->m_values.count(); |
@@ -120,7 +133,8 void QBarSet::append(const QList<qreal> values) | |||
|
120 | 133 | } |
|
121 | 134 | |
|
122 | 135 | /*! |
|
123 | Appends new value \a value to the end of set. | |
|
136 | Convinience operator. Same as append, with real \a value. | |
|
137 | \sa append() | |
|
124 | 138 | */ |
|
125 | 139 | QBarSet& QBarSet::operator << (const qreal &value) |
|
126 | 140 | { |
@@ -128,6 +142,10 QBarSet& QBarSet::operator << (const qreal &value) | |||
|
128 | 142 | return *this; |
|
129 | 143 | } |
|
130 | 144 | |
|
145 | /*! | |
|
146 | Convinience operator. Same as append, with QPointF \a value. | |
|
147 | \sa append() | |
|
148 | */ | |
|
131 | 149 | QBarSet& QBarSet::operator << (const QPointF &value) |
|
132 | 150 | { |
|
133 | 151 | append(value); |
@@ -165,7 +183,10 void QBarSet::replace(const int index, const qreal value) | |||
|
165 | 183 | } |
|
166 | 184 | |
|
167 | 185 | /*! |
|
168 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF | |
|
186 | Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF. | |
|
187 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
|
188 | of the QPointF (if appended with QPointF append). | |
|
189 | If the index is out of bounds QPointF(0, 0.0) is returned. | |
|
169 | 190 | */ |
|
170 | 191 | QPointF QBarSet::at(const int index) const |
|
171 | 192 | { |
@@ -177,7 +198,9 QPointF QBarSet::at(const int index) const | |||
|
177 | 198 | } |
|
178 | 199 | |
|
179 | 200 | /*! |
|
180 | Returns value of set indexed by \a index | |
|
201 | Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF. | |
|
202 | The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value | |
|
203 | of the QPointF (if appended with QPointF append). | |
|
181 | 204 | */ |
|
182 | 205 | QPointF QBarSet::operator [](const int index) const |
|
183 | 206 | { |
@@ -193,7 +216,7 int QBarSet::count() const | |||
|
193 | 216 | } |
|
194 | 217 | |
|
195 | 218 | /*! |
|
196 | Returns sum of all values in barset. | |
|
219 | Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation. | |
|
197 | 220 | */ |
|
198 | 221 | qreal QBarSet::sum() const |
|
199 | 222 | { |
@@ -32,9 +32,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
32 | 32 | \brief part of QtCommercial chart API. |
|
33 | 33 | \mainclass |
|
34 | 34 | |
|
35 |
QGroupedBarSeries represents a series of data shown as bars. |
|
|
36 | grouped next to each other. One QGroupedBarSeries can contain multiple QBarSet data sets. | |
|
37 |
|
|
|
35 | QGroupedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars | |
|
36 | as groups, where bars in same category are grouped next to each other. QGroupedBarSeries groups the data | |
|
37 | from sets to categories, which are defined by a QStringList. | |
|
38 | 38 | |
|
39 | 39 | See the \l {GroupedbarChart Example} {grouped bar chart example} to learn how to create a grouped bar chart. |
|
40 | 40 | \image examples_groupedbarchart.png |
@@ -45,11 +45,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
45 | 45 | /*! |
|
46 | 46 | \fn virtual QSeriesType QGroupedBarSeries::type() const |
|
47 | 47 | \brief Returns type of series. |
|
48 | \sa QSeriesType | |
|
48 | \sa QAbstractSeries, QSeriesType | |
|
49 | 49 | */ |
|
50 | 50 | |
|
51 | 51 | /*! |
|
52 | Constructs empty QGroupedBarSeries. Parameter \a categories defines the categories for chart. | |
|
52 | Constructs empty QGroupedBarSeries. | |
|
53 | 53 | QGroupedBarSeries is QObject which is a child of a \a parent. |
|
54 | 54 | */ |
|
55 | 55 | QGroupedBarSeries::QGroupedBarSeries(QObject *parent) |
@@ -25,7 +25,6 | |||
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | |
|
28 | ||
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
|
31 | 30 | /*! |
@@ -33,9 +32,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
33 | 32 | \brief part of QtCommercial chart API. |
|
34 | 33 | \mainclass |
|
35 | 34 | |
|
36 |
QPercentBarSeries represents a series of data shown as bars. |
|
|
37 | of all bars in category. One QPercentBarSeries can contain multiple QBarSet data sets. | |
|
38 | QBarSeries groups the data from sets to categories, which are defined by QStringList. | |
|
35 | QPercentBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars | |
|
36 | as stacks, where each bar is shown as percentage of all bars in that category. | |
|
37 | QPercentBarSeries groups the data from sets to categories, which are defined by a QStringList. | |
|
39 | 38 | |
|
40 | 39 | See the \l {PercentbarChart Example} {percent bar chart example} to learn how to create a percent bar chart. |
|
41 | 40 | \image examples_percentbarchart.png |
@@ -50,11 +49,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
50 | 49 | */ |
|
51 | 50 | |
|
52 | 51 | /*! |
|
53 | Constructs empty QPercentBarSeries. Parameter \a categories defines the categories for chart. | |
|
52 | Constructs empty QPercentBarSeries. | |
|
54 | 53 | QPercentBarSeries is QObject which is a child of a \a parent. |
|
55 | 54 | */ |
|
56 |
QPercentBarSeries::QPercentBarSeries( |
|
|
57 |
: QBarSeries(*new QPercentBarSeriesPrivate( |
|
|
55 | QPercentBarSeries::QPercentBarSeries(QObject *parent) | |
|
56 | : QBarSeries(*new QPercentBarSeriesPrivate(this), parent) | |
|
58 | 57 | { |
|
59 | 58 | } |
|
60 | 59 | |
@@ -65,7 +64,7 QAbstractSeries::SeriesType QPercentBarSeries::type() const | |||
|
65 | 64 | |
|
66 | 65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
67 | 66 | |
|
68 |
QPercentBarSeriesPrivate::QPercentBarSeriesPrivate( |
|
|
67 | QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QPercentBarSeries *q) : QBarSeriesPrivate(q) | |
|
69 | 68 | { |
|
70 | 69 | |
|
71 | 70 | } |
@@ -32,7 +32,7 class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries | |||
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 | 34 | public: |
|
35 |
explicit QPercentBarSeries( |
|
|
35 | explicit QPercentBarSeries(QObject *parent = 0); | |
|
36 | 36 | QAbstractSeries::SeriesType type() const; |
|
37 | 37 | |
|
38 | 38 | private: |
@@ -32,8 +32,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
32 | 32 | \brief part of QtCommercial chart API. |
|
33 | 33 | \mainclass |
|
34 | 34 | |
|
35 |
QStackedBarSeries represents a series of data shown as bars. |
|
|
36 | stacked on top of each other. One QStackedBarSeries can contain multiple QBarSet data sets. | |
|
35 | QStackedBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars | |
|
36 | as stacks, where bars in same category are stacked on top of each other. | |
|
37 | 37 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
38 | 38 | |
|
39 | 39 | See the \l {StackedbarChart Example} {stacked bar chart example} to learn how to create a stacked bar chart. |
@@ -45,15 +45,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
45 | 45 | /*! |
|
46 | 46 | \fn virtual QSeriesType QStackedBarSeries::type() const |
|
47 | 47 | \brief Returns type of series. |
|
48 | \sa QSeriesType | |
|
48 | \sa QAbstractSeries, QSeriesType | |
|
49 | 49 | */ |
|
50 | 50 | |
|
51 | 51 | /*! |
|
52 | Constructs empty QStackedBarSeries. Parameter \a categories defines the categories for chart. | |
|
52 | Constructs empty QStackedBarSeries. | |
|
53 | 53 | QStackedBarSeries is QObject which is a child of a \a parent. |
|
54 | 54 | */ |
|
55 |
QStackedBarSeries::QStackedBarSeries( |
|
|
56 |
: QBarSeries(*new QStackedBarSeriesPrivate( |
|
|
55 | QStackedBarSeries::QStackedBarSeries(QObject *parent) | |
|
56 | : QBarSeries(*new QStackedBarSeriesPrivate(this), parent) | |
|
57 | 57 | { |
|
58 | 58 | } |
|
59 | 59 | |
@@ -64,7 +64,7 QAbstractSeries::SeriesType QStackedBarSeries::type() const | |||
|
64 | 64 | |
|
65 | 65 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
66 | 66 | |
|
67 |
QStackedBarSeriesPrivate::QStackedBarSeriesPrivate( |
|
|
67 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QStackedBarSeries *q) : QBarSeriesPrivate(q) | |
|
68 | 68 | { |
|
69 | 69 | |
|
70 | 70 | } |
@@ -32,7 +32,7 class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries | |||
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 | 34 | public: |
|
35 |
explicit QStackedBarSeries( |
|
|
35 | explicit QStackedBarSeries(QObject *parent = 0); | |
|
36 | 36 | QAbstractSeries::SeriesType type() const; |
|
37 | 37 | |
|
38 | 38 | private: |
@@ -88,6 +88,7 void ChartDataSet::addSeries(QAbstractSeries* series, QAxis *axisY) | |||
|
88 | 88 | |
|
89 | 89 | series->d_ptr->scaleDomain(*domain); |
|
90 | 90 | |
|
91 | // Note that with SeriesTypeBar we don't set up categories, but use real values on x-asis | |
|
91 | 92 | if(series->type() == QAbstractSeries::SeriesTypeGroupedBar |
|
92 | 93 | || series->type() == QAbstractSeries::SeriesTypeStackedBar |
|
93 | 94 | || series->type() == QAbstractSeries::SeriesTypePercentBar) { |
General Comments 0
You need to be logged in to leave comments.
Login now