##// END OF EJS Templates
Fixing example documentation
Tero Ahola -
r500:4d73e3f9e3b6
parent child
Show More
@@ -1,42 +1,42
1 1 /*!
2 \example example/splinechart
2 \example examples/splinechart
3 3 \title SplineChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple spline chart.
7 7
8 8 \image splinechart_example
9 9
10 10 To create spline chart we need to put our data into QSplineSeries. QSplineSeries automatically calculates spline segment control points that are needed to properly draw the spline.
11 11
12 12 \snippet ../examples/splinechart/splinewidget.cpp 1
13 13
14 14 Customize the look of the spline, by setting its pen's color and pen's width
15 15
16 16 \snippet ../examples/splinechart/splinewidget.cpp 2
17 17
18 18 Now lets add some data points to the series.
19 19
20 20 \snippet ../examples/splinechart/splinewidget.cpp add points to series
21 21
22 22 The data series has been populated. To display it on a chart we create QChartView object and add the data series to it. We also set the ranges on both axises, so that our chart is fully visible and there is some excess of space for adding more data points.
23 23
24 24 \snippet ../examples/splinechart/splinewidget.cpp 3
25 25
26 26 Then we add two buttons for adding and removing data points. Buttons clicked() signals are connected to handler functions.
27 27
28 28 \snippet ../examples/splinechart/splinewidget.cpp 4
29 29
30 30 In the end we add the chart and the buttons to the widget's layout.
31 31
32 32 \snippet ../examples/splinechart/splinewidget.cpp 5
33 33
34 34 Here is the handler function for add new data point button:
35 35
36 36 \snippet ../examples/splinechart/splinewidget.cpp add point
37 37
38 38 And here is one for remove the last data point in the series:
39 39
40 40 \snippet ../examples/splinechart/splinewidget.cpp remove point
41 41
42 42 */
@@ -1,30 +1,30
1 1 /*!
2 \example example/areachart
2 \example examples/areachart
3 3 \title AreaChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple area chart.
7 7
8 8 \image areachart.png
9 9
10 10 To create area charts, we need two QLineSeries instances. They are going to define upper and lower boundary of the area.
11 11
12 12 \snippet ../examples/areachart/main.cpp 1
13 13
14 14 We add data to both series, we use stream operator.
15 15
16 16 \snippet ../examples/areachart/main.cpp 2
17 17
18 18 Now we create QAreaSeries instance using two line series objects. We set the custom gradient fill and width of the outline.
19 19
20 20 \snippet ../examples/areachart/main.cpp 3
21 21
22 22 In the end we create QChartView instance, set title, set anti-aliasing and add area series. We also set the specific range for axes.
23 23
24 24 \snippet ../examples/areachart/main.cpp 4
25 25
26 26 Chart is ready to be shown.
27 27
28 28 \snippet ../examples/areachart/main.cpp 5
29 29
30 30 */ No newline at end of file
@@ -1,39 +1,39
1 1 /*!
2 \example example/barchart
2 \example examples/barchart
3 3 \title BarChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple bar chart. Barchart shows the data in sets as separate bars, which are grouped in categories.
7 7
8 8 \image barchart.png
9 9
10 10 First we define categories.
11 11
12 12 \snippet ../examples/barchart/main.cpp 1
13 13
14 14 Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data
15 15 we want to visulaize to them.
16 16
17 17 \snippet ../examples/barchart/main.cpp 2
18 18
19 19 To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating
20 20 the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets
21 21 are added to series here.
22 22
23 23 \snippet ../examples/barchart/main.cpp 3
24 24
25 25 We want our barchart to behave so, that when mouse is hovered over bar, the name of set which the bar
26 26 represents is shown as tooltip.
27 27 Also when we click the bar, floating values for the set are toggled. Floating values are the data values
28 28 that are drawn on top of bars.
29 29
30 30 \snippet ../examples/barchart/main.cpp 4
31 31
32 32 Here we create the view and add our series to it. Also we set the title and theme we want our chart to use
33 33
34 34 \snippet ../examples/barchart/main.cpp 5
35 35
36 36 For barchart, we don't need X-axis to be visible, so it can be disabled.
37 37
38 38 \snippet ../examples/barchart/main.cpp 6
39 39 */ No newline at end of file
@@ -1,26 +1,26
1 1 /*!
2 \example example/linechart
2 \example examples/linechart
3 3 \title LineChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple line chart.
7 7
8 8 \image linechart.png
9 9
10 10 To create line charts, QLineSeries instance is needed. Here we create two line series and we set the color and width of line.
11 11
12 12 \snippet ../examples/linechart/main.cpp 1
13 13
14 14 We add data to be shown to both series. We can use add() member function or use stream operator.
15 15
16 16 \snippet ../examples/linechart/main.cpp 2
17 17
18 18 In the end we create QChartView instance, set title, set anti-aliasing and add both series.
19 19
20 20 \snippet ../examples/linechart/main.cpp 3
21 21
22 22 Chart is ready to be shown.
23 23
24 24 \snippet ../examples/linechart/main.cpp 4
25 25
26 26 */ No newline at end of file
@@ -1,39 +1,39
1 1 /*!
2 \example example/percentbarchart
2 \example examples/percentbarchart
3 3 \title PercentBarChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple percent bar chart. Percent bar chart shows the data in set as percentage of all sets, per category.
7 7
8 8 \image percentbarchart.png
9 9
10 10 First we define categories.
11 11
12 12 \snippet ../examples/percentbarchart/main.cpp 1
13 13
14 14 Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data
15 15 we want to visulaize to them.
16 16
17 17 \snippet ../examples/percentbarchart/main.cpp 2
18 18
19 19 To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating
20 20 the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets
21 21 are added to series here.
22 22
23 23 \snippet ../examples/percentbarchart/main.cpp 3
24 24
25 25 We want our barchart to behave so, that when mouse is hovered over bar, the name of set which the bar
26 26 represents is shown as tooltip.
27 27 Also when we click the bar, floating values for the set are toggled. Floating values are the data values
28 28 that are drawn on top of bars.
29 29
30 30 \snippet ../examples/percentbarchart/main.cpp 4
31 31
32 32 Here we create the view and add our series to it. Also we set the title and theme we want our chart to use
33 33
34 34 \snippet ../examples/percentbarchart/main.cpp 5
35 35
36 36 For barchart, we don't need X-axis to be visible, so it can be disabled.
37 37
38 38 \snippet ../examples/percentbarchart/main.cpp 6
39 39 */ No newline at end of file
@@ -1,9 +1,9
1 1 /*!
2 \example example/piechart
2 \example examples/piechart
3 3 \title LineChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple pie chart.
7 7
8 8 ...
9 9 */ No newline at end of file
@@ -1,37 +1,37
1 1 /*!
2 \example example/presenterchart
2 \example examples/presenterchart
3 3 \title PresenterChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create chart which presents the same set of data as line, scatter and spline charts.
7 7 ChartPresenter will switch between these three chart types every few seconds.
8 8 Please note this example does not use common data model. A use of common data model is documented here.[TODO]
9 9
10 10 \image presenterchart1.png
11 11 \image presenterchart2.png
12 12 \image presenterchart3.png
13 13
14 14 We create simple ChartView class which derives form QChartView.
15 15
16 16 \snippet ../examples/presenterchart/chartview.h 1
17 17
18 18 Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations.
19 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 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 21 We set custom line and points colors.
22 22
23 23 \snippet ../examples/presenterchart/chartview.cpp 1
24 24
25 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 26
27 27 \snippet ../examples/presenterchart/chartview.cpp 2
28 28
29 29 In the end we store references all the created series and matching titles.
30 30
31 31 \snippet ../examples/presenterchart/chartview.cpp 3
32 32
33 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 34
35 35 \snippet ../examples/presenterchart/chartview.cpp 4
36 36
37 37 */ No newline at end of file
@@ -1,26 +1,26
1 1 /*!
2 \example example/scatterchart
2 \example examples/scatterchart
3 3 \title ScatterChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple scatter chart.
7 7
8 8 \image scatterchart.png
9 9
10 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 12 \snippet ../examples/scatterchart/main.cpp 1
13 13
14 14 We add data to be shown. We can use add() member function or use stream operator.
15 15
16 16 \snippet ../examples/scatterchart/main.cpp 2
17 17
18 18 In the end we create QChartView instance, set title, set anti-aliasing and add scatter series.
19 19
20 20 \snippet ../examples/scatterchart/main.cpp 3
21 21
22 22 Chart is ready to be shown.
23 23
24 24 \snippet ../examples/scatterchart/main.cpp 4
25 25
26 26 */ No newline at end of file
@@ -1,42 +1,42
1 1 /*!
2 \example example/stackedbarchartdrilldown
2 \example examples/stackedbarchartdrilldown
3 3 \title StackedBarChart Drilldown Example
4 4 \subtitle
5 5
6 6 The example shows how to implement drilldown using stacked barchart. In drilldown example we create stacked barchart, which shows the harvest of various chili peppers during season. In season view the harvest is grouped by month. To drill down to weekly view, user clicks selected month with right mouse button. On weekly view, the harvest of clicked month is shown by week. For example purposes each month is 4 weeks long :)
7 7
8 8 Season view looks like this:
9 9 \image stackedbarchart_drilldown_season.png
10 10
11 11 Right mouse button clicked on august, shows the harvest from august:
12 12 \image stackedbarchart_drilldown_august.png
13 13
14 14 Here we define a drilldown series, which adds mapping for categories to other drilldown series.
15 15 Purpose of drilldown series is to contain knowledge of the drilldown structure. The mapDrilldownSeries function maps the category to given series. We can ask the mapping for category with drilldownSeries(QString category) function.
16 16
17 17 \snippet ../examples/stackedbarchartdrilldown/main.cpp 1
18 18
19 19 To enable drilldown we create own view, which implements handler for right click. All QBarSeries derived classes send out rightClicked(QBarSet*, QString) signal when series is clicked with right mouse button. The parameters QBarSet and QString contain the pointer to clicked bar set and name of category, where click occured.
20 20
21 21 In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
22 22
23 23 \snippet ../examples/stackedbarchartdrilldown/main.cpp 2
24 24
25 25 Here we define data, which we use to construct the chart.
26 26
27 27 \snippet ../examples/stackedbarchartdrilldown/main.cpp 3
28 28
29 29 To create the drilldown structure, we first create our top level series, which we call seasonSeries. For each month in seasonSeries we create a drilldown series, called weeklySeries which contains more detailed data for that month.
30 30 In weeklySeries, we use the drilldown handler to bring us back to seasonSeries. To do this we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
31 31 To make mapping work, we connect the rightClicked signals from our series to the drilldownChart.
32 32
33 33 \snippet ../examples/stackedbarchartdrilldown/main.cpp 4
34 34
35 35 When we have our drilldown structure ready, we can add the data to it. Here we generate random crop for each plant in each week. The monthly crop is calculated from weekly crops. To enable floating values, we connect the clicked signal to toggle the value of corresponding set.
36 36
37 37 \snippet ../examples/stackedbarchartdrilldown/main.cpp 5
38 38
39 39 Here we set the chart to show top level series initially.
40 40
41 41 \snippet ../examples/stackedbarchartdrilldown/main.cpp 6
42 42 */ No newline at end of file
@@ -1,39 +1,39
1 1 /*!
2 \example example/stackedbarchart
2 \example examples/stackedbarchart
3 3 \title StackedBarChart Example
4 4 \subtitle
5 5
6 6 The example shows how to create simple stacked bar chart. Stacked bar chart shows the data in sets as bars that are stacked on top of each other. The stacking is done per category.
7 7
8 8 \image stackedbarchart.png
9 9
10 10 First we define categories.
11 11
12 12 \snippet ../examples/stackedbarchart/main.cpp 1
13 13
14 14 Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data
15 15 we want to visulaize to them.
16 16
17 17 \snippet ../examples/stackedbarchart/main.cpp 2
18 18
19 19 To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating
20 20 the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets
21 21 are added to series here.
22 22
23 23 \snippet ../examples/stackedbarchart/main.cpp 3
24 24
25 25 We want our barchart to behave so, that when mouse is hovered over bar, the name of set which the bar
26 26 represents is shown as tooltip.
27 27 Also when we click the bar, floating values for the set are toggled. Floating values are the data values
28 28 that are drawn on top of bars.
29 29
30 30 \snippet ../examples/stackedbarchart/main.cpp 4
31 31
32 32 Here we create the view and add our series to it. Also we set the title and theme we want our chart to use
33 33
34 34 \snippet ../examples/stackedbarchart/main.cpp 5
35 35
36 36 For barchart, we don't need X-axis to be visible, so it can be disabled.
37 37
38 38 \snippet ../examples/stackedbarchart/main.cpp 6
39 39 */ No newline at end of file
@@ -1,32 +1,32
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 <li><a href="example-areachart.html">Area Chart example</a></li>
17 <li><a href="example-barchart.html">Bar 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>
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>
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>
16 <li><a href="examples-areachart.html">Area 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>
19 <li><a href="examples-percentbarchart.html">Percent Bar Chart example</a></li>
20 <li><a href="examples-piechart.html">Pie Chart example</a></li>
21 <li><a href="examples-presenterchart.html">Presenter Chart example</a></li>
22 <li><a href="examples-scatterchart.html">Scatter Chart example</a></li>
23 <li><a href="examples-splinechart.html">Spline Chart example</a></li>
24 <li><a href="examples-stackedbarchart.html">Stacked Bar Chart example</a></li>
25 <li><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li>
26 26 <li><a href="examples-customcolors.html">Customizing colors example</a></li>
27 27 </ul>
28 28 </td>
29 29 </tr>
30 30 </table>
31 31 \endraw
32 32 */
General Comments 0
You need to be logged in to leave comments. Login now