##// END OF EJS Templates
Example finalization and documentation...
Mika Salmela -
r2556:89b8a97da4fc
parent child
Show More
@@ -0,0 +1,13
1 # BoxWhisk Inc share deviation in 2012
2 Jan 25.74 25.28 25.86 26.05 26.64 28.47 28.30 29.22 29.72 27.50 25.62 25.50 25.15 26.47 27.41 25.78 24.82 24.89 24.88 24.60 23.85
3 Feb 30.79 29.62 29.67 30.37 30.16 30.22 31.02 33.70 32.60 32.24 31.98 31.79 31.10 30.79 31.53 30.92 29.00 29.58 30.37 29.40 28.60
4 Mar 29.64 29.34 30.13 30.43 31.75 30.77 30.72 31.52 32.12 33.75 33.51 33.69 32.83 32.47 32.41 32.39 32.78 31.08 29.46 31.58 31.39 31.41
5 Apr 24.96 25.62 25.19 28.37 28.78 26.50 25.90 26.40 26.86 26.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 26.96 26.50
6 May 21.85 21.08 22.98 22.61 22.45 21.73 21.71 23.27 22.14 19.65 22.95 21.23 23.17 24.26 24.17 21.97 22.53 25.49 25.51 26.46 26.65
7 Jun 15.08 15.19 15.36 15.21 15.31 18.19 18.30 15.53 15.35 15.80 15.17 16.95 18.25 20.52 20.61 20.40 20.45 19.43 19.11 19.74
8 Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 19.00 19.03 19.14 19.10 17.86 19.12 19.53 19.43 19.30 19.03 19.76 18.79 18.33
9 Aug 19.69 19.54 19.39 19.49 19.96 19.72 20.25 20.70 21.13 20.74 20.27 19.25 18.72 19.02 19.20 19.24 19.60 19.22 19.60 18.98 18.27 17.70 18.19
10 Sep 19.35 19.82 19.96 20.96 20.75 21.55 21.68 22.19 22.14 22.48 22.45 21.74 21.97 21.18 20.66 20.54 19.89 19.39 19.26 19.86
11 Oct 17.95 17.80 17.45 17.89 18.38 18.12 17.85 18.59 18.65 18.46 18.43 18.30 18.87 19.61 19.55 19.59 20.27 20.54 21.02 20.23 19.05 19.52 19.71
12 Now 20.36 20.29 19.22 19.74 20.05 20.13 19.67 19.19 18.94 19.04 18.49 18.53 18.64 19.00 19.21 19.19 19.30 19.11 19.17 18.76 18.80 18.52
13 Dec 22.95 22.19 22.15 21.42 21.39 21.65 22.39 20.86 20.48 20.70 20.94 20.82 19.25 21.21 19.63 20.55
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,38 +1,76
1 /*!
1 /*!
2 \example examples/boxplotchart
2 \example examples/boxplotchart
3 \title Box and Whiskers Example
3 \title Box and Whiskers Example
4 \subtitle
4 \subtitle
5
5
6 The example shows how to create a box-and-whiskers chart.
6 The example shows how to create a box-and-whiskers chart. It also shows how to read the non-continuous data from the file,
7 arrange it and find medians needed for box-and-whiskers plotting.
7
8
8 \image examples_barchart.png
9 \image examples_boxplotchart.png
9
10
10 Introduction here
11 To show the share deviation of two companies we start by creating two QBoxPlotSeries to handle monthly data.
11
12
12 \snippet ../examples/barchart/main.cpp 1
13 \snippet ../examples/boxplotchart/main.cpp 1
13
14
14 YkkοΏ½skohta
15 QFile class is used to open a text file where the non-continuous data is kept. The BoxDataReader is an auxiliary class for
16 reading the text file and finding the extreme and median values from the data. The BoxDataReader is explained in more detail later.
17 The method readBox reads the values and sets them to the QBoxSet item which the method returns for the caller. The returned QBoxSet
18 item is added to the series.
15
19
16 \snippet ../examples/barchart/main.cpp 2
20 \snippet ../examples/boxplotchart/main.cpp 2
17
21
18 Kakkoskohta
22 In this section a second file is opened for reading the data for the second company.
19
23
20 \snippet ../examples/barchart/main.cpp 3
24 \snippet ../examples/boxplotchart/main.cpp 3
21
25
22 Kolmoskohta
26 In this code snippet a new QChart instance is created and previously created series are added to it. Also title is defined and
27 animation is set to be SeriesAnimation.
23
28
24 \snippet ../examples/barchart/main.cpp 4
29 \snippet ../examples/boxplotchart/main.cpp 4
25
30
26 Neloskohta
31 Here we ask chart to create default axes for our presentation. We also set range for vertical axis by querying the pointer
32 for the axis from the chart and then setting the min and max for that axis.
27
33
28 \snippet ../examples/barchart/main.cpp 5
34 \snippet ../examples/boxplotchart/main.cpp 5
29
35
30 Tarkista numerointi. Finally we add the chart onto a view. We also turn on the antialiasing for the chartView.
36 In this section we set legends visible and place them at the bottom of the chart.
31
37
32 \snippet ../examples/barchart/main.cpp 6
38 \snippet ../examples/boxplotchart/main.cpp 6
33
39
34 Tarkista numerointi. Chart is ready to be shown. We set the chart to be central widget of the window.
40 Finally we add the chart onto a view. We also turn on the antialiasing for the chartView.
41
42 \snippet ../examples/boxplotchart/main.cpp 7
43
44 The chart is ready to be shown. We set the chart to be central widget of the window.
35 We also set the size for the chart window and show it.
45 We also set the size for the chart window and show it.
36
46
37 \snippet ../examples/barchart/main.cpp 7
47 \snippet ../examples/boxplotchart/main.cpp 8
48
49 Here the method readBox is explained in detail. Firstly a line is read from the file and lines starting with # are rejected
50 since they are considered as comment lines.
51
52 \snippet ../examples/boxplotchart/boxdatareader.cpp 1
53
54 On the file the data is arranged as number, space, number, space and so on. On this snippet the line is split into single number strings which
55 are stored on QStringList.
56
57 \snippet ../examples/boxplotchart/boxdatareader.cpp 2
58
59 The sortedList will hold the numbers in continuous order and in this code segment we show how to do it. First the sortedList is cleared and numbers
60 are read from the strList and stored into sortedList in double format. The qSort method arranges the sortedList into continuous order
61 starting from the smallest.
62
63 \snippet ../examples/boxplotchart/boxdatareader.cpp 3
64
65 Here is a code sample how to select extremes and medians from the continuous data. Firstly a new QBoxSet is created.
66 Lower and upper extremes are simple to select; they are just first and last items on the sortedList. For medians we use a helper
67 method findMedian which is explained later. For the median from the upper half we need to adjust the begin number if
68 amount of the numbers is even or uneven. The end number for lower half comes naturally from int rounding.
69
70 \snippet ../examples/boxplotchart/boxdatareader.cpp 4
71
72 Here's the code sample for the method findMedian. If the amount of numbers is uneven we select the number from
73 the middle. For even amount numbers we take two numbers from the middle and calculate the mean value.
74
75 \snippet ../examples/boxplotchart/boxdatareader.cpp 5
38 */
76 */
@@ -1,140 +1,147
1 /*!
1 /*!
2 \page examples.html
2 \page examples.html
3 \title QtCommercial Charts Examples
3 \title QtCommercial Charts Examples
4 \keyword Examples
4 \keyword Examples
5
5
6 \raw HTML
6 \raw HTML
7 <div class="qchart">
7 <div class="qchart">
8
8
9 <table>
9 <table>
10 <tr>
10 <tr>
11 <td><a href="examples-areachart.html">Area Chart</a></td>
11 <td><a href="examples-areachart.html">Area Chart</a></td>
12 <td><a href="examples-barchart.html">Bar Chart</a></td>
12 <td><a href="examples-barchart.html">Bar Chart</a></td>
13 </tr>
13 </tr>
14 <tr>
14 <tr>
15 <td><a href="examples-areachart.html"><img src="images/examples_areachart.png" width="300" alt="Area Chart" /></a></td>
15 <td><a href="examples-areachart.html"><img src="images/examples_areachart.png" width="300" alt="Area Chart" /></a></td>
16 <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="300" alt="Bar Chart" /></a></td>
16 <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="300" alt="Bar Chart" /></a></td>
17 </tr>
17 </tr>
18
18
19 <tr>
19 <tr>
20 <td><a href="examples-barmodelmapper.html">Bar Chart from Model</a></td>
20 <td><a href="examples-barmodelmapper.html">Bar Chart from Model</a></td>
21 <td><a href="examples-customchart.html">Custom Chart</a></td>
21 <td><a href="examples-boxplotchart.html">Box-and-whiskers Chart</a></td>
22 </tr>
22 </tr>
23 <tr>
23 <tr>
24 <td><a href="examples-barmodelmapper.html"><img src="images/examples_barmodelmapper.png" width="300" alt="Bar Chart from Model" /></a></td>
24 <td><a href="examples-barmodelmapper.html"><img src="images/examples_barmodelmapper.png" width="300" alt="Bar Chart from Model" /></a></td>
25 <td><a href="examples-customchart.html"><img src="images/examples_customchart.png" width="300" alt="Custom Chart" /></a></td>
25 <td><a href="examples-boxplotchart.html"><img src="images/examples_boxplotchart.png" width="300" alt="Bar Chart from Model" /></a></td>
26 </tr>
26 </tr>
27
27
28 <tr>
28 <tr>
29 <td><a href="examples-customchart.html">Custom Chart</a></td>
29 <td><a href="examples-datetimeaxis.html">DateTimeAxis Example</a></td>
30 <td><a href="examples-datetimeaxis.html">DateTimeAxis Example</a></td>
30 <td><a href="examples-donutbreakdown.html">Donut Breakdown Chart</a></td>
31 </tr>
31 </tr>
32 <tr>
32 <tr>
33 <td><a href="examples-customchart.html"><img src="images/examples_customchart.png" width="300" alt="Custom Chart" /></a></td>
33 <td><a href="examples-datetimeaxis.html"><img src="images/examples_datetimeaxis.png" width="300" alt="DateTimeAxis Example" /></a></td>
34 <td><a href="examples-datetimeaxis.html"><img src="images/examples_datetimeaxis.png" width="300" alt="DateTimeAxis Example" /></a></td>
34 <td><a href="examples-donutbreakdown.html"><img src="images/examples_donutbreakdown.png" width="300" alt="Donut Breakdown Chart" /></a></td>
35 </tr>
35 </tr>
36
36
37 <tr>
37 <tr>
38 <td><a href="examples-donutbreakdown.html">Donut Breakdown Chart</a></td>
38 <td><a href="examples-donutchart.html">Donut Chart</a></td>
39 <td><a href="examples-donutchart.html">Donut Chart</a></td>
39 <td><a href="examples-horizontalbarchart.html">Horizontal Bar Chart</a></td>
40 </tr>
40 </tr>
41 <tr>
41 <tr>
42 <td><a href="examples-donutbreakdown.html"><img src="images/examples_donutbreakdown.png" width="300" alt="Donut Breakdown Chart" /></a></td>
42 <td><a href="examples-donutchart.html"><img src="images/examples_donutchart.png" width="300" alt="Donut Chart" /></a></td>
43 <td><a href="examples-donutchart.html"><img src="images/examples_donutchart.png" width="300" alt="Donut Chart" /></a></td>
43 <td><a href="examples-horizontalbarchart.html"><img src="images/examples_horizontalbarchart.png" width="300" alt="Horizontal Bar Chart" /></a></td>
44 </tr>
44 </tr>
45
45
46 <tr>
46 <tr>
47 <td><a href="examples-horizontalbarchart.html">Horizontal Bar Chart</a></td>
47 <td><a href="examples-horizontalpercentbarchart.html">Horizontal Percent Bar Chart</a></td>
48 <td><a href="examples-horizontalpercentbarchart.html">Horizontal Percent Bar Chart</a></td>
48 <td><a href="examples-horizontalstackedbarchart.html">Horizontal Stacked Bar Chart</a></td>
49 </tr>
49 </tr>
50 <tr>
50 <tr>
51 <td><a href="examples-horizontalbarchart.html"><img src="images/examples_horizontalbarchart.png" width="300" alt="Horizontal Bar Chart" /></a></td>
51 <td><a href="examples-horizontalpercentbarchart.html"><img src="images/examples_horizontalpercentbarchart.png" width="300" alt="Horizontal Percent Bar Chart" /></a></td>
52 <td><a href="examples-horizontalpercentbarchart.html"><img src="images/examples_horizontalpercentbarchart.png" width="300" alt="Horizontal Percent Bar Chart" /></a></td>
52 <td><a href="examples-horizontalstackedbarchart.html"><img src="images/examples_horizontalstackedbarchart.png" width="300" alt="Horizontal Stacked Bar Chart" /></a></td>
53 </tr>
53 </tr>
54
54
55 <tr>
55 <tr>
56 <td><a href="examples-horizontalstackedbarchart.html">Horizontal Stacked Bar Chart</a></td>
56 <td><a href="examples-legend.html">Legend</a></td>
57 <td><a href="examples-legend.html">Legend</a></td>
57 <td><a href="examples-legendmarkers.html">Legend Markers</a></td>
58 </tr>
58 </tr>
59 <tr>
59 <tr>
60 <td><a href="examples-horizontalstackedbarchart.html"><img src="images/examples_horizontalstackedbarchart.png" width="300" alt="Horizontal Stacked Bar Chart" /></a></td>
60 <td><a href="examples-legend.html"><img src="images/examples_legend_detach.png" width="300" alt="Legend" /></a></td>
61 <td><a href="examples-legend.html"><img src="images/examples_legend_detach.png" width="300" alt="Legend" /></a></td>
61 <td><a href="examples-legendmarkers.html"><img src="images/examples_legendmarkers.png" width="300" alt="Legend Markers" /></a></td>
62 </tr>
62 </tr>
63
63
64 <tr>
64 <tr>
65 <td><a href="examples-legendmarkers.html">Legend Markers</a></td>
65 <td><a href="examples-lineandbar.html">Line and Barchart</a></td>
66 <td><a href="examples-lineandbar.html">Line and Barchart</a></td>
66 <td><a href="examples-linechart.html">Line Chart</a></td>
67 </tr>
67 </tr>
68 <tr>
68 <tr>
69 <td><a href="examples-legendmarkers.html"><img src="images/examples_legendmarkers.png" width="300" alt="Legend Markers" /></a></td>
69 <td><a href="examples-lineandbar.html"><img src="images/examples_lineandbar.png" width="300" alt="Line and Barchart" /></a></td>
70 <td><a href="examples-lineandbar.html"><img src="images/examples_lineandbar.png" width="300" alt="Line and Barchart" /></a></td>
70 <td><a href="examples-linechart.html"><img src="images/examples_linechart.png" width="300" alt="Line Chart" /></a></td>
71 </tr>
71 </tr>
72
72
73 <tr>
73 <tr>
74 <td><a href="examples-linechart.html">Line Chart</a></td>
74 <td><a href="examples-logvalueaxis.html">Logarithmic axis</a></td>
75 <td><a href="examples-logvalueaxis.html">Logarithmic axis</a></td>
75 <td><a href="examples-modeldata.html">Model Data</a></td>
76 </tr>
76 </tr>
77 <tr>
77 <tr>
78 <td><a href="examples-linechart.html"><img src="images/examples_linechart.png" width="300" alt="Line Chart" /></a></td>
78 <td><a href="examples-logvalueaxis.html"><img src="images/examples_logvalueaxis.png" width="300" alt="Logarythmix axis" /></a></td>
79 <td><a href="examples-logvalueaxis.html"><img src="images/examples_logvalueaxis.png" width="300" alt="Logarythmix axis" /></a></td>
79 <td><a href="examples-modeldata.html"><img src="images/examples_modeldata.png" width="300" alt="Model Data" /></a></td>
80 </tr>
80 </tr>
81
81
82 <tr>
82 <tr>
83 <td><a href="examples-modeldata.html">Model Data</a></td>
83 <td><a href="examples-multiaxis.html">Multiple axes</a></td>
84 <td><a href="examples-multiaxis.html">Multiple axes</a></td>
84 <td><a href="examples-percentbarchart.html">Percent Bar Chart</a></td>
85 </tr>
85 </tr>
86 <tr>
86 <tr>
87 <td><a href="examples-modeldata.html"><img src="images/examples_modeldata.png" width="300" alt="Model Data" /></a></td>
87 <td><a href="examples-multiaxis.html"><img src="images/examples_multiaxis.png" width="300" alt="Multiple axes" /></a></td>
88 <td><a href="examples-multiaxis.html"><img src="images/examples_multiaxis.png" width="300" alt="Multiple axes" /></a></td>
88 <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="300" alt="Percent Bar Chart" /></a></td>
89 </tr>
89 </tr>
90
90
91 <tr>
91 <tr>
92 <td><a href="examples-percentbarchart.html">Percent Bar Chart</a></td>
92 <td><a href="examples-piechart.html">Pie Chart</a></td>
93 <td><a href="examples-piechart.html">Pie Chart</a></td>
93 <td><a href="examples-piechartdrilldown.html">Pie Chart Drilldown</a></td>
94 </tr>
94 </tr>
95 <tr>
95 <tr>
96 <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="300" alt="Percent Bar Chart" /></a></td>
96 <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="300" alt="Pie Chart" /></a></td>
97 <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="300" alt="Pie Chart" /></a></td>
97 <td><a href="examples-piechartdrilldown.html"><img src="images/examples_piechartdrill2.png" width="300" alt="Pie Chart Drilldown" /></a></td>
98 </tr>
98 </tr>
99
99
100 <tr>
100 <tr>
101 <td><a href="examples-piechartdrilldown.html">Pie Chart Drilldown</a></td>
101 <td><a href="examples-polarchart.html">Polar chart</a></td>
102 <td><a href="examples-polarchart.html">Polar chart</a></td>
102 <td><a href="examples-scatterchart.html">Scatter chart</a></td>
103 </tr>
103 </tr>
104 <tr>
104 <tr>
105 <td><a href="examples-piechartdrilldown.html"><img src="images/examples_piechartdrill2.png" width="300" alt="Pie Chart Drilldown" /></a></td>
105 <td><a href="examples-polarchart.html"><img src="images/examples_polarchart.png" width="300" alt="Polar chart" /></a></td>
106 <td><a href="examples-polarchart.html"><img src="images/examples_polarchart.png" width="300" alt="Polar chart" /></a></td>
106 <td><a href="examples-scatterchart.html"><img src="images/examples_scatterchart.png" width="300" alt="Scatter chart" /></a></td>
107 </tr>
107 </tr>
108
108
109 <tr>
109 <tr>
110 <td><a href="examples-scatterchart.html">Scatter chart</a></td>
110 <td><a href="examples-scatterinteractions.html">Scatter Interactions</a></td>
111 <td><a href="examples-scatterinteractions.html">Scatter Interactions</a></td>
111 <td><a href="examples-splinechart.html">Spline Chart</a></td>
112 </tr>
112 </tr>
113 <tr>
113 <tr>
114 <td><a href="examples-scatterchart.html"><img src="images/examples_scatterchart.png" width="300" alt="Scatter chart" /></a></td>
114 <td><a href="examples-scatterinteractions.html"><img src="images/examples_scatterinteractions.png" width="300" alt="Scatter Interactions" /></a></td>
115 <td><a href="examples-scatterinteractions.html"><img src="images/examples_scatterinteractions.png" width="300" alt="Scatter Interactions" /></a></td>
115 <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="300" alt="Spline Chart" /></a></td>
116 </tr>
116 </tr>
117
117
118 <tr>
118 <tr>
119 <td><a href="examples-splinechart.html">Spline Chart</a></td>
119 <td><a href="examples-stackedbarchart.html">Stacked Bar Chart</a></td>
120 <td><a href="examples-stackedbarchart.html">Stacked Bar Chart</a></td>
120 <td><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown</a></td>
121 </tr>
121 </tr>
122 <tr>
122 <tr>
123 <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="300" alt="Spline Chart" /></a></td>
123 <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="300" alt="Stacked Bar Chart" /></a></td>
124 <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="300" alt="Stacked Bar Chart" /></a></td>
124 <td><a href="examples-stackedbarchartdrilldown.html"><img src="images/examples_stackedbarchartdrilldown1.png" width="300" alt="Stacked Bar Chart Drilldown" /></a></td>
125 </tr>
125 </tr>
126
126
127 <tr>
127 <tr>
128 <td><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown</a></td>
128 <td><a href="examples-temperaturerecords.html">Temperature Records</a></td>
129 <td><a href="examples-temperaturerecords.html">Temperature Records</a></td>
129 <td><a href="examples-zoomlinechart.html">Zoom Line</a></td>
130 </tr>
130 </tr>
131 <tr>
131 <tr>
132 <td><a href="examples-stackedbarchartdrilldown.html"><img src="images/examples_stackedbarchartdrilldown1.png" width="300" alt="Stacked Bar Chart Drilldown" /></a></td>
132 <td><a href="examples-temperaturerecords.html"><img src="images/examples_temperaturerecords.png" width="300" alt="Temperature Records" /></a></td>
133 <td><a href="examples-temperaturerecords.html"><img src="images/examples_temperaturerecords.png" width="300" alt="Temperature Records" /></a></td>
134 </tr>
135
136 <tr>
137 <td><a href="examples-zoomlinechart.html">Zoom Line</a></td>
138 </tr>
139 <tr>
133 <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart1.png" width="300" alt="Zoom Line" /></a></td>
140 <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart1.png" width="300" alt="Zoom Line" /></a></td>
134 </tr>
141 </tr>
135
142
136 </table>
143 </table>
137 </div>
144 </div>
138 \endraw
145 \endraw
139
146
140 */
147 */
1 NO CONTENT: file renamed from examples/boxplotchart/stock_data.txt to examples/boxplotchart/acme_data.txt
NO CONTENT: file renamed from examples/boxplotchart/stock_data.txt to examples/boxplotchart/acme_data.txt
@@ -1,67 +1,79
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "boxdatareader.h"
21 #include "boxdatareader.h"
22
22
23 BoxDataReader::BoxDataReader(QIODevice *device) :
23 BoxDataReader::BoxDataReader(QIODevice *device) :
24 QTextStream(device)
24 QTextStream(device)
25 {
25 {
26 }
26 }
27
27
28 void BoxDataReader::readFile(QIODevice *device)
29 {
30 QTextStream::setDevice(device);
31 }
32
28 QBoxSet* BoxDataReader::readBox()
33 QBoxSet *BoxDataReader::readBox()
29 {
34 {
35 //! [1]
30 QString line = readLine();
36 QString line = readLine();
31 if (line.startsWith("#"))
37 if (line.startsWith("#"))
32 return 0;
38 return 0;
39 //! [1]
33
40
41 //! [2]
34 QStringList strList = line.split(" ", QString::SkipEmptyParts);
42 QStringList strList = line.split(" ", QString::SkipEmptyParts);
35 sortedList.clear();
43 //! [2]
36
44
45 //! [3]
46 sortedList.clear();
37 for (int i = 1; i < strList.count(); i++)
47 for (int i = 1; i < strList.count(); i++)
38 sortedList.append(strList.at(i).toDouble());
48 sortedList.append(strList.at(i).toDouble());
39
49
40 qSort(sortedList.begin(), sortedList.end());
50 qSort(sortedList.begin(), sortedList.end());
51 //! [3]
41
52
42 int count = sortedList.count();
53 int count = sortedList.count();
43
54
55 //! [4]
44 QBoxSet *box = new QBoxSet(strList.first());
56 QBoxSet *box = new QBoxSet(strList.first());
45 box->setValue(QBoxSet::LowerExtreme, sortedList.first());
57 box->setValue(QBoxSet::LowerExtreme, sortedList.first());
46 box->setValue(QBoxSet::UpperExtreme, sortedList.last());
58 box->setValue(QBoxSet::UpperExtreme, sortedList.last());
47 box->setValue(QBoxSet::Median, findMedian(0, count));
59 box->setValue(QBoxSet::Median, findMedian(0, count));
48 box->setValue(QBoxSet::LowerQuartile, findMedian(0, count / 2));
60 box->setValue(QBoxSet::LowerQuartile, findMedian(0, count / 2));
49 if (count % 2)
61 box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2 + (count % 2), count));
50 box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2 + 1, count));
62 //! [4]
51 else // even amount of numbers
52 box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2, count));
53
63
54 return box;
64 return box;
55 }
65 }
56
66
57 qreal BoxDataReader::findMedian(int begin, int end)
67 qreal BoxDataReader::findMedian(int begin, int end)
58 {
68 {
69 //! [5]
59 int count = end - begin;
70 int count = end - begin;
60 if (count % 2 ) {
71 if (count % 2) {
61 return sortedList.at(int(count/2) + begin);
72 return sortedList.at(count / 2 + begin);
62 } else {
73 } else {
63 qreal right = sortedList.at(count / 2 + begin);
74 qreal right = sortedList.at(count / 2 + begin);
64 qreal left = sortedList.at(count / 2 - 1 + begin);
75 qreal left = sortedList.at(count / 2 - 1 + begin);
65 return (right + left) / 2.0;
76 return (right + left) / 2.0;
66 }
77 }
78 //! [5]
67 }
79 }
@@ -1,42 +1,43
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 #ifndef BOXDATAREADER_H
21 #ifndef BOXDATAREADER_H
22 #define BOXDATAREADER_H
22 #define BOXDATAREADER_H
23
23
24 #include <QTextStream>
24 #include <QTextStream>
25 #include <QBoxSet>
25 #include <QBoxSet>
26
26
27 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
28
29 class BoxDataReader : public QTextStream
29 class BoxDataReader : public QTextStream
30 {
30 {
31 public:
31 public:
32 explicit BoxDataReader(QIODevice *device);
32 explicit BoxDataReader(QIODevice *device);
33 QBoxSet* readBox();
33 QBoxSet *readBox();
34 void readFile(QIODevice *device);
34
35
35 protected:
36 protected:
36 qreal findMedian(int begin, int end);
37 qreal findMedian(int begin, int end);
37
38
38 private:
39 private:
39 QList<qreal> sortedList;
40 QList<qreal> sortedList;
40 };
41 };
41
42
42 #endif // BOXDATAREADER_H
43 #endif // BOXDATAREADER_H
@@ -1,5 +1,6
1 <RCC>
1 <RCC>
2 <qresource prefix="/">
2 <qresource prefix="/">
3 <file alias="stock">stock_data.txt</file>
3 <file alias="acme">acme_data.txt</file>
4 <file alias="boxwhisk">boxwhisk_data.txt</file>
4 </qresource>
5 </qresource>
5 </RCC>
6 </RCC>
@@ -1,85 +1,104
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 <QApplication>
21 #include <QApplication>
22 #include <QMainWindow>
22 #include <QMainWindow>
23 #include <QChartView>
23 #include <QChartView>
24 #include <QBoxPlotSeries>
24 #include <QBoxPlotSeries>
25 #include <QBoxSet>
25 #include <QBoxSet>
26 #include <QLegend>
26 #include <QLegend>
27 #include <QBarCategoryAxis>
27 #include <QBarCategoryAxis>
28
28
29 #include "boxdatareader.h"
29 #include "boxdatareader.h"
30
30
31 QTCOMMERCIALCHART_USE_NAMESPACE
31 QTCOMMERCIALCHART_USE_NAMESPACE
32
32
33 int main(int argc, char *argv[])
33 int main(int argc, char *argv[])
34 {
34 {
35 QApplication a(argc, argv);
35 QApplication a(argc, argv);
36
37 //! [1]
38 QBoxPlotSeries *acmeSeries = new QBoxPlotSeries();
39 acmeSeries->setName("Acme Ltd");
40
41 QBoxPlotSeries *boxWhiskSeries = new QBoxPlotSeries();
42 boxWhiskSeries->setName("BoxWhisk Inc");
36 //![1]
43 //! [1]
37
44
38 //![2]
45 //! [2]
39 QBoxPlotSeries *series = new QBoxPlotSeries();
46 QFile acmeData(":acme");
40 series->setName("Acme Ltd");
47 if (!acmeData.open(QIODevice::ReadOnly | QIODevice::Text))
48 return 1;
49
50 BoxDataReader dataReader(&acmeData);
51 while (!dataReader.atEnd()) {
52 QBoxSet *set = dataReader.readBox();
53 if (set)
54 acmeSeries->append(set);
55 }
41 //![2]
56 //! [2]
42
57
43 QFile stockData(":stock");
58 //! [3]
44 if (!stockData.open(QIODevice::ReadOnly | QIODevice::Text))
59 QFile boxwhiskData(":boxwhisk");
60 if (!boxwhiskData.open(QIODevice::ReadOnly | QIODevice::Text))
45 return 1;
61 return 1;
46
62
47 BoxDataReader dataReader(&stockData);
63 dataReader.readFile(&boxwhiskData);
48 while (!dataReader.atEnd()) {
64 while (!dataReader.atEnd()) {
49 QBoxSet *set = dataReader.readBox();
65 QBoxSet *set = dataReader.readBox();
50 if (set)
66 if (set)
51 series->append(set);
67 boxWhiskSeries->append(set);
52 }
68 }
53
54 //![3]
69 //! [3]
70
71 //! [4]
55 QChart *chart = new QChart();
72 QChart *chart = new QChart();
56 chart->addSeries(series);
73 chart->addSeries(acmeSeries);
57 chart->setTitle("Acme's share deviation in 2012");
74 chart->addSeries(boxWhiskSeries);
75 chart->setTitle("Acme Ltd and BoxWhisk Inc share deviation in 2012");
58 chart->setAnimationOptions(QChart::SeriesAnimations);
76 chart->setAnimationOptions(QChart::SeriesAnimations);
59 //![3]
60
61 //![4]
77 //! [4]
78
79 //! [5]
62 chart->createDefaultAxes();
80 chart->createDefaultAxes();
63 chart->axisY()->setMin(15.0);
81 chart->axisY()->setMin(15.0);
64 //![4]
82 chart->axisY()->setMax(34.0);
65
66 //![5]
83 //! [5]
84
85 //! [6]
67 chart->legend()->setVisible(true);
86 chart->legend()->setVisible(true);
68 chart->legend()->setAlignment(Qt::AlignBottom);
87 chart->legend()->setAlignment(Qt::AlignBottom);
69 //![5]
70
71 //![6]
88 //! [6]
89
90 //! [7]
72 QChartView *chartView = new QChartView(chart);
91 QChartView *chartView = new QChartView(chart);
73 chartView->setRenderHint(QPainter::Antialiasing);
92 chartView->setRenderHint(QPainter::Antialiasing);
74 //![6]
75
76 //![7]
93 //! [7]
94
95 //! [8]
77 QMainWindow window;
96 QMainWindow window;
78 window.setCentralWidget(chartView);
97 window.setCentralWidget(chartView);
79 window.resize(600, 400);
98 window.resize(800, 600);
80 window.show();
99 window.show();
81 //![7]
100 //! [8]
82
101
83 return a.exec();
102 return a.exec();
84 }
103 }
85
104
@@ -1,400 +1,391
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 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 "qboxset.h"
21 #include "qboxset.h"
22 #include "qboxset_p.h"
22 #include "qboxset_p.h"
23 #include "charthelpers_p.h"
23 #include "charthelpers_p.h"
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 /*!
27 /*!
28 \class QBoxSet
28 \class QBoxSet
29 \brief Building block for box-and-whiskers chart
29 \brief Building block for box-and-whiskers chart
30
30
31 QBoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation
31 QBoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation
32 of range and three medians. There are two ways to give the values. The first one is with constructor
32 of range and three medians. There are two ways to give the values. The first one is with constructor
33 or stream operator (<<). The values have to be given in the following order: lower extreme,
33 or stream operator (<<). The values have to be given in the following order: lower extreme,
34 lower quartile, median, upper quartile and upper extreme. The Second method is to create an empty QBoxSet instance and
34 lower quartile, median, upper quartile and upper extreme. The Second method is to create an empty QBoxSet instance and
35 give the values using setValue method.
35 give the values using setValue method.
36
36
37 \mainclass
37 \mainclass
38
38
39 \sa QBoxPlotSeries
39 \sa QBoxPlotSeries
40 */
40 */
41 /*!
41 /*!
42 \qmlclass BoxSet QBoxSet
42 \qmlclass BoxSet QBoxSet
43
43
44 BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation
44 BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation
45 of range and three medians. There are two ways to give the values. The first one is with constructor
45 of range and three medians. There are two ways to give the values. The first one is with constructor
46 or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median,
46 or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median,
47 upper quartile and upper extre. The second method is to create an empty QBoxSet instance and give the values using
47 upper quartile and upper extre. The second method is to create an empty QBoxSet instance and give the values using
48 value specific methods.
48 value specific methods.
49 \sa BoxPlotSeries
49 \sa BoxPlotSeries
50 */
50 */
51 /*!
51 /*!
52 \enum QBoxSet::ValuePositions
52 \enum QBoxSet::ValuePositions
53
53
54 \value LowerExtreme
54 \value LowerExtreme
55 \value LowerQuartile
55 \value LowerQuartile
56 \value Median
56 \value Median
57 \value UpperQuartile
57 \value UpperQuartile
58 \value UpperExtreme
58 \value UpperExtreme
59 */
59 */
60
60
61 /*!
61 /*!
62 \qmlproperty string BoxSet::label
62 \qmlproperty string BoxSet::label
63 Defines the label of the boxSet.
63 Defines the label of the boxSet.
64 */
64 */
65 /*!
65 /*!
66 \qmlproperty int BoxSet::count
66 \qmlproperty int BoxSet::count
67 The count of values on the box-and-whiskers set
67 The count of values on the box-and-whiskers set
68 */
68 */
69
69
70 /*!
70 /*!
71 \property QBoxSet::pen
71 \property QBoxSet::pen
72 \brief Defines the pen used by the box-and-whiskers set.
72 \brief Defines the pen used by the box-and-whiskers set.
73 */
73 */
74
74
75 /*!
75 /*!
76 \property QBoxSet::brush
76 \property QBoxSet::brush
77 \brief Defines the brush used by the box-and-whiskers set.
77 \brief Defines the brush used by the box-and-whiskers set.
78 */
78 */
79
79
80 /*!
80 /*!
81 \qmlmethod void BoxSet::setValue(int index, qreal value)
81 \qmlmethod void BoxSet::setValue(int index, qreal value)
82 Sets a new \a value on the \a index position.
82 Sets a new \a value on the \a index position.
83 */
83 */
84 /*!
84 /*!
85 \fn void QBoxSet::clicked()
85 \fn void QBoxSet::clicked()
86 The signal is emitted if the user clicks with a mouse on top of box-and-whisker item.
86 The signal is emitted if the user clicks with a mouse on top of box-and-whisker item.
87 */
87 */
88 /*!
88 /*!
89 \qmlsignal BoxSet::onClicked()
89 \qmlsignal BoxSet::onClicked()
90 This signal is emitted when the user clicks with a mouse on top of box-and-whisker item.
90 This signal is emitted when the user clicks with a mouse on top of box-and-whisker item.
91 */
91 */
92
92
93 /*!
93 /*!
94 \fn void QBoxSet::hovered(bool status)
94 \fn void QBoxSet::hovered(bool status)
95
95
96 The signal is emitted if mouse is hovered on top of box-and-whisker item.
96 The signal is emitted if mouse is hovered on top of box-and-whisker item.
97 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
97 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
98 */
98 */
99 /*!
99 /*!
100 \qmlsignal BoxSet::onHovered(bool status)
100 \qmlsignal BoxSet::onHovered(bool status)
101
101
102 The signal is emitted if mouse is hovered on top of box-and-whisker item.
102 The signal is emitted if mouse is hovered on top of box-and-whisker item.
103 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
103 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
104 */
104 */
105
105
106 /*!
106 /*!
107 \fn void QBoxSet::penChanged()
107 \fn void QBoxSet::penChanged()
108 This signal is emitted when the pen of the box-and-whisker item has changed.
108 This signal is emitted when the pen of the box-and-whisker item has changed.
109 \sa pen
109 \sa pen
110 */
110 */
111 /*!
111 /*!
112 \qmlsignal BoxSet::onPenChanged()
112 \qmlsignal BoxSet::onPenChanged()
113 This signal is emitted when the pen of the box-and-whisker item has changed.
113 This signal is emitted when the pen of the box-and-whisker item has changed.
114 */
114 */
115 /*!
115 /*!
116 \fn void QBoxSet::brushChanged()
116 \fn void QBoxSet::brushChanged()
117 This signal is emitted when the brush of the box-and-whisker item has changed.
117 This signal is emitted when the brush of the box-and-whisker item has changed.
118 \sa brush
118 \sa brush
119 */
119 */
120 /*!
120 /*!
121 \qmlsignal BoxSet::onBrushChanged()
121 \qmlsignal BoxSet::onBrushChanged()
122 This signal is emitted when the brush of the box-and-whisker item has changed.
122 This signal is emitted when the brush of the box-and-whisker item has changed.
123 */
123 */
124
124
125 /*!
125 /*!
126 \fn void QBoxSet::colorChanged(QColor)
127 This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color.
128 */
129 /*!
130 \qmlsignal BoxSet::onColorChanged(QColor color)
131 This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color.
132 */
133
134 /*!
135 \fn void QBoxSet::valuesChanged()
126 \fn void QBoxSet::valuesChanged()
136 This signal is emitted when multiple values have been changed on the box-and-whisker item.
127 This signal is emitted when multiple values have been changed on the box-and-whisker item.
137 \sa append()
128 \sa append()
138 */
129 */
139 /*!
130 /*!
140 \qmlsignal BoxSet::onChangedValues()
131 \qmlsignal BoxSet::onChangedValues()
141 This signal is emitted when multiple values have been changed on the box-and-whisker item.
132 This signal is emitted when multiple values have been changed on the box-and-whisker item.
142 */
133 */
143
134
144 /*!
135 /*!
145 \fn void QBoxSet::valueChanged(int index)
136 \fn void QBoxSet::valueChanged(int index)
146 This signal is emitted values the value in the box-and-whisker item has been modified.
137 This signal is emitted values the value in the box-and-whisker item has been modified.
147 Parameter \a index indicates the position of the modified value.
138 Parameter \a index indicates the position of the modified value.
148 \sa at()
139 \sa at()
149 */
140 */
150 /*!
141 /*!
151 \qmlsignal BoxSet::onChangedValue(int index)
142 \qmlsignal BoxSet::onChangedValue(int index)
152 This signal is emitted values the value in the box-and-whisker item has been modified.
143 This signal is emitted values the value in the box-and-whisker item has been modified.
153 Parameter \a index indicates the position of the modified value.
144 Parameter \a index indicates the position of the modified value.
154 */
145 */
155
146
156 /*!
147 /*!
157 \fn void QBoxSet::cleared()
148 \fn void QBoxSet::cleared()
158 This signal is emitted when all the values on the set are cleared to 0.
149 This signal is emitted when all the values on the set are cleared to 0.
159 */
150 */
160 /*!
151 /*!
161 \qmlsignal BoxSet::onCleared()
152 \qmlsignal BoxSet::onCleared()
162 This signal is emitted when all the values on the set are cleared to 0.
153 This signal is emitted when all the values on the set are cleared to 0.
163 */
154 */
164
155
165
156
166 /*!
157 /*!
167 Constructs QBoxSet with optional \a label and parent of \a parent
158 Constructs QBoxSet with optional \a label and parent of \a parent
168 */
159 */
169 QBoxSet::QBoxSet(const QString label, QObject *parent)
160 QBoxSet::QBoxSet(const QString label, QObject *parent)
170 : QObject(parent),
161 : QObject(parent),
171 d_ptr(new QBoxSetPrivate(label, this))
162 d_ptr(new QBoxSetPrivate(label, this))
172 {
163 {
173 }
164 }
174
165
175 /*!
166 /*!
176 Constructs QBoxSet with given ordered values. \a le for lower extreme, \a lq for lower quartile, \a m for median,
167 Constructs QBoxSet with given ordered values. \a le for lower extreme, \a lq for lower quartile, \a m for median,
177 \a uq for upper quartile and \a ue for upper quartile. \a label and \a parent are optional.
168 \a uq for upper quartile and \a ue for upper quartile. \a label and \a parent are optional.
178 */
169 */
179 QBoxSet::QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label, QObject *parent)
170 QBoxSet::QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label, QObject *parent)
180 : QObject(parent),
171 : QObject(parent),
181 d_ptr(new QBoxSetPrivate(label, this))
172 d_ptr(new QBoxSetPrivate(label, this))
182 {
173 {
183 d_ptr->append(le);
174 d_ptr->append(le);
184 d_ptr->append(lq);
175 d_ptr->append(lq);
185 d_ptr->append(m);
176 d_ptr->append(m);
186 d_ptr->append(uq);
177 d_ptr->append(uq);
187 d_ptr->append(ue);
178 d_ptr->append(ue);
188 }
179 }
189
180
190 /*!
181 /*!
191 Destroys the boxset
182 Destroys the boxset
192 */
183 */
193 QBoxSet::~QBoxSet()
184 QBoxSet::~QBoxSet()
194 {
185 {
195 }
186 }
196
187
197 /*!
188 /*!
198 Appends new value \a value to the end of set.
189 Appends new value \a value to the end of set.
199 */
190 */
200 void QBoxSet::append(const qreal value)
191 void QBoxSet::append(const qreal value)
201 {
192 {
202 if (d_ptr->append(value))
193 if (d_ptr->append(value))
203 emit valueChanged(d_ptr->m_appendCount - 1);
194 emit valueChanged(d_ptr->m_appendCount - 1);
204 }
195 }
205
196
206 /*!
197 /*!
207 Appends a list of reals to set. Works like append with single real value. The \a values in list
198 Appends a list of reals to set. Works like append with single real value. The \a values in list
208 are appended to end of boxset.
199 are appended to end of boxset.
209 \sa append()
200 \sa append()
210 */
201 */
211 void QBoxSet::append(const QList<qreal> &values)
202 void QBoxSet::append(const QList<qreal> &values)
212 {
203 {
213 if (d_ptr->append(values))
204 if (d_ptr->append(values))
214 emit valuesChanged();
205 emit valuesChanged();
215 }
206 }
216
207
217 /*!
208 /*!
218 Sets new \a label for set.
209 Sets new \a label for set.
219 */
210 */
220 void QBoxSet::setLabel(const QString label)
211 void QBoxSet::setLabel(const QString label)
221 {
212 {
222 d_ptr->m_label = label;
213 d_ptr->m_label = label;
223 }
214 }
224
215
225 /*!
216 /*!
226 Returns label of the set.
217 Returns label of the set.
227 */
218 */
228 QString QBoxSet::label() const
219 QString QBoxSet::label() const
229 {
220 {
230 return d_ptr->m_label;
221 return d_ptr->m_label;
231 }
222 }
232
223
233 /*!
224 /*!
234 Convenience operator. Same as append, with real \a value.
225 Convenience operator. Same as append, with real \a value.
235 \sa append()
226 \sa append()
236 */
227 */
237 QBoxSet &QBoxSet::operator << (const qreal &value)
228 QBoxSet &QBoxSet::operator << (const qreal &value)
238 {
229 {
239 append(value);
230 append(value);
240 return *this;
231 return *this;
241 }
232 }
242
233
243 /*!
234 /*!
244 Sets a new \a value on the \a index position. For \a index ValuePositions can be used.
235 Sets a new \a value on the \a index position. For \a index ValuePositions can be used.
245 */
236 */
246 void QBoxSet::setValue(const int index, const qreal value)
237 void QBoxSet::setValue(const int index, const qreal value)
247 {
238 {
248 d_ptr->setValue(index, value);
239 d_ptr->setValue(index, value);
249 emit valueChanged(index);
240 emit valueChanged(index);
250 }
241 }
251
242
252 /*!
243 /*!
253 Sets all values on the set to 0.
244 Sets all values on the set to 0.
254 */
245 */
255 void QBoxSet::clear()
246 void QBoxSet::clear()
256 {
247 {
257 d_ptr->clear();
248 d_ptr->clear();
258 emit cleared();
249 emit cleared();
259 }
250 }
260
251
261 /*!
252 /*!
262 Returns value of set indexed by \a index. For \a index ValuePositions can be used.
253 Returns value of set indexed by \a index. For \a index ValuePositions can be used.
263 If the index is out of bounds 0.0 is returned.
254 If the index is out of bounds 0.0 is returned.
264 */
255 */
265 qreal QBoxSet::at(const int index) const
256 qreal QBoxSet::at(const int index) const
266 {
257 {
267 if (index < 0 || index >= 5)
258 if (index < 0 || index >= 5)
268 return 0;
259 return 0;
269 return d_ptr->m_values[index];
260 return d_ptr->m_values[index];
270 }
261 }
271
262
272 /*!
263 /*!
273 Returns value of set indexed by \a index. For \a index ValuePositions can be used.
264 Returns value of set indexed by \a index. For \a index ValuePositions can be used.
274 If the index is out of bounds 0.0 is returned.
265 If the index is out of bounds 0.0 is returned.
275 */
266 */
276 qreal QBoxSet::operator [](const int index) const
267 qreal QBoxSet::operator [](const int index) const
277 {
268 {
278 return at(index);
269 return at(index);
279 }
270 }
280
271
281 /*!
272 /*!
282 Returns count of values appended to the set.
273 Returns count of values appended to the set.
283 */
274 */
284 int QBoxSet::count() const
275 int QBoxSet::count() const
285 {
276 {
286 return d_ptr->m_appendCount;
277 return d_ptr->m_appendCount;
287 }
278 }
288
279
289 /*!
280 /*!
290 Sets pen for set. Boxes of this set are drawn using \a pen
281 Sets pen for set. Boxes of this set are drawn using \a pen
291 */
282 */
292 void QBoxSet::setPen(const QPen &pen)
283 void QBoxSet::setPen(const QPen &pen)
293 {
284 {
294 if (d_ptr->m_pen != pen) {
285 if (d_ptr->m_pen != pen) {
295 d_ptr->m_pen = pen;
286 d_ptr->m_pen = pen;
296 emit d_ptr->updatedBox();
287 emit d_ptr->updatedBox();
297 emit penChanged();
288 emit penChanged();
298 }
289 }
299 }
290 }
300
291
301 /*!
292 /*!
302 Returns pen of the set.
293 Returns pen of the set.
303 */
294 */
304 QPen QBoxSet::pen() const
295 QPen QBoxSet::pen() const
305 {
296 {
306 return d_ptr->m_pen;
297 return d_ptr->m_pen;
307 }
298 }
308
299
309 /*!
300 /*!
310 Sets brush for the set. Boxes of this set are drawn using \a brush
301 Sets brush for the set. Boxes of this set are drawn using \a brush
311 */
302 */
312 void QBoxSet::setBrush(const QBrush &brush)
303 void QBoxSet::setBrush(const QBrush &brush)
313 {
304 {
314 if (d_ptr->m_brush != brush) {
305 if (d_ptr->m_brush != brush) {
315 d_ptr->m_brush = brush;
306 d_ptr->m_brush = brush;
316 emit d_ptr->updatedBox();
307 emit d_ptr->updatedBox();
317 emit brushChanged();
308 emit brushChanged();
318 }
309 }
319 }
310 }
320
311
321 /*!
312 /*!
322 Returns brush of the set.
313 Returns brush of the set.
323 */
314 */
324 QBrush QBoxSet::brush() const
315 QBrush QBoxSet::brush() const
325 {
316 {
326 return d_ptr->m_brush;
317 return d_ptr->m_brush;
327 }
318 }
328
319
329 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
320 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
330
321
331 QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(parent),
322 QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(parent),
332 q_ptr(parent),
323 q_ptr(parent),
333 m_label(label),
324 m_label(label),
334 m_valuesCount(5),
325 m_valuesCount(5),
335 m_appendCount(0),
326 m_appendCount(0),
336 m_pen(QPen(Qt::NoPen)),
327 m_pen(QPen(Qt::NoPen)),
337 m_brush(QBrush(Qt::NoBrush))
328 m_brush(QBrush(Qt::NoBrush))
338 {
329 {
339 m_values = new qreal[m_valuesCount];
330 m_values = new qreal[m_valuesCount];
340 }
331 }
341
332
342 QBoxSetPrivate::~QBoxSetPrivate()
333 QBoxSetPrivate::~QBoxSetPrivate()
343 {
334 {
344 }
335 }
345
336
346 bool QBoxSetPrivate::append(qreal value)
337 bool QBoxSetPrivate::append(qreal value)
347 {
338 {
348 if (isValidValue(value) && m_appendCount < m_valuesCount) {
339 if (isValidValue(value) && m_appendCount < m_valuesCount) {
349 m_values[m_appendCount++] = value;
340 m_values[m_appendCount++] = value;
350 emit restructuredBox();
341 emit restructuredBox();
351
342
352 return true;
343 return true;
353 }
344 }
354 return false;
345 return false;
355 }
346 }
356
347
357 bool QBoxSetPrivate::append(QList<qreal> values)
348 bool QBoxSetPrivate::append(QList<qreal> values)
358 {
349 {
359 bool success = false;
350 bool success = false;
360
351
361 for (int i = 0; i < values.count(); i++) {
352 for (int i = 0; i < values.count(); i++) {
362 if (isValidValue(values.at(i)) && m_appendCount < m_valuesCount) {
353 if (isValidValue(values.at(i)) && m_appendCount < m_valuesCount) {
363 success = true;
354 success = true;
364 m_values[m_appendCount++] = values.at(i);
355 m_values[m_appendCount++] = values.at(i);
365 }
356 }
366 }
357 }
367
358
368 if (success)
359 if (success)
369 emit restructuredBox();
360 emit restructuredBox();
370
361
371 return success;
362 return success;
372 }
363 }
373
364
374 void QBoxSetPrivate::clear()
365 void QBoxSetPrivate::clear()
375 {
366 {
376 m_appendCount = 0;
367 m_appendCount = 0;
377 for (int i = 0; i < m_valuesCount; i++)
368 for (int i = 0; i < m_valuesCount; i++)
378 m_values[i] = 0.0;
369 m_values[i] = 0.0;
379 emit restructuredBox();
370 emit restructuredBox();
380 }
371 }
381
372
382 void QBoxSetPrivate::setValue(const int index, const qreal value)
373 void QBoxSetPrivate::setValue(const int index, const qreal value)
383 {
374 {
384 if (index < m_valuesCount) {
375 if (index < m_valuesCount) {
385 m_values[index] = value;
376 m_values[index] = value;
386 emit updatedLayout();
377 emit updatedLayout();
387 }
378 }
388 }
379 }
389
380
390 qreal QBoxSetPrivate::value(const int index)
381 qreal QBoxSetPrivate::value(const int index)
391 {
382 {
392 if (index < 0 || index >= m_valuesCount)
383 if (index < 0 || index >= m_valuesCount)
393 return 0;
384 return 0;
394 return m_values[index];
385 return m_values[index];
395 }
386 }
396
387
397 #include "moc_qboxset.cpp"
388 #include "moc_qboxset.cpp"
398 #include "moc_qboxset_p.cpp"
389 #include "moc_qboxset_p.cpp"
399
390
400 QTCOMMERCIALCHART_END_NAMESPACE
391 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now