@@ -1,62 +1,75 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Charts module. |
|
8 | 8 | ** |
|
9 | 9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
10 | 10 | ** accordance with the Qt License Agreement provided with the Software |
|
11 | 11 | ** or, alternatively, in accordance with the terms contained in a written |
|
12 | 12 | ** agreement between you and The Qt Company. |
|
13 | 13 | ** |
|
14 | 14 | ** If you have questions regarding the use of this file, please use |
|
15 | 15 | ** contact form at http://qt.io |
|
16 | 16 | ** |
|
17 | 17 | ****************************************************************************/ |
|
18 | 18 | |
|
19 | 19 | import QtQuick 2.0 |
|
20 |
import QtCharts 2. |
|
|
20 | import QtCharts 2.1 | |
|
21 | 21 | |
|
22 | 22 | Flow { |
|
23 | 23 | anchors.fill: parent |
|
24 | 24 | property variant chart |
|
25 | 25 | flow: Flow.TopToBottom |
|
26 | 26 | spacing: 5 |
|
27 | 27 | |
|
28 | 28 | Button { |
|
29 | 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 | 36 | Button { |
|
33 | 37 | text: "add spline" |
|
34 | onClicked: addXYSeries(ChartView.SeriesTypeSpline, "spline"); | |
|
38 | onClicked: addXYSeries(ChartView.SeriesTypeSpline, "spline", false); | |
|
35 | 39 | } |
|
36 | 40 | Button { |
|
37 | 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 | 48 | Button { |
|
41 | 49 | text: "remove last" |
|
42 | 50 | onClicked: { |
|
43 | 51 | if (chart.count > 0) |
|
44 | 52 | chart.removeSeries(chart.series(chart.count - 1)); |
|
45 | 53 | else |
|
46 | 54 | chart.removeSeries(0); |
|
47 | 55 | } |
|
48 | 56 | } |
|
49 | 57 | Button { |
|
50 | 58 | text: "remove all" |
|
51 | 59 | onClicked: chart.removeAllSeries(); |
|
52 | 60 | } |
|
53 | 61 | |
|
54 | function addXYSeries(type, name) { | |
|
62 | function addXYSeries(type, name, openGl) { | |
|
55 | 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 | 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 | 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