examples-barchart.qdoc
34 lines
| 1.2 KiB
| text/plain
|
TextLexer
|
r330 | /*! | ||
|
r500 | \example examples/barchart | ||
|
r387 | \title BarChart Example | ||
\subtitle | ||||
|
r330 | |||
|
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. | ||
|
r330 | |||
|
r971 | \image examples_barchart.png | ||
|
r387 | |||
|
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. | ||||
|
r387 | |||
|
r492 | \snippet ../examples/barchart/main.cpp 1 | ||
|
r387 | |||
|
r1208 | To combine the sets to a chart, we need to create QBarSeries instance. Then we append our barsets to the series. | ||
|
r387 | |||
|
r492 | \snippet ../examples/barchart/main.cpp 2 | ||
|
r387 | |||
|
r1208 | Next we create a chart and add the series to it. | ||
|
r971 | |||
|
r1208 | \snippet ../examples/barchart/main.cpp 3 | ||
|
r387 | |||
|
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. | ||
|
r971 | |||
|
r1208 | \snippet ../examples/barchart/main.cpp 4 | ||
|
r387 | |||
|
r971 | Finally we add the chart onto a view. | ||
|
r1208 | \snippet ../examples/barchart/main.cpp 5 | ||
|
r971 | |||
And it is ready to be shown in a window. | ||||
|
r1208 | \snippet ../examples/percentbarchart/main.cpp 6 | ||
|
r971 | */ | ||