##// END OF EJS Templates
Fix value axis documentation...
Fix value axis documentation QML documentation does not show obsolete properties correctly. Removed the obsolete key and added a deprecated comment. Related typos fixed. Change-Id: I86c862e4f587541df0a08363834ad13efc14e1b4 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>

File last commit:

r2610:66fa88d10640
r2636:25b732239a6d
Show More
examples-datetimeaxis.qdoc
38 lines | 1.9 KiB | text/plain | TextLexer
/ doc / src / examples-datetimeaxis.qdoc
/*!
\example examples/datetimeaxis
\title DateTimeAxis Example
\subtitle
The example shows how to use QLineChart with QDateTimeAxis.
\image examples_datetimeaxis.png
To create line chart, QLineSeries instance is needed. Let's create one.
\snippet ../examples/datetimeaxis/main.cpp 1
On the charts we will present how the number of sun spots changes in time. The data (from the Space Weather Prediction Center) is read from a text file.
In the snippet below, notice how the QDateTime::toMSecsSinceEpoch method is used to convert the QDateTime object into a number that can be passed to the QLineSeries append method.
\snippet ../examples/datetimeaxis/main.cpp 2
To present the data on the chart we need the QChart instance. We add the series to it, hide the legend, create the default axes and set the title of the chart.
\snippet ../examples/datetimeaxis/main.cpp 3
Since we use QLineSeries, calling createDefaultAxes will create QValueAxis both as X- and Y-axis. To use QDateTimeAxis we need to set it manually to the chart.
First, the instance of QDateTimeAxis is created, then the number of ticks to be shown is set. The number of sun spots is provided as an average for the month.
Therefore we don't need the axis labels to contain the information about the time and the day. This is achieved by setting a custom label format.
Please refer to the QDateTime::toString() method documentation to learn about the available format options.
\snippet ../examples/datetimeaxis/main.cpp 4
Then we create a QChartView object with QChart as a parameter. This way we don't need to create the QGraphicsView scene ourselves. We also set the Antialiasing on to have the rendered lines look nicer.
\snippet ../examples/datetimeaxis/main.cpp 5
The chart is ready to be shown.
\snippet ../examples/datetimeaxis/main.cpp 6
*/