@@ -0,0 +1,34 | |||||
|
1 | #include "chartview.h" | |||
|
2 | #include <QScatterSeries> | |||
|
3 | ||||
|
4 | ChartView::ChartView(QWidget *parent) : | |||
|
5 | QChartView(new QChart(), parent) | |||
|
6 | { | |||
|
7 | //![1] | |||
|
8 | QScatterSeries *series0 = new QScatterSeries(); | |||
|
9 | series0->setShape(QScatterSeries::MarkerShapeCircle); | |||
|
10 | series0->setSize(15.0); | |||
|
11 | ||||
|
12 | QScatterSeries *series1 = new QScatterSeries(); | |||
|
13 | series1->setShape(QScatterSeries::MarkerShapeCircle); | |||
|
14 | series1->setSize(20.0); | |||
|
15 | //![1] | |||
|
16 | ||||
|
17 | //![2] | |||
|
18 | series0->append(0, 6); | |||
|
19 | series0->append(2, 4); | |||
|
20 | series0->append(3, 8); | |||
|
21 | series0->append(7, 4); | |||
|
22 | series0->append(10, 5); | |||
|
23 | ||||
|
24 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); | |||
|
25 | //![2] | |||
|
26 | ||||
|
27 | //![3] | |||
|
28 | setRenderHint(QPainter::Antialiasing); | |||
|
29 | chart()->addSeries(series0); | |||
|
30 | chart()->addSeries(series1); | |||
|
31 | chart()->setTitle("Simple scatterchart example"); | |||
|
32 | chart()->setBackgroundDropShadowEnabled(false); | |||
|
33 | //![3] | |||
|
34 | } |
@@ -0,0 +1,20 | |||||
|
1 | #ifndef CHARTVIEW_H | |||
|
2 | #define CHARTVIEW_H | |||
|
3 | ||||
|
4 | #include <QChartView> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
7 | ||||
|
8 | class ChartView : public QChartView | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit ChartView(QWidget *parent = 0); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | ||||
|
16 | public slots: | |||
|
17 | ||||
|
18 | }; | |||
|
19 | ||||
|
20 | #endif // CHARTVIEW_H |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,48 +1,39 | |||||
1 | /*! |
|
1 | /*! | |
2 | \example examples/presenterchart |
|
2 | \example examples/presenterchart | |
3 | \title PresenterChart Example |
|
3 | \title PresenterChart Example | |
4 | \subtitle |
|
4 | \subtitle | |
5 |
|
5 | |||
6 | The example shows how to create chart which presents the same set of data as line, scatter, spline and area charts. |
|
6 | The example shows how to create chart which presents the same set of data as line, scatter, spline and area charts. | |
7 | ChartPresenter will switch between these four chart types every few seconds. Note: You can also use the |
|
7 | ChartPresenter will switch between these four chart types every few seconds. Note: You can also use the | |
8 | QAbstractItemModel related APIs to pass data for the different series types. See the \l {Model data example} for |
|
8 | QAbstractItemModel related APIs to pass data for the different series types. See the \l {Model data example} for | |
9 | more details. |
|
9 | more details. | |
10 |
|
10 | |||
11 | \image examples_presenterchart1.png |
|
11 | \image examples_presenterchart1.png | |
12 | \image examples_presenterchart2.png |
|
12 | \image examples_presenterchart2.png | |
13 | \image examples_presenterchart3.png |
|
13 | \image examples_presenterchart3.png | |
14 | \image examples_presenterchart4.png |
|
14 | \image examples_presenterchart4.png | |
15 |
|
15 | |||
16 | We create simple ChartView class which derives form QChartView. |
|
16 | We create simple ChartView class which derives form QChartView. | |
17 |
|
17 | |||
18 | \snippet ../examples/presenterchart/chartview.h 1 |
|
18 | \snippet ../examples/presenterchart/chartview.h 1 | |
19 |
|
19 | |||
20 | Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. |
|
20 | Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. | |
21 | We are also going to provide \c handlePoitClicked() slot which will show clicked point on the chart. |
|
21 | We are also going to provide \c handlePoitClicked() slot which will show clicked point on the chart. | |
22 | Class members \c m_series and \c m_titles are going to store series and related titles. In example we are going to present data as a line chart |
|
22 | Class members \c m_series and \c m_titles are going to store series and related titles. In example we are going to present data as a line chart | |
23 | using QLineSeries , as scatter chart using QScatterSeries, as a spline chart using QSplineSeries and a area chart using QAreaSeries. We create needed instances in constructor of ChartView class. |
|
23 | using QLineSeries , as scatter chart using QScatterSeries, as a spline chart using QSplineSeries and a area chart using QAreaSeries. We create needed instances in constructor of ChartView class. | |
24 | We set custom line and points colors. |
|
24 | We set custom line and points colors. | |
25 |
|
25 | |||
26 | \snippet ../examples/presenterchart/chartview.cpp 1 |
|
26 | \snippet ../examples/presenterchart/chartview.cpp 1 | |
27 |
|
27 | |||
28 | We add data to three series. Please note area chart is going to use QLineSeries as the upper line. We can use add() member function. |
|
28 | We add data to three series. Please note area chart is going to use QLineSeries as the upper line. We can use add() member function. | |
29 |
|
29 | |||
30 | \snippet ../examples/presenterchart/chartview.cpp 2 |
|
30 | \snippet ../examples/presenterchart/chartview.cpp 2 | |
31 |
|
31 | |||
32 | In the end we store references all the created series and matching titles. |
|
32 | In the end we store references all the created series and matching titles. | |
33 |
|
33 | |||
34 | \snippet ../examples/presenterchart/chartview.cpp 3 |
|
34 | \snippet ../examples/presenterchart/chartview.cpp 3 | |
35 |
|
35 | |||
36 | We connect \c clicked() signals from each series with our \c handlePointClciked() slot. |
|
|||
37 |
|
||||
38 | \snippet ../examples/presenterchart/chartview.cpp 4 |
|
|||
39 |
|
||||
40 | In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. |
|
36 | In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. | |
41 |
|
37 | |||
42 |
\snippet ../examples/presenterchart/chartview.cpp |
|
38 | \snippet ../examples/presenterchart/chartview.cpp 4 | |
43 |
|
||||
44 | In \c handlePointClciked() slot we set the chart's title to show clicked point x and y coordinates. |
|
|||
45 |
|
||||
46 | \snippet ../examples/presenterchart/chartview.cpp 6 |
|
|||
47 |
|
||||
48 | */ |
|
39 | */ |
@@ -1,26 +1,27 | |||||
1 | /*! |
|
1 | /*! | |
2 | \example examples/scatterchart |
|
2 | \example examples/scatterchart | |
3 | \title ScatterChart Example |
|
3 | \title ScatterChart Example | |
4 | \subtitle |
|
4 | \subtitle | |
5 |
|
5 | |||
6 | The example shows how to create simple scatter chart. |
|
6 | The example shows how to create simple scatter chart. | |
7 |
|
7 | |||
8 | \image examples_scatterchart.png |
|
8 | \image examples_scatterchart.png | |
9 |
|
9 | |||
10 | To create scatter charts, QScatterSeries instance is needed. Here we create scatter series instance and we set the type, color and width of outline for scatter points. |
|
10 | To create scatter charts, QScatterSeries instance is needed. Here we create scatter series instance and we set the type, color and width of outline for scatter points. | |
11 |
|
11 | |||
12 |
\snippet ../examples/scatterchart/ |
|
12 | \snippet ../examples/scatterchart/chartview.cpp 1 | |
13 |
|
13 | |||
14 | We add data to be shown. We can use add() member function or use stream operator. |
|
14 | We add data to be shown. We can use add() member function or use stream operator. | |
15 |
|
15 | |||
16 |
\snippet ../examples/scatterchart/ |
|
16 | \snippet ../examples/scatterchart/chartview.cpp 2 | |
17 |
|
17 | |||
18 | In the end we create QChartView instance, set title, set anti-aliasing and add scatter series. |
|
18 | In the end we enable anti-aliasing, set the chart title and add the scatter series onto the chart. We also disable | |
|
19 | drop shadow, because it would not look good on an application with only chart view shown. | |||
19 |
|
20 | |||
20 |
\snippet ../examples/scatterchart/ |
|
21 | \snippet ../examples/scatterchart/chartview.cpp 3 | |
21 |
|
22 | |||
22 | Chart is ready to be shown. |
|
23 | Chart is ready to be shown. | |
23 |
|
24 | |||
24 |
\snippet ../examples/scatterchart/main.cpp 4 |
|
25 | \snippet ../examples/scatterchart/main.cpp 4 | |
25 |
|
26 | |||
26 | */ |
|
27 | */ |
@@ -1,116 +1,105 | |||||
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 "chartview.h" |
|
21 | #include "chartview.h" | |
22 | #include <QLineSeries> |
|
22 | #include <QLineSeries> | |
23 | #include <QScatterSeries> |
|
23 | #include <QScatterSeries> | |
24 | #include <QSplineSeries> |
|
24 | #include <QSplineSeries> | |
25 | #include <QAreaSeries> |
|
25 | #include <QAreaSeries> | |
26 | #include <QTime> |
|
26 | #include <QTime> | |
27 |
|
27 | |||
28 | ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), |
|
28 | ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), | |
29 | m_index(-1),m_chart(chart) |
|
29 | m_index(-1),m_chart(chart) | |
30 | { |
|
30 | { | |
31 | m_chart->setTitle("Charts presenter"); |
|
31 | m_chart->setTitle("Charts presenter"); | |
|
32 | m_chart->setBackgroundDropShadowEnabled(false); | |||
32 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); |
|
33 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); | |
33 | m_timer.setInterval(3000); |
|
34 | m_timer.setInterval(3000); | |
34 |
|
35 | |||
35 | //![1] |
|
36 | //![1] | |
36 | QLineSeries* series0 = new QLineSeries(); |
|
37 | QLineSeries* series0 = new QLineSeries(); | |
37 | QPen blue(Qt::blue); |
|
38 | QPen blue(Qt::blue); | |
38 | blue.setWidth(3); |
|
39 | blue.setWidth(3); | |
39 | series0->setPen(blue); |
|
40 | series0->setPen(blue); | |
40 |
|
41 | |||
41 | QScatterSeries* series1 = new QScatterSeries(); |
|
42 | QScatterSeries* series1 = new QScatterSeries(); | |
42 | QPen red(Qt::red); |
|
43 | QPen red(Qt::red); | |
43 | red.setWidth(3); |
|
44 | red.setWidth(3); | |
44 | series1->setPen(red); |
|
45 | series1->setPen(red); | |
45 | series1->setBrush(Qt::white); |
|
46 | series1->setBrush(Qt::white); | |
46 |
|
47 | |||
47 | QSplineSeries* series2 = new QSplineSeries(); |
|
48 | QSplineSeries* series2 = new QSplineSeries(); | |
48 | QPen green(Qt::green); |
|
49 | QPen green(Qt::green); | |
49 | green.setWidth(3); |
|
50 | green.setWidth(3); | |
50 | series2->setPen(green); |
|
51 | series2->setPen(green); | |
51 |
|
52 | |||
52 | QAreaSeries* series3 = new QAreaSeries(series0); |
|
53 | QAreaSeries* series3 = new QAreaSeries(series0); | |
53 | QPen yellow(Qt::black); |
|
54 | QPen yellow(Qt::black); | |
54 | yellow.setWidth(3); |
|
55 | yellow.setWidth(3); | |
55 | series3->setPen(yellow); |
|
56 | series3->setPen(yellow); | |
56 | series3->setBrush(Qt::yellow); |
|
57 | series3->setBrush(Qt::yellow); | |
57 | //![1] |
|
58 | //![1] | |
58 |
|
59 | |||
59 | //![2] |
|
60 | //![2] | |
60 | int numPoints = 10; |
|
61 | int numPoints = 10; | |
61 |
|
62 | |||
62 | for (int x = 0; x <= numPoints; ++x) { |
|
63 | for (int x = 0; x <= numPoints; ++x) { | |
63 | qreal y = qrand() % 100; |
|
64 | qreal y = qrand() % 100; | |
64 | series0->append(x,y); |
|
65 | series0->append(x,y); | |
65 | series1->append(x,y); |
|
66 | series1->append(x,y); | |
66 | series2->append(x,y); |
|
67 | series2->append(x,y); | |
67 | } |
|
68 | } | |
68 | //![2] |
|
69 | //![2] | |
69 |
|
70 | |||
70 | //![3] |
|
71 | //![3] | |
71 | m_series<<series0; |
|
72 | m_series<<series0; | |
72 | m_titles<< m_chart->title()+": LineChart"; |
|
73 | m_titles<< m_chart->title()+": LineChart"; | |
73 | m_series<<series1; |
|
74 | m_series<<series1; | |
74 | m_titles<< m_chart->title()+": ScatterChart"; |
|
75 | m_titles<< m_chart->title()+": ScatterChart"; | |
75 | m_series<<series2; |
|
76 | m_series<<series2; | |
76 | m_titles<< m_chart->title()+": SplineChart"; |
|
77 | m_titles<< m_chart->title()+": SplineChart"; | |
77 | m_series<<series3; |
|
78 | m_series<<series3; | |
78 | m_titles<< m_chart->title()+": AreaChart"; |
|
79 | m_titles<< m_chart->title()+": AreaChart"; | |
79 | //![3] |
|
80 | //![3] | |
80 |
|
81 | |||
81 | //![4] |
|
|||
82 | foreach (QAbstractSeries* series, m_series) { |
|
|||
83 | QObject::connect(series,SIGNAL(clicked(QPointF)),this,SLOT(handlePointClicked(QPointF))); |
|
|||
84 | } |
|
|||
85 | //![4] |
|
|||
86 | m_timer.start(); |
|
82 | m_timer.start(); | |
87 | handleTimeout(); |
|
83 | handleTimeout(); | |
88 | } |
|
84 | } | |
89 |
|
85 | |||
90 | ChartView::~ChartView() |
|
86 | ChartView::~ChartView() | |
91 | { |
|
87 | { | |
92 | if(m_series.size()==0) return; |
|
88 | if(m_series.size()==0) return; | |
93 | m_chart->removeSeries(m_series.at(m_index)); |
|
89 | m_chart->removeSeries(m_series.at(m_index)); | |
94 | m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone |
|
90 | m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone | |
95 | qDeleteAll(m_series); |
|
91 | qDeleteAll(m_series); | |
96 | } |
|
92 | } | |
97 |
|
93 | |||
98 |
//![ |
|
94 | //![4] | |
99 | void ChartView::handleTimeout() |
|
95 | void ChartView::handleTimeout() | |
100 | { |
|
96 | { | |
101 | if(m_series.size()==0) return; |
|
97 | if(m_series.size()==0) return; | |
102 | if(m_index>=0) |
|
98 | if(m_index>=0) | |
103 | m_chart->removeSeries(m_series.at(m_index)); |
|
99 | m_chart->removeSeries(m_series.at(m_index)); | |
104 | m_index++; |
|
100 | m_index++; | |
105 | m_index=m_index%m_series.size(); |
|
101 | m_index=m_index%m_series.size(); | |
106 | m_chart->addSeries(m_series.at(m_index)); |
|
102 | m_chart->addSeries(m_series.at(m_index)); | |
107 | m_chart->setTitle(m_titles.at(m_index)); |
|
103 | m_chart->setTitle(m_titles.at(m_index)); | |
108 | } |
|
104 | } | |
109 |
//![ |
|
105 | //![4] | |
110 |
|
||||
111 | //![6] |
|
|||
112 | void ChartView::handlePointClicked(const QPointF& point) |
|
|||
113 | { |
|
|||
114 | m_chart->setTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y())); |
|
|||
115 | } |
|
|||
116 | //![6] |
|
@@ -1,50 +1,49 | |||||
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 CHARTVIEW_H_ |
|
21 | #ifndef CHARTVIEW_H_ | |
22 | #define CHARTVIEW_H_ |
|
22 | #define CHARTVIEW_H_ | |
23 |
|
23 | |||
24 | #include <QChartView> |
|
24 | #include <QChartView> | |
25 | #include <QTimer> |
|
25 | #include <QTimer> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | //![1] |
|
29 | //![1] | |
30 | class ChartView: public QChartView |
|
30 | class ChartView: public QChartView | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | ChartView(QChart* chart,QWidget* parent = 0); |
|
34 | ChartView(QChart* chart,QWidget* parent = 0); | |
35 | virtual ~ChartView(); |
|
35 | virtual ~ChartView(); | |
36 |
|
36 | |||
37 | public slots: |
|
37 | public slots: | |
38 | void handleTimeout(); |
|
38 | void handleTimeout(); | |
39 | void handlePointClicked(const QPointF& point); |
|
|||
40 |
|
39 | |||
41 | private: |
|
40 | private: | |
42 | QTimer m_timer; |
|
41 | QTimer m_timer; | |
43 | QList<QAbstractSeries *> m_series; |
|
42 | QList<QAbstractSeries *> m_series; | |
44 | QStringList m_titles; |
|
43 | QStringList m_titles; | |
45 | int m_index; |
|
44 | int m_index; | |
46 | QChart *m_chart; |
|
45 | QChart *m_chart; | |
47 | }; |
|
46 | }; | |
48 | //![1] |
|
47 | //![1] | |
49 |
|
48 | |||
50 | #endif /* CHARTVIEW_H_ */ |
|
49 | #endif /* CHARTVIEW_H_ */ |
@@ -1,39 +1,39 | |||||
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 "chartview.h" |
|
21 | #include "chartview.h" | |
22 | #include <QApplication> |
|
22 | #include <QApplication> | |
23 | #include <QMainWindow> |
|
23 | #include <QMainWindow> | |
24 |
|
24 | |||
25 | int main(int argc, char *argv[]) |
|
25 | int main(int argc, char *argv[]) | |
26 | { |
|
26 | { | |
27 | QApplication a(argc, argv); |
|
27 | QApplication a(argc, argv); | |
28 | QMainWindow window; |
|
28 | QMainWindow window; | |
29 | QChart* chart = new QChart(); |
|
29 | QChart* chart = new QChart(); | |
30 | chart->axisX()->setNiceNumbersEnabled(true); |
|
30 | chart->axisX()->setNiceNumbersEnabled(true); | |
31 | chart->axisY()->setNiceNumbersEnabled(true); |
|
31 | chart->axisY()->setNiceNumbersEnabled(true); | |
32 | ChartView chartView(chart,&window); |
|
32 | ChartView chartView(chart,&window); | |
33 | chartView.setRenderHint(QPainter::Antialiasing); |
|
33 | chartView.setRenderHint(QPainter::Antialiasing); | |
34 |
chart->setAnimationOptions(QChart:: |
|
34 | chart->setAnimationOptions(QChart::SeriesAnimations); | |
35 | window.setCentralWidget(&chartView); |
|
35 | window.setCentralWidget(&chartView); | |
36 | window.resize(400, 300); |
|
36 | window.resize(400, 300); | |
37 | window.show(); |
|
37 | window.show(); | |
38 | return a.exec(); |
|
38 | return a.exec(); | |
39 | } |
|
39 | } |
@@ -1,82 +1,40 | |||||
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 <QtGui/QApplication> |
|
21 | #include <QtGui/QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 |
#include |
|
23 | #include "chartview.h" | |
24 | #include <QScatterSeries> |
|
|||
25 |
|
24 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
26 | |||
28 | int main(int argc, char *argv[]) |
|
27 | int main(int argc, char *argv[]) | |
29 | { |
|
28 | { | |
30 | QApplication a(argc, argv); |
|
29 | QApplication a(argc, argv); | |
31 |
|
30 | |||
32 | //![1] |
|
|||
33 | QPen pen(Qt::black); |
|
|||
34 | pen.setWidth(2); |
|
|||
35 | QBrush blue(Qt::blue); |
|
|||
36 | QBrush red(Qt::red); |
|
|||
37 |
|
||||
38 | QScatterSeries *series0 = new QScatterSeries(); |
|
|||
39 | series0->setPen(pen); |
|
|||
40 | series0->setBrush(blue); |
|
|||
41 | series0->setShape(QScatterSeries::MarkerShapeCircle); |
|
|||
42 | series0->setSize(15.0); |
|
|||
43 |
|
||||
44 | QScatterSeries *series1 = new QScatterSeries(); |
|
|||
45 | series1->setPen(pen); |
|
|||
46 | series1->setBrush(red); |
|
|||
47 | series1->setShape(QScatterSeries::MarkerShapeCircle); |
|
|||
48 | series1->setSize(15.0); |
|
|||
49 | //![1] |
|
|||
50 |
|
||||
51 | //![2] |
|
|||
52 | series0->append(0, 6); |
|
|||
53 | series0->append(2, 4); |
|
|||
54 | series0->append(3, 8); |
|
|||
55 | series0->append(7, 4); |
|
|||
56 | series0->append(10, 5); |
|
|||
57 |
|
||||
58 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); |
|
|||
59 | //![2] |
|
|||
60 |
|
||||
61 | //![3] |
|
|||
62 | QChart* chart = new QChart(); |
|
|||
63 |
|
||||
64 | chart->addSeries(series0); |
|
|||
65 | chart->addSeries(series1); |
|
|||
66 | chart->setTitle("Simple scatterchart example"); |
|
|||
67 | //![3] |
|
|||
68 |
|
||||
69 | //![4] |
|
|||
70 | QChartView* chartView = new QChartView(chart); |
|
|||
71 | chartView->setRenderHint(QPainter::Antialiasing); |
|
|||
72 | //![4] |
|
31 | //![4] | |
73 |
|
32 | ChartView* chartView = new ChartView(); | ||
74 | //![5] |
|
|||
75 | QMainWindow window; |
|
33 | QMainWindow window; | |
76 | window.setCentralWidget(chartView); |
|
34 | window.setCentralWidget(chartView); | |
77 | window.resize(400, 300); |
|
35 | window.resize(400, 300); | |
78 | window.show(); |
|
36 | window.show(); | |
79 |
//![ |
|
37 | //![4] | |
80 |
|
38 | |||
81 | return a.exec(); |
|
39 | return a.exec(); | |
82 | } |
|
40 | } |
@@ -1,5 +1,9 | |||||
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 = scatterchart |
|
4 | TARGET = scatterchart | |
5 | SOURCES += main.cpp |
|
5 | SOURCES += main.cpp \ | |
|
6 | chartview.cpp | |||
|
7 | ||||
|
8 | HEADERS += \ | |||
|
9 | chartview.h |
General Comments 0
You need to be logged in to leave comments.
Login now