##// 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
@@ -1,33 +1,37
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="examples-areachart.html">Area chart example</a></li>
17 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 22 <li><a href="examples-percentbarchart.html">Percent bar chart example</a></li>
20 23 <li><a href="examples-piechart.html">Pie chart example</a></li>
21 24 <li><a href="examples-piechartdrilldown.html">Pie chart drilldown example</a></li>
22 25 <li><a href="examples-presenterchart.html">Presenter chart example</a></li>
23 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 28 <li><a href="examples-splinechart.html">Spline chart example</a></li>
25 29 <li><a href="examples-stackedbarchart.html">Stacked bar chart example</a></li>
26 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 32 </ul>
29 33 </td>
30 34 </tr>
31 35 </table>
32 36 \endraw
33 37 */
@@ -1,113 +1,117
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QtGui/QApplication>
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QBarSet>
25 25 #include <QLegend>
26 26 #include "drilldownseries.h"
27 27 #include "drilldownchart.h"
28 28
29 29 QTCOMMERCIALCHART_USE_NAMESPACE
30 30
31 31 int main(int argc, char *argv[])
32 32 {
33 //! [1]
33 34 QApplication a(argc, argv);
34 35 QMainWindow window;
36 //! [1]
35 37
38 //! [2]
36 39 DrilldownChart* drilldownChart = new DrilldownChart();
37 40 drilldownChart->setTheme(QChart::ChartThemeBlueIcy);
38 41 drilldownChart->setAnimationOptions(QChart::SeriesAnimations);
42 //! [2]
39 43
40 44 //! [3]
41 45 // Define categories
42 46 QStringList months;
43 47 months << "May" << "Jun" << "Jul" << "Aug" << "Sep";
44 48 QStringList weeks;
45 49 weeks << "week 1" << "week 2" << "week 3" << "week 4";
46 50 QStringList plants;
47 51 plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo";
48 52 //! [3]
49 53
50 54 //! [4]
51 55 // Create drilldown structure
52 56 DrilldownBarSeries* seasonSeries = new DrilldownBarSeries(months, drilldownChart);
53 57 seasonSeries->setName("Crop by month - Season");
54 58
55 59 // Each month in season series has drilldown series for weekly data
56 60 foreach (QString month, months) {
57 61
58 62 // Create drilldown series for every week
59 63 DrilldownBarSeries* weeklySeries = new DrilldownBarSeries(weeks, drilldownChart);
60 64 seasonSeries->mapDrilldownSeries(month, weeklySeries);
61 65
62 66 // Drilling down from weekly data brings us back to season data.
63 67 foreach (QString week, weeks) {
64 68 weeklySeries->mapDrilldownSeries(week, seasonSeries);
65 69 weeklySeries->setName(QString("Crop by week - " + month));
66 70 }
67 71
68 72 // Use right click signal to implement drilldown
69 73 QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
70 74 }
71 75
72 76 // Enable drilldown from season series using right click.
73 77 QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons)));
74 78 //! [4]
75 79
76 80 //! [5]
77 81 // Fill monthly and weekly series with data
78 82 foreach (QString plant, plants) {
79 83 QBarSet* monthlyCrop = new QBarSet(plant);
80 84 foreach (QString month, months) {
81 85 QBarSet* weeklyCrop = new QBarSet(plant);
82 86 foreach (QString week, weeks )
83 87 *weeklyCrop << (qrand() % 20);
84 88 // Get the drilldown series from season series and add crop to it.
85 89 seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop);
86 90 seasonSeries->drilldownSeries(month)->setToolTipEnabled(true);
87 91 *monthlyCrop << weeklyCrop->total();
88 92 }
89 93 seasonSeries->appendBarSet(monthlyCrop);
90 94 }
91 95 //! [5]
92 96
93 97 //! [6]
94 98 // Show season series in initial view
95 99 drilldownChart->changeSeries(seasonSeries);
96 100 drilldownChart->setTitle(seasonSeries->name());
97 101 //! [6]
98 102
99 103 //! [7]
100 104 drilldownChart->axisX()->setGridLineVisible(false);
101 105 drilldownChart->axisY()->setNiceNumbers(true);
102 106 drilldownChart->legend()->setVisible(true);
103 107 drilldownChart->legend()->setAlignment(QLegend::AlignmentBottom);
104 108 //! [7]
105 109
106 110 QChartView *chartView = new QChartView(drilldownChart);
107 111 window.setCentralWidget(chartView);
108 112 window.resize(400, 300);
109 113 window.show();
110 114
111 115 return a.exec();
112 116 }
113 117
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now