1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30import QtQuick 2.0
31import QtCharts 2.0
32
33Item {
34    anchors.fill: parent
35
36    //![1]
37    PolarChartView {
38        title: "Historical Area Series"
39        anchors.fill: parent
40        legend.visible: false
41        antialiasing: true
42
43        DateTimeAxis {
44            id: axis1
45            format: "yyyy MMM"
46            tickCount: 13
47        }
48        ValueAxis {
49            id: axis2
50        }
51        LineSeries {
52            id: lowerLine
53            axisAngular: axis1
54            axisRadial: axis2
55
56            // Please note that month in JavaScript months are zero based, so 2 means March
57            XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 15 }
58            XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 35 }
59            XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 }
60            XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 75 }
61            XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 102 }
62            XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 132 }
63            XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 }
64            XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 120 }
65            XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 140 }
66            XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 150 }
67        }
68        LineSeries {
69            id: upperLine
70            axisAngular: axis1
71            axisRadial: axis2
72
73            // Please note that month in JavaScript months are zero based, so 2 means March
74            XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 30 }
75            XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 55 }
76            XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 80 }
77            XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 105 }
78            XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 125 }
79            XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 160 }
80            XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 140 }
81            XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 140 }
82            XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 170 }
83            XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 200 }
84        }
85        AreaSeries {
86            axisAngular: axis1
87            axisRadial: axis2
88            lowerSeries: lowerLine
89            upperSeries: upperLine
90        }
91    }
92    // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to
93    // milliseconds since epoch to make them match the DateTimeAxis values
94    function toMsecsSinceEpoch(date) {
95        var msecs = date.getTime();
96        return msecs;
97    }
98    //![1]
99}
100