Debian Codegraph @

examples/charts/qmlchartsgallery/qml/DateTimeAxisPolar.qml

raw
1 // Copyright (C) 2023 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 import QtQuick
5 import QtCharts
6
7 //![1]
8 PolarChartView {
9 id: root
10 title: "Historical Area Chart"
11 anchors.fill: parent
12 legend.visible: false
13 antialiasing: true
14
15 DateTimeAxis {
16 id: axis1
17 format: "yyyy MMM"
18 tickCount: 13
19 }
20 ValueAxis {
21 id: axis2
22 }
23 LineSeries {
24 id: lowerLine
25 axisAngular: axis1
26 axisRadial: axis2
27
28 // Please note that month in JavaScript months are zero based, so 2 means March
29 XYPoint { x: root.toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 15 }
30 XYPoint { x: root.toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 35 }
31 XYPoint { x: root.toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 }
32 XYPoint { x: root.toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 75 }
33 XYPoint { x: root.toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 102 }
34 XYPoint { x: root.toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 132 }
35 XYPoint { x: root.toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 }
36 XYPoint { x: root.toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 120 }
37 XYPoint { x: root.toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 140 }
38 XYPoint { x: root.toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 150 }
39 }
40 LineSeries {
41 id: upperLine
42 axisAngular: axis1
43 axisRadial: axis2
44
45 // Please note that month in JavaScript months are zero based, so 2 means March
46 XYPoint { x: root.toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 30 }
47 XYPoint { x: root.toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 55 }
48 XYPoint { x: root.toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 80 }
49 XYPoint { x: root.toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 105 }
50 XYPoint { x: root.toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 125 }
51 XYPoint { x: root.toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 160 }
52 XYPoint { x: root.toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 140 }
53 XYPoint { x: root.toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 140 }
54 XYPoint { x: root.toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 170 }
55 XYPoint { x: root.toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 200 }
56 }
57 AreaSeries {
58 axisAngular: axis1
59 axisRadial: axis2
60 lowerSeries: lowerLine
61 upperSeries: upperLine
62 }
63
64 // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to
65 // milliseconds since epoch to make them match the DateTimeAxis values
66 function toMsecsSinceEpoch(date) {
67 var msecs = date.getTime();
68 return msecs;
69 }
70 }
71 //![1]