examples-barchart.qdoc
34 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
|
r1208 | 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. | ||
Michal Klocek
|
r330 | |||
Tero Ahola
|
r971 | \image examples_barchart.png | ||
sauimone
|
r387 | |||
sauimone
|
r1208 | Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | ||
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. | ||||
sauimone
|
r387 | |||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 1 | ||
sauimone
|
r387 | |||
sauimone
|
r1208 | To combine the sets to a chart, we need to create QBarSeries instance. Then we append our barsets to the series. | ||
sauimone
|
r387 | |||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 2 | ||
sauimone
|
r387 | |||
sauimone
|
r1208 | Next we create a chart and add the series to it. | ||
Tero Ahola
|
r971 | |||
sauimone
|
r1208 | \snippet ../examples/barchart/main.cpp 3 | ||
sauimone
|
r387 | |||
sauimone
|
r1208 | 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. | ||
Tero Ahola
|
r971 | |||
sauimone
|
r1208 | \snippet ../examples/barchart/main.cpp 4 | ||
sauimone
|
r387 | |||
Tero Ahola
|
r971 | Finally we add the chart onto a view. | ||
sauimone
|
r1208 | \snippet ../examples/barchart/main.cpp 5 | ||
Tero Ahola
|
r971 | |||
And it is ready to be shown in a window. | ||||
sauimone
|
r1208 | \snippet ../examples/percentbarchart/main.cpp 6 | ||
Tero Ahola
|
r971 | */ | ||