Debian Codegraph @

examples/charts/qmlchartsgallery/doc/src/qmlchartsgallery.qdoc

raw
1 // Copyright (C) 2023 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4 /*!
5 \example qmlchartsgallery
6 \title Charts with QML Gallery
7 \ingroup qtcharts_examples
8 \examplecategory {Data Visualization}
9 \examplecategory {Mobile}
10 \brief Demonstrates how to use the different chart types by using qml.
11
12 \image QMLChartsGallery.png {Screenshot showing the number of NHL All-Star Team
13 Players from three different countries displayed as an area chart, the
14 green area being Swedish, the blue area being Russian, and the orange
15 area being Finnish. On the left side are different options to change the
16 chart to different chart types}
17
18 \include examples-run.qdocinc
19
20 This is a Qt Quick application, the files for each chart type are located in
21 the qml directory of the example folder and are loaded arranged into a
22 ListView by main.qml, located in this examples directory.
23
24 This documentation won't focus on the top level layout or loading, but
25 rather on the use of the Qt Charts QML API.
26
27 \section1 Including dependencies
28
29 All .qml files start with:
30 \qml
31 import QtQuick
32 import QtCharts
33 \endqml
34
35 \section1 Creating charts with QML
36
37 Creating each chart type begins with the creation of a ChartView.
38
39 To create a pie chart, we use the PieSeries API together with a few PieSlices:
40
41 \image examples_qmlchart1.png {Screenshot showing the top five car brand
42 shares in Finland displayed as a pie chart}
43 \snippet qmlchartsgallery/qml/PieChart.qml 1
44
45 You can create a chart with a line series:
46
47 \image examples_qmlchart2.png {Screenshot showing a line chart example}
48 \snippet qmlchartsgallery/qml/LineSeries.qml 1
49
50 And a spline series:
51
52 \image examples_qmlchart3.png {Screenshot showing a spline chart example}
53 \snippet qmlchartsgallery/qml/SplineSeries.qml 1
54
55 You can create a chart that illustrates the NHL All-Star player selections
56 by using three area series:
57
58 \image examples_qmlchart4.png {Screenshot showing the number of NHL All-Star
59 Team Players from three different countries displayed as an area chart,
60 the green area being Swedish, the blue area being Russian, and the
61 orange area being Finnish}
62 \snippet qmlchartsgallery/qml/AreaSeries.qml 1
63 \dots
64
65 Then a couple of scatter series:
66
67 \image examples_qmlchart5.png {Screenshot showing two scatter series stacked in
68 a chart and with scatter1 having blue dots and scatter2 having green
69 dots}
70 \snippet qmlchartsgallery/qml/ScatterSeries.qml 1
71 \dots
72
73 And a few different bar series:
74
75 \image examples_qmlchart6.png {Screenshot showing contributions from three
76 different people as a bar series, with Bob being the blue bar, Susan being
77 green and James being orange}
78 \snippet qmlchartsgallery/qml/BarSeries.qml 1
79
80 \image examples_qmlchart7.png {Screenshot showing the contributions from the
81 same people but as a stacked bar series}
82 \snippet qmlchartsgallery/qml/BarSeriesStacked.qml 1
83
84 \image examples_qmlchart8.png {Screenshot showing the contributions from the
85 same people, but as a percent bar series}
86 \snippet qmlchartsgallery/qml/BarSeriesPercent.qml 1
87
88 \image examples_qmlchart9.png {Screenshot showing the contributions from the
89 same people but as a horizontal bar series}
90 \snippet qmlchartsgallery/qml/BarSeriesHorizontal.qml 1
91
92 \image examples_qmlchart10.png {Screenshot showing the contributions from the
93 same people, but as a horizontal stacked bar series}
94 \snippet qmlchartsgallery/qml/BarSeriesStackedHorizontal.qml 1
95
96 \image examples_qmlchart11.png {Screenshot showing the contributions from the
97 same people, but as a horizontal percent bar series}
98 \snippet qmlchartsgallery/qml/BarSeriesPercentHorizontal.qml 1
99
100 This demonstrates how to create a donut chart with two pie series:
101
102 \image examples_qmlchart12.png {Screenshot showing production costs displayed
103 as a donut chart with the main tops having subtopics}
104 \snippet qmlchartsgallery/qml/Donut.qml 1
105
106 Additionally, anti-aliasing is set with the qml property in Qt Quick 2.
107
108 \section1 More charts
109
110 See the following links for walk-through of the remaining charts in this
111 example app.
112
113 \annotatedlist charts_qml_gallery_example
114 */