@@ -1,62 +1,75 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | import QtQuick 2.0 |
|
19 | import QtQuick 2.0 | |
20 |
import QtCharts 2. |
|
20 | import QtCharts 2.1 | |
21 |
|
21 | |||
22 | Flow { |
|
22 | Flow { | |
23 | anchors.fill: parent |
|
23 | anchors.fill: parent | |
24 | property variant chart |
|
24 | property variant chart | |
25 | flow: Flow.TopToBottom |
|
25 | flow: Flow.TopToBottom | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 |
|
27 | |||
28 | Button { |
|
28 | Button { | |
29 | text: "add line" |
|
29 | text: "add line" | |
30 | onClicked: addXYSeries(ChartView.SeriesTypeLine, "line"); |
|
30 | onClicked: addXYSeries(ChartView.SeriesTypeLine, "line", false); | |
|
31 | } | |||
|
32 | Button { | |||
|
33 | text: "add GL line" | |||
|
34 | onClicked: addXYSeries(ChartView.SeriesTypeLine, "GL line", true); | |||
31 | } |
|
35 | } | |
32 | Button { |
|
36 | Button { | |
33 | text: "add spline" |
|
37 | text: "add spline" | |
34 | onClicked: addXYSeries(ChartView.SeriesTypeSpline, "spline"); |
|
38 | onClicked: addXYSeries(ChartView.SeriesTypeSpline, "spline", false); | |
35 | } |
|
39 | } | |
36 | Button { |
|
40 | Button { | |
37 | text: "add scatter" |
|
41 | text: "add scatter" | |
38 | onClicked: addXYSeries(ChartView.SeriesTypeScatter, "scatter"); |
|
42 | onClicked: addXYSeries(ChartView.SeriesTypeScatter, "scatter", false); | |
|
43 | } | |||
|
44 | Button { | |||
|
45 | text: "add GL scatter" | |||
|
46 | onClicked: addXYSeries(ChartView.SeriesTypeScatter, "GL scatter", true); | |||
39 | } |
|
47 | } | |
40 | Button { |
|
48 | Button { | |
41 | text: "remove last" |
|
49 | text: "remove last" | |
42 | onClicked: { |
|
50 | onClicked: { | |
43 | if (chart.count > 0) |
|
51 | if (chart.count > 0) | |
44 | chart.removeSeries(chart.series(chart.count - 1)); |
|
52 | chart.removeSeries(chart.series(chart.count - 1)); | |
45 | else |
|
53 | else | |
46 | chart.removeSeries(0); |
|
54 | chart.removeSeries(0); | |
47 | } |
|
55 | } | |
48 | } |
|
56 | } | |
49 | Button { |
|
57 | Button { | |
50 | text: "remove all" |
|
58 | text: "remove all" | |
51 | onClicked: chart.removeAllSeries(); |
|
59 | onClicked: chart.removeAllSeries(); | |
52 | } |
|
60 | } | |
53 |
|
61 | |||
54 | function addXYSeries(type, name) { |
|
62 | function addXYSeries(type, name, openGl) { | |
55 | var series = chart.createSeries(type, name + " " + chart.count); |
|
63 | var series = chart.createSeries(type, name + " " + chart.count); | |
56 | for (var i = chart.axisX().min; i < chart.axisX().max; i++) { |
|
64 | var multiplier = 10; | |
|
65 | if (openGl) { | |||
|
66 | series.useOpenGL = true; | |||
|
67 | multiplier = 100; | |||
|
68 | } | |||
|
69 | for (var i = chart.axisX().min * multiplier; i < chart.axisX().max * multiplier; i++) { | |||
57 | var y = Math.random() * (chart.axisY().max - chart.axisY().min) + chart.axisY().min; |
|
70 | var y = Math.random() * (chart.axisY().max - chart.axisY().min) + chart.axisY().min; | |
58 | var x = Math.random() + i; |
|
71 | var x = (Math.random() + i) / multiplier; | |
59 | series.append(x, y); |
|
72 | series.append(x, y); | |
60 | } |
|
73 | } | |
61 | } |
|
74 | } | |
62 | } |
|
75 | } |
General Comments 0
You need to be logged in to leave comments.
Login now