##// END OF EJS Templates
F1 qml example fixed
Marek Rosa -
r1663:12a2900c59b3
parent child
Show More
@@ -25,10 +25,11
25 #include <QTime>
25 #include <QTime>
26 #include <QDebug>
26 #include <QDebug>
27
27
28 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
28 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags):
29 :QChart(parent, wFlags),
29 QChart(parent, wFlags),
30 m_step(0),
30 m_series(0),
31 m_axis(new QValuesAxis),
31 m_axis(new QValuesAxis),
32 m_step(0),
32 m_x(5),
33 m_x(5),
33 m_y(1)
34 m_y(1)
34 {
35 {
@@ -64,26 +64,27 Rectangle {
64 if (!lineSeries)
64 if (!lineSeries)
65 lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver);
65 lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver);
66
66
67 // after the series has been created set the axes ranges.
68 if (currentIndex < 3) {
67 if (currentIndex < 3) {
69 chartView.axisY.min = 0;
68 chartView.createDefaultAxes();
70 chartView.axisY.max = 250
69 chartView.axisY(lineSeries).min = 0;
70 chartView.axisY(lineSeries).max = 250
71 }
71 }
72
72
73 lineSeries.append(currentIndex, speedsXml.get(currentIndex).speed);
73 lineSeries.append(currentIndex, speedsXml.get(currentIndex).speed);
74
74
75 // Make the x-axis range dynamic
75 // Make the x-axis range dynamic
76 if (currentIndex > 9)
76 if (currentIndex > 9)
77 chartView.axisX.min = currentIndex - 10;
77 chartView.axisX(lineSeries).min = currentIndex - 10;
78 else
78 else
79 chartView.axisX.min = 0;
79 chartView.axisX(lineSeries).min = 0;
80 chartView.axisX.max = currentIndex + 1;
80
81 chartView.axisX(lineSeries).max = currentIndex + 1;
81 } else {
82 } else {
82 // No more data, change x-axis range to show all the data
83 // No more data, change x-axis range to show all the data
83 timer.stop();
84 timer.stop();
84 chartView.animationOptions = ChartView.AllAnimations;
85 chartView.animationOptions = ChartView.AllAnimations;
85 chartView.axisX.min = 0;
86 chartView.axisX(lineSeries).min = 0;
86 chartView.axisX.max = currentIndex + 1;
87 chartView.axisX(lineSeries).max = currentIndex + 1;
87 }
88 }
88 }
89 }
89 }
90 }
@@ -492,7 +492,6 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType typ
492 }
492 }
493 series->setName(name);
493 series->setName(name);
494 m_chart->addSeries(series);
494 m_chart->addSeries(series);
495 m_chart->createDefaultAxes();
496 return series;
495 return series;
497 }
496 }
498
497
General Comments 0
You need to be logged in to leave comments. Login now