@@ -17,7 +17,7 | |||
|
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 |
@@ -27,15 +27,23 Flow { | |||
|
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" |
@@ -51,11 +59,16 Flow { | |||
|
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 | } |
General Comments 0
You need to be logged in to leave comments.
Login now