1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,37 | |||||
|
1 | /*! | |||
|
2 | \example example/presenterchart | |||
|
3 | \title PresenterChart Example | |||
|
4 | \subtitle | |||
|
5 | ||||
|
6 | The example shows how to create chart which presents the same set of data as line, scatter and spline charts. | |||
|
7 | ChartPresenter will switch between these three chart types every few seconds. | |||
|
8 | Please note this example does not use common data model. A use of common data model is documented here.[TODO] | |||
|
9 | ||||
|
10 | \image presenterchart1.png | |||
|
11 | \image presenterchart2.png | |||
|
12 | \image presenterchart3.png | |||
|
13 | ||||
|
14 | We create simple ChartView class which derives form QChartView. | |||
|
15 | ||||
|
16 | \snippet ../example/presenterchart/chartview.h 1 | |||
|
17 | ||||
|
18 | Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. | |||
|
19 | 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 | |||
|
20 | using QLineSeries , as scatter chart using QScatterSeries, and as a spline chart using QSplineSeries. We create needed instances in constructor of ChartView class. | |||
|
21 | We set custom line and points colors. | |||
|
22 | ||||
|
23 | \snippet ../example/presenterchart/chartview.cpp 1 | |||
|
24 | ||||
|
25 | We add data to all three series. We can use add() member function. If data set is large,it is wiser to use shared data model, as described here.[TODO] | |||
|
26 | ||||
|
27 | \snippet ../example/presenterchart/chartview.cpp 2 | |||
|
28 | ||||
|
29 | In the end we store references all the created series and matching titles. | |||
|
30 | ||||
|
31 | \snippet ../example/presenterchart/chartview.cpp 3 | |||
|
32 | ||||
|
33 | 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. | |||
|
34 | ||||
|
35 | \snippet ../example/presenterchart/chartview.cpp 4 | |||
|
36 | ||||
|
37 | */ No newline at end of file |
@@ -1,41 +1,42 | |||||
1 | # Define the location of the templates to use. Style sheets and scripts are |
|
1 | # Define the location of the templates to use. Style sheets and scripts are | |
2 | # specified relative to the template directory and will be copied into |
|
2 | # specified relative to the template directory and will be copied into | |
3 | # subdirectories of the output directory. |
|
3 | # subdirectories of the output directory. | |
4 |
|
4 | |||
5 | HTML.templatedir = . |
|
5 | HTML.templatedir = . | |
6 |
|
6 | |||
7 | HTML.stylesheets = style/offline.css |
|
7 | HTML.stylesheets = style/offline.css | |
8 |
|
8 | |||
9 | HTML.scripts = |
|
9 | HTML.scripts = | |
10 |
|
10 | |||
11 | # Files not referenced in any qdoc file, many needed by style sheets. |
|
11 | # Files not referenced in any qdoc file, many needed by style sheets. | |
12 | # These also need to be listed in qhp.Qt.extraFiles with the correct |
|
12 | # These also need to be listed in qhp.Qt.extraFiles with the correct | |
13 | # directory prefixes. |
|
13 | # directory prefixes. | |
14 |
|
14 | |||
15 | extraimages.HTML = qt_commercial_logo.png \ |
|
15 | extraimages.HTML = qt_commercial_logo.png \ | |
16 | digia_logo.png \ |
|
16 | digia_logo.png \ | |
17 | qcharts.png \ |
|
17 | qcharts.png \ | |
18 | arrow_down.png \ |
|
18 | arrow_down.png \ | |
19 | breadcrumb.png \ |
|
19 | breadcrumb.png \ | |
20 | bullet_gt.png \ |
|
20 | bullet_gt.png \ | |
21 | bullet_dn.png \ |
|
21 | bullet_dn.png \ | |
22 | bullet_sq.png \ |
|
22 | bullet_sq.png \ | |
23 | bullet_up.png \ |
|
23 | bullet_up.png \ | |
24 | horBar.png \ |
|
24 | horBar.png \ | |
|
25 | presenterchart_example.png \ | |||
25 | bg.png |
|
26 | bg.png | |
26 |
|
27 | |||
27 |
|
28 | |||
28 |
|
29 | |||
29 |
|
30 | |||
30 | # Include the style sheets and scripts used. |
|
31 | # Include the style sheets and scripts used. | |
31 |
|
32 | |||
32 | HTML.headerstyles = \ |
|
33 | HTML.headerstyles = \ | |
33 | " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n" |
|
34 | " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n" | |
34 |
|
35 | |||
35 | HTML.headerscripts = |
|
36 | HTML.headerscripts = | |
36 |
|
37 | |||
37 | HTML.endheader = \ |
|
38 | HTML.endheader = \ | |
38 | "</head>\n" \ |
|
39 | "</head>\n" \ | |
39 | "<body>\n" |
|
40 | "<body>\n" | |
40 |
|
41 | |||
41 | HTML.nobreadcrumbs = true No newline at end of file |
|
42 | HTML.nobreadcrumbs = true |
@@ -1,30 +1,31 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page examples.html |
|
2 | \page examples.html | |
3 | \title Examples |
|
3 | \title Examples | |
4 | \keyword Examples |
|
4 | \keyword Examples | |
5 |
|
5 | |||
6 | \raw HTML |
|
6 | \raw HTML | |
7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> | |
8 | <tr> |
|
8 | <tr> | |
9 | <th class="titleheader" width="33%"> |
|
9 | <th class="titleheader" width="33%"> | |
10 | List of examples |
|
10 | List of examples | |
11 | </th> |
|
11 | </th> | |
12 | </tr> |
|
12 | </tr> | |
13 | <tr> |
|
13 | <tr> | |
14 | <td valign="top"> |
|
14 | <td valign="top"> | |
15 | <ul> |
|
15 | <ul> | |
16 | <li><a href="example-areachart.html">Area Chart example</a></li> |
|
16 | <li><a href="example-areachart.html">Area Chart example</a></li> | |
17 | <li><a href="example-barchart.html">Bar Chart example</a></li> |
|
17 | <li><a href="example-barchart.html">Bar Chart example</a></li> | |
18 | <li><a href="example-stackedbarchart.html">Stacked Bar Chart example</a></li> |
|
|||
19 | <li><a href="example-percentbarchart.html">Percent Bar Chart example</a></li> |
|
|||
20 | <li><a href="example-scatterchart.html">Scatter Chart example</a></li> |
|
|||
21 | <li><a href="example-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li> |
|
|||
22 | <li><a href="example-linechart.html">Line Chart example</a></li> |
|
18 | <li><a href="example-linechart.html">Line Chart example</a></li> | |
|
19 | <li><a href="example-percentbarchart.html">Percent Bar Chart example</a></li> | |||
23 | <li><a href="example-piechart.html">Pie Chart example</a></li> |
|
20 | <li><a href="example-piechart.html">Pie Chart example</a></li> | |
|
21 | <li><a href="example-presenterchart.html">Presenter Chart example</a></li> | |||
|
22 | <li><a href="example-scatterchart.html">Scatter Chart example</a></li> | |||
24 | <li><a href="example-splinechart.html">Spline Chart example</a></li> |
|
23 | <li><a href="example-splinechart.html">Spline Chart example</a></li> | |
|
24 | <li><a href="example-stackedbarchart.html">Stacked Bar Chart example</a></li> | |||
|
25 | <li><a href="example-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li> | |||
25 | </ul> |
|
26 | </ul> | |
26 | </td> |
|
27 | </td> | |
27 | </tr> |
|
28 | </tr> | |
28 | </table> |
|
29 | </table> | |
29 | \endraw |
|
30 | \endraw | |
30 | */ |
|
31 | */ |
@@ -1,44 +1,45 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page index.html |
|
2 | \page index.html | |
3 | \keyword About |
|
3 | \keyword About | |
4 |
|
4 | |||
5 | \raw HTML |
|
5 | \raw HTML | |
6 | <div class="qchart"> |
|
6 | <div class="qchart"> | |
7 | <img src="images/qt_commercial_logo.png" alt="qtcommercial"/> |
|
7 | <img src="images/qt_commercial_logo.png" alt="qtcommercial"/> | |
8 |
|
8 | |||
9 | <p> |
|
9 | <p> | |
10 | QCharts is a part of Qt Commercial addons package. It provides a set of easy to use chart |
|
10 | QCharts is a part of Qt Commercial addons package. It provides a set of easy to use chart | |
11 | components which are available for Qt Commercial customers. It uses Qt Graphics View |
|
11 | components which are available for Qt Commercial customers. It uses Qt Graphics View | |
12 | Framework, therefore charts can be easily integrated to modern 2D user interfaces. QCharts can |
|
12 | Framework, therefore charts can be easily integrated to modern 2D user interfaces. QCharts can | |
13 | be used as QWidgets, QGraphicsWidget or QML elements. Users can easily create impressive |
|
13 | be used as QWidgets, QGraphicsWidget or QML elements. Users can easily create impressive | |
14 | graphs by selecting one of the charts themes. |
|
14 | graphs by selecting one of the charts themes. | |
15 | </p> |
|
15 | </p> | |
16 |
|
16 | |||
17 | <table><tr> |
|
17 | <table><tr> | |
18 | <td><a href="example-linechart.html"><img src="images/linechart.png" alt="linechart" /></a></td> |
|
18 | <td><a href="example-linechart.html"><img src="images/linechart.png" alt="linechart" /></a></td> | |
19 | <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td> |
|
19 | <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td> | |
20 | </tr> |
|
20 | </tr> | |
21 | <tr> |
|
21 | <tr> | |
22 | <td><a href="example-scatterchart.html"><img src="images/scatterchart.png" alt="scatterchart" /></a></td> |
|
22 | <td><a href="example-scatterchart.html"><img src="images/scatterchart.png" alt="scatterchart" /></a></td> | |
23 | <td><a href="example-barchart.html"><img src="images/barchart.png" alt="barchart" /></a></td> |
|
23 | <td><a href="example-barchart.html"><img src="images/barchart.png" alt="barchart" /></a></td> | |
24 | </tr> |
|
24 | </tr> | |
25 | <tr> |
|
25 | <tr> | |
26 | <td><a href="example-stackedbarchart.html"><img src="images/stackedbarchart.png" alt="stackedbarchart" /></a></td> |
|
26 | <td><a href="example-stackedbarchart.html"><img src="images/stackedbarchart.png" alt="stackedbarchart" /></a></td> | |
27 | <td><a href="example-percentbarchart.html"><img src="images/percentbarchart.png" alt="percentbarcchart" /></a></td> |
|
27 | <td><a href="example-percentbarchart.html"><img src="images/percentbarchart.png" alt="percentbarcchart" /></a></td> | |
28 | </tr><tr> |
|
28 | </tr><tr> | |
29 | <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td> |
|
29 | <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td> | |
30 | <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td> |
|
30 | <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td> | |
31 | </tr> |
|
31 | </tr> | |
32 | <tr> |
|
32 | <tr> | |
33 | <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td> |
|
33 | <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td> | |
34 | <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td> |
|
34 | <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td> | |
35 | </tr> |
|
35 | </tr> | |
36 | <tr> |
|
36 | <tr> | |
37 |
|
|
37 | <td><img src="images/chartview_example.jpg " alt="linechart" /></td> | |
|
38 | <td><a href="example-presenterchart.html"><img src="images/presenterchart_example.png" alt="presenterchart" /></a></td> | |||
38 | </tr> |
|
39 | </tr> | |
39 | </table> |
|
40 | </table> | |
40 | </div> |
|
41 | </div> | |
41 | \endraw |
|
42 | \endraw | |
42 |
|
43 | |||
43 |
|
44 | |||
44 | */ |
|
45 | */ |
@@ -1,70 +1,77 | |||||
1 | #include "chartview.h" |
|
1 | #include "chartview.h" | |
2 | #include <qlineseries.h> |
|
2 | #include <qlineseries.h> | |
3 | #include <qscatterseries.h> |
|
3 | #include <qscatterseries.h> | |
4 | #include <qsplineseries.h> |
|
4 | #include <qsplineseries.h> | |
5 | #include <QTime> |
|
5 | #include <QTime> | |
6 |
|
6 | |||
7 | ChartView::ChartView(QWidget* parent):QChartView(parent), |
|
7 | ChartView::ChartView(QWidget* parent):QChartView(parent), | |
8 | m_index(0) |
|
8 | m_index(0) | |
9 | { |
|
9 | { | |
|
10 | QTime now = QTime::currentTime(); | |||
|
11 | qsrand((uint)now.msec()); | |||
10 | setChartTitle("Three random line charts"); |
|
12 | setChartTitle("Three random line charts"); | |
11 |
|
13 | |||
12 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); |
|
14 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); | |
13 | m_timer.setInterval(3000); |
|
15 | m_timer.setInterval(3000); | |
14 |
|
16 | |||
15 | QTime now = QTime::currentTime(); |
|
17 | //![1] | |
16 | qsrand((uint)now.msec()); |
|
|||
17 |
|
||||
18 | QLineSeries* series0 = new QLineSeries(this); |
|
18 | QLineSeries* series0 = new QLineSeries(this); | |
19 | QPen blue(Qt::blue); |
|
19 | QPen blue(Qt::blue); | |
20 | blue.setWidth(3); |
|
20 | blue.setWidth(3); | |
21 | series0->setPen(blue); |
|
21 | series0->setPen(blue); | |
|
22 | ||||
22 | QScatterSeries* series1 = new QScatterSeries(this); |
|
23 | QScatterSeries* series1 = new QScatterSeries(this); | |
23 | QPen red(Qt::red); |
|
24 | QPen red(Qt::red); | |
24 | red.setWidth(3); |
|
25 | red.setWidth(3); | |
25 | series1->setPen(red); |
|
26 | series1->setPen(red); | |
26 | series1->setBrush(Qt::white); |
|
27 | series1->setBrush(Qt::white); | |
|
28 | ||||
27 | QSplineSeries* series2 = new QSplineSeries(this); |
|
29 | QSplineSeries* series2 = new QSplineSeries(this); | |
28 | QPen green(Qt::green); |
|
30 | QPen green(Qt::green); | |
29 | green.setWidth(3); |
|
31 | green.setWidth(3); | |
30 | series2->setPen(green); |
|
32 | series2->setPen(green); | |
|
33 | //![1] | |||
31 |
|
34 | |||
|
35 | //![2] | |||
32 | int numPoints = 10; |
|
36 | int numPoints = 10; | |
33 |
|
37 | |||
34 | for (int x = 0; x <= numPoints; ++x) { |
|
38 | for (int x = 0; x <= numPoints; ++x) { | |
35 | qreal y = qrand() % 100; |
|
39 | qreal y = qrand() % 100; | |
36 | series0->add(x,y); |
|
40 | series0->add(x,y); | |
37 | series1->add(x,y); |
|
41 | series1->add(x,y); | |
38 | series2->add(x,y); |
|
42 | series2->add(x,y); | |
39 | } |
|
43 | } | |
|
44 | //![2] | |||
40 |
|
45 | |||
|
46 | //![3] | |||
41 | m_series<<series0; |
|
47 | m_series<<series0; | |
42 | m_titles<<chartTitle()+": LineChart"; |
|
48 | m_titles<<chartTitle()+": LineChart"; | |
43 | m_series<<series1; |
|
49 | m_series<<series1; | |
44 | m_titles<<chartTitle()+": ScatterChart"; |
|
50 | m_titles<<chartTitle()+": ScatterChart"; | |
45 | m_series<<series2; |
|
51 | m_series<<series2; | |
46 | m_titles<<chartTitle()+": SplineChart"; |
|
52 | m_titles<<chartTitle()+": SplineChart"; | |
47 |
|
53 | //![3] | ||
48 | addSeries(series0); |
|
54 | addSeries(series0); | |
49 | setChartTitle(m_titles.at(0)); |
|
55 | setChartTitle(m_titles.at(0)); | |
50 |
|
56 | |||
51 | m_timer.start(); |
|
57 | m_timer.start(); | |
52 | } |
|
58 | } | |
53 |
|
59 | |||
54 | ChartView::~ChartView() |
|
60 | ChartView::~ChartView() | |
55 | { |
|
61 | { | |
56 | if(m_series.size()==0) return; |
|
62 | if(m_series.size()==0) return; | |
57 | removeSeries(m_series.at(m_index)); |
|
63 | removeSeries(m_series.at(m_index)); | |
58 | qDeleteAll(m_series); |
|
64 | qDeleteAll(m_series); | |
59 | } |
|
65 | } | |
60 |
|
66 | |||
|
67 | //![4] | |||
61 | void ChartView::handleTimeout() |
|
68 | void ChartView::handleTimeout() | |
62 | { |
|
69 | { | |
63 | if(m_series.size()==0) return; |
|
70 | if(m_series.size()==0) return; | |
64 |
|
||||
65 | removeSeries(m_series.at(m_index)); |
|
71 | removeSeries(m_series.at(m_index)); | |
66 | m_index++; |
|
72 | m_index++; | |
67 | m_index=m_index%m_series.size(); |
|
73 | m_index=m_index%m_series.size(); | |
68 | addSeries(m_series.at(m_index)); |
|
74 | addSeries(m_series.at(m_index)); | |
69 | setChartTitle(m_titles.at(m_index)); |
|
75 | setChartTitle(m_titles.at(m_index)); | |
70 | } |
|
76 | } | |
|
77 | //![4] |
@@ -1,26 +1,28 | |||||
1 | #ifndef CHARTVIEW_H_ |
|
1 | #ifndef CHARTVIEW_H_ | |
2 | #define CHARTVIEW_H_ |
|
2 | #define CHARTVIEW_H_ | |
3 |
|
3 | |||
4 | #include <qchartview.h> |
|
4 | #include <qchartview.h> | |
5 | #include <QTimer> |
|
5 | #include <QTimer> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
7 | QTCOMMERCIALCHART_USE_NAMESPACE | |
8 |
|
8 | |||
|
9 | //![1] | |||
9 | class ChartView: public QChartView |
|
10 | class ChartView: public QChartView | |
10 | { |
|
11 | { | |
11 | Q_OBJECT |
|
12 | Q_OBJECT | |
12 | public: |
|
13 | public: | |
13 | ChartView(QWidget* parent=0); |
|
14 | ChartView(QWidget* parent=0); | |
14 | virtual ~ChartView(); |
|
15 | virtual ~ChartView(); | |
15 |
|
16 | |||
16 | public slots: |
|
17 | public slots: | |
17 | void handleTimeout(); |
|
18 | void handleTimeout(); | |
18 |
|
19 | |||
19 | private: |
|
20 | private: | |
20 | QTimer m_timer; |
|
21 | QTimer m_timer; | |
21 | QList<QSeries*> m_series; |
|
22 | QList<QSeries*> m_series; | |
22 | QStringList m_titles; |
|
23 | QStringList m_titles; | |
23 | int m_index; |
|
24 | int m_index; | |
24 | }; |
|
25 | }; | |
|
26 | //![1] | |||
25 |
|
27 | |||
26 | #endif /* CHARTVIEW_H_ */ |
|
28 | #endif /* CHARTVIEW_H_ */ |
@@ -1,6 +1,6 | |||||
1 | !include( ../example.pri ) { |
|
1 | !include( ../example.pri ) { | |
2 | error( "Couldn't find the example.pri file!" ) |
|
2 | error( "Couldn't find the example.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
TARGET = presenter |
|
4 | TARGET = presenterchart | |
5 | HEADERS += chartview.h |
|
5 | HEADERS += chartview.h | |
6 | SOURCES += main.cpp chartview.cpp No newline at end of file |
|
6 | SOURCES += main.cpp chartview.cpp |
General Comments 0
You need to be logged in to leave comments.
Login now