@@ -1,5 +1,5 | |||
|
1 | 1 | /*! |
|
2 | \example example/barchart | |
|
2 | \example examples/barchart | |
|
3 | 3 | \title BarChart Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
@@ -9,31 +9,31 | |||
|
9 | 9 | |
|
10 | 10 | First we define categories. |
|
11 | 11 | |
|
12 | \snippet ../example/barchart/main.cpp 1 | |
|
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 | \snippet ../example/barchart/main.cpp 2 | |
|
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 | \snippet ../example/barchart/main.cpp 3 | |
|
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 | \snippet ../example/barchart/main.cpp 4 | |
|
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 | \snippet ../example/barchart/main.cpp 5 | |
|
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 | \snippet ../example/barchart/main.cpp 6 | |
|
38 | \snippet ../examples/barchart/main.cpp 6 | |
|
39 | 39 | */ No newline at end of file |
@@ -1,5 +1,5 | |||
|
1 | 1 | /*! |
|
2 | \example example/percentbarchart | |
|
2 | \example examples/percentbarchart | |
|
3 | 3 | \title PercentBarChart Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
@@ -9,31 +9,31 | |||
|
9 | 9 | |
|
10 | 10 | First we define categories. |
|
11 | 11 | |
|
12 | \snippet ../example/percentbarchart/main.cpp 1 | |
|
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 | \snippet ../example/percentbarchart/main.cpp 2 | |
|
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 | \snippet ../example/percentbarchart/main.cpp 3 | |
|
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 | \snippet ../example/percentbarchart/main.cpp 4 | |
|
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 | \snippet ../example/percentbarchart/main.cpp 5 | |
|
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 | \snippet ../example/percentbarchart/main.cpp 6 | |
|
38 | \snippet ../examples/percentbarchart/main.cpp 6 | |
|
39 | 39 | */ No newline at end of file |
@@ -1,5 +1,5 | |||
|
1 | 1 | /*! |
|
2 | \example example/stackedbarchartdrilldown | |
|
2 | \example examples/stackedbarchartdrilldown | |
|
3 | 3 | \title StackedBarChart Drilldown Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
@@ -14,29 +14,29 | |||
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 1 | |
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 2 | |
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 3 | |
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 4 | |
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 5 | |
|
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 | \snippet ../example/stackedbarchartdrilldown/main.cpp 6 | |
|
41 | \snippet ../examples/stackedbarchartdrilldown/main.cpp 6 | |
|
42 | 42 | */ No newline at end of file |
@@ -9,31 +9,31 | |||
|
9 | 9 | |
|
10 | 10 | First we define categories. |
|
11 | 11 | |
|
12 | \snippet ../example/stackedbarchart/main.cpp 1 | |
|
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 | \snippet ../example/stackedbarchart/main.cpp 2 | |
|
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 | \snippet ../example/stackedbarchart/main.cpp 3 | |
|
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 | \snippet ../example/stackedbarchart/main.cpp 4 | |
|
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 | \snippet ../example/stackedbarchart/main.cpp 5 | |
|
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 | \snippet ../example/stackedbarchart/main.cpp 6 | |
|
38 | \snippet ../examples/stackedbarchart/main.cpp 6 | |
|
39 | 39 | */ No newline at end of file |
@@ -109,6 +109,9 void QBarSet::setValue(int index, qreal value) | |||
|
109 | 109 | mValues.replace(index,value); |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | /*! | |
|
113 | Returns total sum of all values in barset. | |
|
114 | */ | |
|
112 | 115 | qreal QBarSet::total() |
|
113 | 116 | { |
|
114 | 117 | qreal total(0); |
@@ -118,7 +121,6 qreal QBarSet::total() | |||
|
118 | 121 | return total; |
|
119 | 122 | } |
|
120 | 123 | |
|
121 | ||
|
122 | 124 | /*! |
|
123 | 125 | Sets pen for set. Bars of this set are drawn using \a pen |
|
124 | 126 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now