examples-barchart.qdoc
40 lines
| 1.2 KiB
| text/plain
|
TextLexer
Michal Klocek
|
r330 | /*! | ||
Tero Ahola
|
r500 | \example examples/barchart | ||
sauimone
|
r387 | \title BarChart Example | ||
\subtitle | ||||
Michal Klocek
|
r330 | |||
sauimone
|
r387 | The example shows how to create simple bar chart. Barchart shows the data in sets as separate bars, which are grouped in categories. | ||
Michal Klocek
|
r330 | |||
Tero Ahola
|
r971 | \image examples_barchart.png | ||
sauimone
|
r387 | |||
First we define categories. | ||||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 1 | ||
sauimone
|
r387 | |||
Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | ||||
Tero Ahola
|
r971 | we want to visualize to them. | ||
sauimone
|
r387 | |||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 2 | ||
sauimone
|
r387 | |||
To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating | ||||
the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets | ||||
are added to series here. | ||||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 3 | ||
sauimone
|
r387 | |||
Tero Ahola
|
r971 | Then we create a chart and add the series to it. | ||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 4 | ||
sauimone
|
r387 | |||
Tero Ahola
|
r971 | And we also want to show the legend, so that the data is easier to read. | ||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 5 | ||
sauimone
|
r387 | |||
Tero Ahola
|
r971 | Finally we add the chart onto a view. | ||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 6 | ||
Tero Ahola
|
r971 | |||
And it is ready to be shown in a window. | ||||
\snippet ../examples/percentbarchart/main.cpp 7 | ||||
*/ | ||||