@@ -6,15 +6,15 project = QtCommercialCharts | |||
|
6 | 6 | description = Library for creating charts |
|
7 | 7 | |
|
8 | 8 | sourcedirs = ../src \ |
|
9 | ../example \ | |
|
9 | ../examples \ | |
|
10 | 10 | ./src |
|
11 | 11 | headerdirs = ../src \ |
|
12 | ../example | |
|
12 | ../examples | |
|
13 | 13 | exampledirs = ../ \ |
|
14 | 14 | ../src \ |
|
15 | ../example | |
|
15 | ../examples | |
|
16 | 16 | |
|
17 | excludefiles += ../example/linechart/linechart.pro | |
|
17 | excludefiles += ../examples/linechart/linechart.pro | |
|
18 | 18 | |
|
19 | 19 | sources.fileextensions = *.cpp *.qdoc *.mm *.qml |
|
20 | 20 | headers.fileextensions = *.h *.ch *.h++ *.hh *.hpp *.hxx |
@@ -9,22 +9,22 | |||
|
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 | \snippet ../example/areachart/main.cpp 1 | |
|
12 | \snippet ../examples/areachart/main.cpp 1 | |
|
13 | 13 | |
|
14 | 14 | We add data to both series, we use stream operator. |
|
15 | 15 | |
|
16 | \snippet ../example/areachart/main.cpp 2 | |
|
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 | \snippet ../example/areachart/main.cpp 3 | |
|
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 | \snippet ../example/areachart/main.cpp 4 | |
|
24 | \snippet ../examples/areachart/main.cpp 4 | |
|
25 | 25 | |
|
26 | 26 | Chart is ready to be shown. |
|
27 | 27 | |
|
28 | \snippet ../example/areachart/main.cpp 5 | |
|
28 | \snippet ../examples/areachart/main.cpp 5 | |
|
29 | 29 | |
|
30 | 30 | */ No newline at end of file |
@@ -9,18 +9,18 | |||
|
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 | \snippet ../example/linechart/main.cpp 1 | |
|
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 | \snippet ../example/linechart/main.cpp 2 | |
|
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 | \snippet ../example/linechart/main.cpp 3 | |
|
20 | \snippet ../examples/linechart/main.cpp 3 | |
|
21 | 21 | |
|
22 | 22 | Chart is ready to be shown. |
|
23 | 23 | |
|
24 | \snippet ../example/linechart/main.cpp 4 | |
|
24 | \snippet ../examples/linechart/main.cpp 4 | |
|
25 | 25 | |
|
26 | 26 | */ No newline at end of file |
@@ -13,25 +13,25 | |||
|
13 | 13 | |
|
14 | 14 | We create simple ChartView class which derives form QChartView. |
|
15 | 15 | |
|
16 | \snippet ../example/presenterchart/chartview.h 1 | |
|
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 | \snippet ../example/presenterchart/chartview.cpp 1 | |
|
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 | \snippet ../example/presenterchart/chartview.cpp 2 | |
|
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 | \snippet ../example/presenterchart/chartview.cpp 3 | |
|
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 | \snippet ../example/presenterchart/chartview.cpp 4 | |
|
35 | \snippet ../examples/presenterchart/chartview.cpp 4 | |
|
36 | 36 | |
|
37 | 37 | */ No newline at end of file |
@@ -9,18 +9,18 | |||
|
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 | \snippet ../example/scatterchart/main.cpp 1 | |
|
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 | \snippet ../example/scatterchart/main.cpp 2 | |
|
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 | \snippet ../example/scatterchart/main.cpp 3 | |
|
20 | \snippet ../examples/scatterchart/main.cpp 3 | |
|
21 | 21 | |
|
22 | 22 | Chart is ready to be shown. |
|
23 | 23 | |
|
24 | \snippet ../example/scatterchart/main.cpp 4 | |
|
24 | \snippet ../examples/scatterchart/main.cpp 4 | |
|
25 | 25 | |
|
26 | 26 | */ No newline at end of file |
@@ -9,34 +9,34 | |||
|
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 | \snippet ../example/splinechart/splinewidget.cpp 1 | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp 2 | |
|
16 | \snippet ../examples/splinechart/splinewidget.cpp 2 | |
|
17 | 17 | |
|
18 | 18 | Now lets add some data points to the series. |
|
19 | 19 | |
|
20 | \snippet ../example/splinechart/splinewidget.cpp add points to series | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp 3 | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp 4 | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp 5 | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp add point | |
|
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 | \snippet ../example/splinechart/splinewidget.cpp remove point | |
|
40 | \snippet ../examples/splinechart/splinewidget.cpp remove point | |
|
41 | 41 | |
|
42 | 42 | */ |
@@ -4,23 +4,23 | |||
|
4 | 4 | \keyword Tutorials |
|
5 | 5 | |
|
6 | 6 | For example, to create a chart with line series using a widget based application: |
|
7 | \snippet ../example/chartview/main.cpp 1 | |
|
7 | \snippet ../examples/chartview/main.cpp 1 | |
|
8 | 8 | \image chartview_example.jpg |
|
9 | 9 | |
|
10 | 10 | To replace the line series with a pie series you use the dedicated QPieSeries class: |
|
11 | \snippet ../example/chartview/main.cpp 3 | |
|
11 | \snippet ../examples/chartview/main.cpp 3 | |
|
12 | 12 | \image chartview_example_pie.jpg |
|
13 | 13 | |
|
14 | 14 | To use a scatter series you use QScatterSeries class: |
|
15 | \snippet ../example/chartview/main.cpp 4 | |
|
15 | \snippet ../examples/chartview/main.cpp 4 | |
|
16 | 16 | \image chartview_example_scatter.jpg |
|
17 | 17 | |
|
18 | 18 | And to show a bar series you use one of the bar series classes, for example QBarChartSeries: |
|
19 | \snippet ../example/chartview/main.cpp 5 | |
|
19 | \snippet ../examples/chartview/main.cpp 5 | |
|
20 | 20 | \image chartview_example_bar.jpg |
|
21 | 21 | |
|
22 | 22 | If you need to give a more professional touch to your chart you can switch from the default |
|
23 | 23 | theme to one of the other themes: |
|
24 | \snippet ../example/chartview/main.cpp 2 | |
|
24 | \snippet ../examples/chartview/main.cpp 2 | |
|
25 | 25 | \image chartview_example_theme.jpg |
|
26 | 26 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now