##// END OF EJS Templates
Add all examples to docs
Jani Honkonen -
r919:611d2fd27b7b
parent child
Show More
@@ -0,0 +1,7
1 /*!
2 \example examples/customchart
3 \title Custom chart example
4 \subtitle
5
6 This example shows how to customize the appearance of the whole chart.
7 */
@@ -0,0 +1,7
1 /*!
2 \example examples/ekgchart
3 \title EKG chart Example
4 \subtitle
5
6 The example shows how to simulate a EKG chart.
7 */
@@ -0,0 +1,7
1 /*!
2 \example examples/modeldata
3 \title Model data example
4 \subtitle
5
6 This example shows how to use QAbstractItemModel derived model as the data for the series.
7 */
@@ -0,0 +1,7
1 /*!
2 \example examples/scatterinteractions
3 \title ScatterChart Example
4 \subtitle
5
6 The example shows how to create simple scatter chart and how to interact with the chart.
7 */
@@ -0,0 +1,7
1 /*!
2 \example examples/stackedbarchartdrilldown
3 \title Stacked bar chart drilldown example
4 \subtitle
5
6 The example shows how to create stacked bar chart with a drilldown effect.
7 */
@@ -0,0 +1,7
1 /*!
2 \example examples/zoomlinechart
3 \title Zoom line example
4 \subtitle
5
6 The example shows how to create your own custom zooming effect with QRubberBand.
7 */
1 NO CONTENT: file renamed from doc/src/example-splinechart.qdoc to doc/src/examples-splinechart.qdoc
NO CONTENT: file renamed from doc/src/example-splinechart.qdoc to doc/src/examples-splinechart.qdoc
@@ -1,33 +1,37
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="examples-areachart.html">Area chart example</a></li>
16 <li><a href="examples-areachart.html">Area chart example</a></li>
17 <li><a href="examples-barchart.html">Bar chart example</a></li>
17 <li><a href="examples-barchart.html">Bar chart example</a></li>
18 <li><a href="examples-linechart.html">Line chart example</a></li>
18 <li><a href="examples-customchart.html">Custom chart example</a></li>
19 <li><a href="examples-ekgchart.html">EKG chart example</a></li>
20 <li><a href="examples-linechart.html">Bar chart example</a></li>
21 <li><a href="examples-modeldata.html">Model data example</a></li>
19 <li><a href="examples-percentbarchart.html">Percent bar chart example</a></li>
22 <li><a href="examples-percentbarchart.html">Percent bar chart example</a></li>
20 <li><a href="examples-piechart.html">Pie chart example</a></li>
23 <li><a href="examples-piechart.html">Pie chart example</a></li>
21 <li><a href="examples-piechartdrilldown.html">Pie chart drilldown example</a></li>
24 <li><a href="examples-piechartdrilldown.html">Pie chart drilldown example</a></li>
22 <li><a href="examples-presenterchart.html">Presenter chart example</a></li>
25 <li><a href="examples-presenterchart.html">Presenter chart example</a></li>
23 <li><a href="examples-scatterchart.html">Scatter chart example</a></li>
26 <li><a href="examples-scatterchart.html">Scatter chart example</a></li>
27 <li><a href="examples-scatterinteractions.html">Scatter interactions example</a></li>
24 <li><a href="examples-splinechart.html">Spline chart example</a></li>
28 <li><a href="examples-splinechart.html">Spline chart example</a></li>
25 <li><a href="examples-stackedbarchart.html">Stacked bar chart example</a></li>
29 <li><a href="examples-stackedbarchart.html">Stacked bar chart example</a></li>
26 <li><a href="examples-stackedbarchartdrilldown.html">Stacked bar chart drilldown example</a></li>
30 <li><a href="examples-stackedbarchartdrilldown.html">Stacked bar chart drilldown example</a></li>
27 <li><a href="examples-customcolors.html">Customizing colors example</a></li>
31 <li><a href="examples-zoomlinechart.html">Zoom line example</a></li>
28 </ul>
32 </ul>
29 </td>
33 </td>
30 </tr>
34 </tr>
31 </table>
35 </table>
32 \endraw
36 \endraw
33 */
37 */
@@ -1,113 +1,117
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 <QChartView>
23 #include <QChartView>
24 #include <QBarSet>
24 #include <QBarSet>
25 #include <QLegend>
25 #include <QLegend>
26 #include "drilldownseries.h"
26 #include "drilldownseries.h"
27 #include "drilldownchart.h"
27 #include "drilldownchart.h"
28
28
29 QTCOMMERCIALCHART_USE_NAMESPACE
29 QTCOMMERCIALCHART_USE_NAMESPACE
30
30
31 int main(int argc, char *argv[])
31 int main(int argc, char *argv[])
32 {
32 {
33 //! [1]
33 QApplication a(argc, argv);
34 QApplication a(argc, argv);
34 QMainWindow window;
35 QMainWindow window;
36 //! [1]
35
37
38 //! [2]
36 DrilldownChart* drilldownChart = new DrilldownChart();
39 DrilldownChart* drilldownChart = new DrilldownChart();
37 drilldownChart->setTheme(QChart::ChartThemeBlueIcy);
40 drilldownChart->setTheme(QChart::ChartThemeBlueIcy);
38 drilldownChart->setAnimationOptions(QChart::SeriesAnimations);
41 drilldownChart->setAnimationOptions(QChart::SeriesAnimations);
42 //! [2]
39
43
40 //! [3]
44 //! [3]
41 // Define categories
45 // Define categories
42 QStringList months;
46 QStringList months;
43 months << "May" << "Jun" << "Jul" << "Aug" << "Sep";
47 months << "May" << "Jun" << "Jul" << "Aug" << "Sep";
44 QStringList weeks;
48 QStringList weeks;
45 weeks << "week 1" << "week 2" << "week 3" << "week 4";
49 weeks << "week 1" << "week 2" << "week 3" << "week 4";
46 QStringList plants;
50 QStringList plants;
47 plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo";
51 plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo";
48 //! [3]
52 //! [3]
49
53
50 //! [4]
54 //! [4]
51 // Create drilldown structure
55 // Create drilldown structure
52 DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart);
56 DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart);
53 seasonSeries->setName("Crop by month - Season");
57 seasonSeries->setName("Crop by month - Season");
54
58
55 // Each month in season series has drilldown series for weekly data
59 // Each month in season series has drilldown series for weekly data
56 foreach (QString month, months) {
60 foreach (QString month, months) {
57
61
58 // Create drilldown series for every week
62 // Create drilldown series for every week
59 DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart);
63 DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart);
60 seasonSeries->mapDrilldownSeries(month, weeklySeries);
64 seasonSeries->mapDrilldownSeries(month, weeklySeries);
61
65
62 // Drilling down from weekly data brings us back to season data.
66 // Drilling down from weekly data brings us back to season data.
63 foreach (QString week, weeks) {
67 foreach (QString week, weeks) {
64 weeklySeries->mapDrilldownSeries(week, seasonSeries);
68 weeklySeries->mapDrilldownSeries(week, seasonSeries);
65 weeklySeries->setName(QString("Crop by week - " + month));
69 weeklySeries->setName(QString("Crop by week - " + month));
66 }
70 }
67
71
68 // Use right click signal to implement drilldown
72 // Use right click signal to implement drilldown
69 QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
73 QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
70 }
74 }
71
75
72 // Enable drilldown from season series using right click.
76 // Enable drilldown from season series using right click.
73 QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
77 QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
74 //! [4]
78 //! [4]
75
79
76 //! [5]
80 //! [5]
77 // Fill monthly and weekly series with data
81 // Fill monthly and weekly series with data
78 foreach (QString plant, plants) {
82 foreach (QString plant, plants) {
79 QBarSet* monthlyCrop = new QBarSet(plant);
83 QBarSet* monthlyCrop = new QBarSet(plant);
80 foreach (QString month, months) {
84 foreach (QString month, months) {
81 QBarSet* weeklyCrop = new QBarSet(plant);
85 QBarSet* weeklyCrop = new QBarSet(plant);
82 foreach (QString week, weeks )
86 foreach (QString week, weeks )
83 *weeklyCrop << (qrand() % 20);
87 *weeklyCrop << (qrand() % 20);
84 // Get the drilldown series from season series and add crop to it.
88 // Get the drilldown series from season series and add crop to it.
85 seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop);
89 seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop);
86 seasonSeries->drilldownSeries(month)->setToolTipEnabled(true);
90 seasonSeries->drilldownSeries(month)->setToolTipEnabled(true);
87 *monthlyCrop << weeklyCrop->total();
91 *monthlyCrop << weeklyCrop->total();
88 }
92 }
89 seasonSeries->appendBarSet(monthlyCrop);
93 seasonSeries->appendBarSet(monthlyCrop);
90 }
94 }
91 //! [5]
95 //! [5]
92
96
93 //! [6]
97 //! [6]
94 // Show season series in initial view
98 // Show season series in initial view
95 drilldownChart->changeSeries(seasonSeries);
99 drilldownChart->changeSeries(seasonSeries);
96 drilldownChart->setTitle(seasonSeries->name());
100 drilldownChart->setTitle(seasonSeries->name());
97 //! [6]
101 //! [6]
98
102
99 //! [7]
103 //! [7]
100 drilldownChart->axisX()->setGridLineVisible(false);
104 drilldownChart->axisX()->setGridLineVisible(false);
101 drilldownChart->axisY()->setNiceNumbers(true);
105 drilldownChart->axisY()->setNiceNumbers(true);
102 drilldownChart->legend()->setVisible(true);
106 drilldownChart->legend()->setVisible(true);
103 drilldownChart->legend()->setAlignment(QLegend::AlignmentBottom);
107 drilldownChart->legend()->setAlignment(QLegend::AlignmentBottom);
104 //! [7]
108 //! [7]
105
109
106 QChartView *chartView = new QChartView(drilldownChart);
110 QChartView *chartView = new QChartView(drilldownChart);
107 window.setCentralWidget(chartView);
111 window.setCentralWidget(chartView);
108 window.resize(400, 300);
112 window.resize(400, 300);
109 window.show();
113 window.show();
110
114
111 return a.exec();
115 return a.exec();
112 }
116 }
113
117
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now