|
1 | NO CONTENT: new file 100644, binary diff hidden |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
|
1 | 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 | 1 | # Define the location of the templates to use. Style sheets and scripts are |
|
2 | 2 | # specified relative to the template directory and will be copied into |
|
3 | 3 | # subdirectories of the output directory. |
|
4 | 4 | |
|
5 | 5 | HTML.templatedir = . |
|
6 | 6 | |
|
7 | 7 | HTML.stylesheets = style/offline.css |
|
8 | 8 | |
|
9 | 9 | HTML.scripts = |
|
10 | 10 | |
|
11 | 11 | # Files not referenced in any qdoc file, many needed by style sheets. |
|
12 | 12 | # These also need to be listed in qhp.Qt.extraFiles with the correct |
|
13 | 13 | # directory prefixes. |
|
14 | 14 | |
|
15 | 15 | extraimages.HTML = qt_commercial_logo.png \ |
|
16 | 16 | digia_logo.png \ |
|
17 | 17 | qcharts.png \ |
|
18 | 18 | arrow_down.png \ |
|
19 | 19 | breadcrumb.png \ |
|
20 | 20 | bullet_gt.png \ |
|
21 | 21 | bullet_dn.png \ |
|
22 | 22 | bullet_sq.png \ |
|
23 | 23 | bullet_up.png \ |
|
24 | 24 | horBar.png \ |
|
25 | presenterchart_example.png \ | |
|
25 | 26 | bg.png |
|
26 | 27 | |
|
27 | 28 | |
|
28 | 29 | |
|
29 | 30 | |
|
30 | 31 | # Include the style sheets and scripts used. |
|
31 | 32 | |
|
32 | 33 | HTML.headerstyles = \ |
|
33 | 34 | " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n" |
|
34 | 35 | |
|
35 | 36 | HTML.headerscripts = |
|
36 | 37 | |
|
37 | 38 | HTML.endheader = \ |
|
38 | 39 | "</head>\n" \ |
|
39 | 40 | "<body>\n" |
|
40 | 41 | |
|
41 | 42 | HTML.nobreadcrumbs = true No newline at end of file |
@@ -1,30 +1,31 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page examples.html |
|
3 | 3 | \title Examples |
|
4 | 4 | \keyword Examples |
|
5 | 5 | |
|
6 | 6 | \raw HTML |
|
7 | 7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
8 | 8 | <tr> |
|
9 | 9 | <th class="titleheader" width="33%"> |
|
10 | 10 | List of examples |
|
11 | 11 | </th> |
|
12 | 12 | </tr> |
|
13 | 13 | <tr> |
|
14 | 14 | <td valign="top"> |
|
15 | 15 | <ul> |
|
16 | 16 | <li><a href="example-areachart.html">Area Chart example</a></li> |
|
17 | 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 | 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 | 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 | 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 | 26 | </ul> |
|
26 | 27 | </td> |
|
27 | 28 | </tr> |
|
28 | 29 | </table> |
|
29 | 30 | \endraw |
|
30 | 31 | */ |
@@ -1,44 +1,45 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page index.html |
|
3 | 3 | \keyword About |
|
4 | 4 | |
|
5 | 5 | \raw HTML |
|
6 | 6 | <div class="qchart"> |
|
7 | 7 | <img src="images/qt_commercial_logo.png" alt="qtcommercial"/> |
|
8 | 8 | |
|
9 | 9 | <p> |
|
10 | 10 | QCharts is a part of Qt Commercial addons package. It provides a set of easy to use chart |
|
11 | 11 | components which are available for Qt Commercial customers. It uses Qt Graphics View |
|
12 | 12 | Framework, therefore charts can be easily integrated to modern 2D user interfaces. QCharts can |
|
13 | 13 | be used as QWidgets, QGraphicsWidget or QML elements. Users can easily create impressive |
|
14 | 14 | graphs by selecting one of the charts themes. |
|
15 | 15 | </p> |
|
16 | 16 | |
|
17 | 17 | <table><tr> |
|
18 | 18 | <td><a href="example-linechart.html"><img src="images/linechart.png" alt="linechart" /></a></td> |
|
19 | 19 | <td><a href="example-areachart.html"><img src="images/areachart.png" alt="areachart" /></a></td> |
|
20 | 20 | </tr> |
|
21 | 21 | <tr> |
|
22 | 22 | <td><a href="example-scatterchart.html"><img src="images/scatterchart.png" alt="scatterchart" /></a></td> |
|
23 | 23 | <td><a href="example-barchart.html"><img src="images/barchart.png" alt="barchart" /></a></td> |
|
24 | 24 | </tr> |
|
25 | 25 | <tr> |
|
26 | 26 | <td><a href="example-stackedbarchart.html"><img src="images/stackedbarchart.png" alt="stackedbarchart" /></a></td> |
|
27 | 27 | <td><a href="example-percentbarchart.html"><img src="images/percentbarchart.png" alt="percentbarcchart" /></a></td> |
|
28 | 28 | </tr><tr> |
|
29 | 29 | <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td> |
|
30 | 30 | <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td> |
|
31 | 31 | </tr> |
|
32 | 32 | <tr> |
|
33 | 33 | <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td> |
|
34 | 34 | <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td> |
|
35 | 35 | </tr> |
|
36 | 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 | 39 | </tr> |
|
39 | 40 | </table> |
|
40 | 41 | </div> |
|
41 | 42 | \endraw |
|
42 | 43 | |
|
43 | 44 | |
|
44 | 45 | */ |
@@ -1,70 +1,77 | |||
|
1 | 1 | #include "chartview.h" |
|
2 | 2 | #include <qlineseries.h> |
|
3 | 3 | #include <qscatterseries.h> |
|
4 | 4 | #include <qsplineseries.h> |
|
5 | 5 | #include <QTime> |
|
6 | 6 | |
|
7 | 7 | ChartView::ChartView(QWidget* parent):QChartView(parent), |
|
8 | 8 | m_index(0) |
|
9 | 9 | { |
|
10 | QTime now = QTime::currentTime(); | |
|
11 | qsrand((uint)now.msec()); | |
|
10 | 12 | setChartTitle("Three random line charts"); |
|
11 | 13 | |
|
12 | 14 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); |
|
13 | 15 | m_timer.setInterval(3000); |
|
14 | 16 | |
|
15 | QTime now = QTime::currentTime(); | |
|
16 | qsrand((uint)now.msec()); | |
|
17 | ||
|
17 | //![1] | |
|
18 | 18 | QLineSeries* series0 = new QLineSeries(this); |
|
19 | 19 | QPen blue(Qt::blue); |
|
20 | 20 | blue.setWidth(3); |
|
21 | 21 | series0->setPen(blue); |
|
22 | ||
|
22 | 23 | QScatterSeries* series1 = new QScatterSeries(this); |
|
23 | 24 | QPen red(Qt::red); |
|
24 | 25 | red.setWidth(3); |
|
25 | 26 | series1->setPen(red); |
|
26 | 27 | series1->setBrush(Qt::white); |
|
28 | ||
|
27 | 29 | QSplineSeries* series2 = new QSplineSeries(this); |
|
28 | 30 | QPen green(Qt::green); |
|
29 | 31 | green.setWidth(3); |
|
30 | 32 | series2->setPen(green); |
|
33 | //![1] | |
|
31 | 34 | |
|
35 | //![2] | |
|
32 | 36 | int numPoints = 10; |
|
33 | 37 | |
|
34 | 38 | for (int x = 0; x <= numPoints; ++x) { |
|
35 | 39 | qreal y = qrand() % 100; |
|
36 | 40 | series0->add(x,y); |
|
37 | 41 | series1->add(x,y); |
|
38 | 42 | series2->add(x,y); |
|
39 | 43 | } |
|
44 | //![2] | |
|
40 | 45 | |
|
46 | //![3] | |
|
41 | 47 | m_series<<series0; |
|
42 | 48 | m_titles<<chartTitle()+": LineChart"; |
|
43 | 49 | m_series<<series1; |
|
44 | 50 | m_titles<<chartTitle()+": ScatterChart"; |
|
45 | 51 | m_series<<series2; |
|
46 | 52 | m_titles<<chartTitle()+": SplineChart"; |
|
47 | ||
|
53 | //![3] | |
|
48 | 54 | addSeries(series0); |
|
49 | 55 | setChartTitle(m_titles.at(0)); |
|
50 | 56 | |
|
51 | 57 | m_timer.start(); |
|
52 | 58 | } |
|
53 | 59 | |
|
54 | 60 | ChartView::~ChartView() |
|
55 | 61 | { |
|
56 | 62 | if(m_series.size()==0) return; |
|
57 | 63 | removeSeries(m_series.at(m_index)); |
|
58 | 64 | qDeleteAll(m_series); |
|
59 | 65 | } |
|
60 | 66 | |
|
67 | //![4] | |
|
61 | 68 | void ChartView::handleTimeout() |
|
62 | 69 | { |
|
63 | 70 | if(m_series.size()==0) return; |
|
64 | ||
|
65 | 71 | removeSeries(m_series.at(m_index)); |
|
66 | 72 | m_index++; |
|
67 | 73 | m_index=m_index%m_series.size(); |
|
68 | 74 | addSeries(m_series.at(m_index)); |
|
69 | 75 | setChartTitle(m_titles.at(m_index)); |
|
70 | 76 | } |
|
77 | //![4] |
@@ -1,26 +1,28 | |||
|
1 | 1 | #ifndef CHARTVIEW_H_ |
|
2 | 2 | #define CHARTVIEW_H_ |
|
3 | 3 | |
|
4 | 4 | #include <qchartview.h> |
|
5 | 5 | #include <QTimer> |
|
6 | 6 | |
|
7 | 7 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | 8 | |
|
9 | //![1] | |
|
9 | 10 | class ChartView: public QChartView |
|
10 | 11 | { |
|
11 | 12 | Q_OBJECT |
|
12 | 13 | public: |
|
13 | 14 | ChartView(QWidget* parent=0); |
|
14 | 15 | virtual ~ChartView(); |
|
15 | 16 | |
|
16 | 17 | public slots: |
|
17 | 18 | void handleTimeout(); |
|
18 | 19 | |
|
19 | 20 | private: |
|
20 | 21 | QTimer m_timer; |
|
21 | 22 | QList<QSeries*> m_series; |
|
22 | 23 | QStringList m_titles; |
|
23 | 24 | int m_index; |
|
24 | 25 | }; |
|
26 | //![1] | |
|
25 | 27 | |
|
26 | 28 | #endif /* CHARTVIEW_H_ */ |
General Comments 0
You need to be logged in to leave comments.
Login now