examples-barchart.qdoc
39 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
|
r1618 | The example shows how to create a bar chart. BarChart shows the data in sets as separate bars, which are in categories. | ||
Michal Klocek
|
r330 | |||
Tero Ahola
|
r971 | \image examples_barchart.png | ||
sauimone
|
r1618 | |||
Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | ||||
to them. | ||||
sauimone
|
r387 | |||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 1 | ||
sauimone
|
r387 | |||
sauimone
|
r1618 | We create the series and append the sets to it. The barseries groups the data from sets to categories. | ||
First value of each set are gropuped together at first category second value to second category and so on. | ||||
sauimone
|
r387 | |||
sauimone
|
r492 | \snippet ../examples/barchart/main.cpp 2 | ||
Tero Ahola
|
r971 | |||
sauimone
|
r1618 | Then we create a chart and add the series to it. | ||
sauimone
|
r387 | |||
sauimone
|
r1618 | \snippet ../examples/barchart/main.cpp 3 | ||
We define the categories here and add them to QCategoriesAxis which we then set to be the x-axis of the chart. | ||||
Tero Ahola
|
r971 | |||
sauimone
|
r1208 | \snippet ../examples/barchart/main.cpp 4 | ||
sauimone
|
r387 | |||
sauimone
|
r1618 | And we also want to show the legend. | ||
Tero Ahola
|
r971 | |||
sauimone
|
r1208 | \snippet ../examples/barchart/main.cpp 5 | ||
Tero Ahola
|
r971 | |||
sauimone
|
r1618 | Finally we add the chart onto a view. | ||
\snippet ../examples/barchart/main.cpp 6 | ||||
Tero Ahola
|
r971 | And it is ready to be shown in a window. | ||
sauimone
|
r1618 | \snippet ../examples/barchart/main.cpp 7 | ||
Tero Ahola
|
r971 | */ | ||