##// END OF EJS Templates
Rename ekgchart -> dynamicspline
Jani Honkonen -
r977:0f732f6459ec
parent child
Show More
@@ -1,75 +1,65
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "chart.h"
21 #include "chart.h"
22 #include <QChartAxis>
22 #include <QChartAxis>
23 #include <QSplineSeries>
23 #include <QSplineSeries>
24 #include <QTime>
24 #include <QTime>
25
25
26 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
26 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
27 :QChart(parent, wFlags),
27 :QChart(parent, wFlags),
28 m_step(1),
28 m_step(1),
29 m_x(0),
29 m_x(0),
30 m_y(1)
30 m_y(1)
31 {
31 {
32 QTime now = QTime::currentTime();
32 qsrand((uint) QTime::currentTime().msec());
33 qsrand((uint)now.msec());
34
33
35 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
34 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
36 m_timer.setInterval(1000);
35 m_timer.setInterval(1000);
37
36
38 m_series0 = new QLineSeries(this);
37 m_series = new QSplineSeries(this);
39 QPen blue(Qt::blue);
40 blue.setWidth(3);
41 m_series0->setPen(blue);
42
43 m_series1 = new QSplineSeries(this);
44 QPen green(Qt::red);
38 QPen green(Qt::red);
45 green.setWidth(3);
39 green.setWidth(3);
46 m_series1->setPen(green);
40 m_series->setPen(green);
41 m_series->append(m_x, m_y);
47
42
48 m_series0->append(m_x, m_y);
43 addSeries(m_series);
49 m_series1->append(m_x, m_y);
50
44
51 addSeries(m_series0);
52 addSeries(m_series1);
53 axisY()->setRange(-5, 5);
45 axisY()->setRange(-5, 5);
54 axisX()->setRange(-9, 1);
46 axisX()->setRange(-9, 1);
55 axisX()->setTicksCount(11);
47 axisX()->setTicksCount(11);
48
56 m_timer.start();
49 m_timer.start();
57 }
50 }
58
51
59 Chart::~Chart()
52 Chart::~Chart()
60 {
53 {
61
54
62 }
55 }
63
56
64 void Chart::handleTimeout()
57 void Chart::handleTimeout()
65 {
58 {
66 m_x += m_step;
59 m_x += m_step;
67 m_y = qrand() % 5 - 2.5;
60 m_y = qrand() % 5 - 2.5;
68 m_series0->append(m_x, m_y);
61 m_series->append(m_x, m_y);
69 m_series1->append(m_x, m_y);
62 if (m_x >= 10)
70 if (m_x >= 10) {
63 m_series->remove(m_x - 10);
71 m_series0->remove(m_x - 10);
72 m_series1->remove(m_x - 10);
73 }
74 scrollRight();
64 scrollRight();
75 }
65 }
@@ -1,56 +1,54
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHART_H_
21 #ifndef CHART_H_
22 #define CHART_H_
22 #define CHART_H_
23
23
24 #include <QChart>
24 #include <QChart>
25 #include <QTimer>
25 #include <QTimer>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QSplineSeries;
28 class QSplineSeries;
29 class QLineSeries;
30 QTCOMMERCIALCHART_END_NAMESPACE
29 QTCOMMERCIALCHART_END_NAMESPACE
31
30
32 QTCOMMERCIALCHART_USE_NAMESPACE
31 QTCOMMERCIALCHART_USE_NAMESPACE
33
32
34 //![1]
33 //![1]
35 class Chart: public QChart
34 class Chart: public QChart
36 {
35 {
37 Q_OBJECT
36 Q_OBJECT
38 public:
37 public:
39 Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
38 Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
40 virtual ~Chart();
39 virtual ~Chart();
41
40
42 public slots:
41 public slots:
43 void handleTimeout();
42 void handleTimeout();
44
43
45 private:
44 private:
46 QTimer m_timer;
45 QTimer m_timer;
47 QLineSeries* m_series0;
46 QSplineSeries* m_series;
48 QSplineSeries* m_series1;
49 QStringList m_titles;
47 QStringList m_titles;
50 qreal m_step;
48 qreal m_step;
51 qreal m_x;
49 qreal m_x;
52 qreal m_y;
50 qreal m_y;
53 };
51 };
54 //![1]
52 //![1]
55
53
56 #endif /* CHART_H_ */
54 #endif /* CHART_H_ */
@@ -1,6 +1,6
1 !include( ../examples.pri ) {
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
2 error( "Couldn't find the examples.pri file!" )
3 }
3 }
4 TARGET = ekgchart
4 TARGET = dynamicspline
5 HEADERS += chart.h
5 HEADERS += chart.h
6 SOURCES += main.cpp chart.cpp No newline at end of file
6 SOURCES += main.cpp chart.cpp
@@ -1,41 +1,41
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "chart.h"
21 #include "chart.h"
22 #include <QChartView>
22 #include <QChartView>
23 #include <QApplication>
23 #include <QApplication>
24 #include <QMainWindow>
24 #include <QMainWindow>
25
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
27
28 int main(int argc, char *argv[])
28 int main(int argc, char *argv[])
29 {
29 {
30 QApplication a(argc, argv);
30 QApplication a(argc, argv);
31 QMainWindow window;
31 QMainWindow window;
32 Chart *chart = new Chart;
32 Chart *chart = new Chart;
33 chart->setTitle("Simple EKG chart");
33 chart->setTitle("Dynamic spline chart");
34 chart->setAnimationOptions(QChart::AllAnimations);
34 chart->setAnimationOptions(QChart::AllAnimations);
35 QChartView chartView(chart);
35 QChartView chartView(chart);
36 chartView.setRenderHint(QPainter::Antialiasing);
36 chartView.setRenderHint(QPainter::Antialiasing);
37 window.setCentralWidget(&chartView);
37 window.setCentralWidget(&chartView);
38 window.resize(400, 300);
38 window.resize(400, 300);
39 window.show();
39 window.show();
40 return a.exec();
40 return a.exec();
41 }
41 }
@@ -1,26 +1,26
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += \
2 SUBDIRS += \
3 areachart \
3 areachart \
4 barchart \
4 barchart \
5 customchart \
5 customchart \
6 ekgchart \
6 dynamicspline \
7 linechart \
7 linechart \
8 percentbarchart \
8 percentbarchart \
9 piechart \
9 piechart \
10 piechartdrilldown \
10 piechartdrilldown \
11 presenterchart \
11 presenterchart \
12 scatterchart \
12 scatterchart \
13 scatterinteractions \
13 scatterinteractions \
14 splinechart \
14 splinechart \
15 stackedbarchart \
15 stackedbarchart \
16 stackedbarchartdrilldown \
16 stackedbarchartdrilldown \
17 zoomlinechart \
17 zoomlinechart \
18 modeldata
18 modeldata
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
General Comments 0
You need to be logged in to leave comments. Login now