@@ -0,0 +1,30 | |||
|
1 | /*! | |
|
2 | \example examples/logvalueaxis | |
|
3 | \title Logarithmic axis example | |
|
4 | \subtitle | |
|
5 | ||
|
6 | The example shows how to use QLogValueAxis. | |
|
7 | ||
|
8 | \image examples_logvalueaxis.png | |
|
9 | ||
|
10 | Create QLineSeries instance and add some data to it. | |
|
11 | ||
|
12 | \snippet ../examples/logvalueaxis/main.cpp 1 | |
|
13 | ||
|
14 | To present the data on the char we need QChart instance. Add the series to it, hide the legend and set the title of the chart. | |
|
15 | ||
|
16 | \snippet ../examples/logvalueaxis/main.cpp 2 | |
|
17 | ||
|
18 | Create the axes. Add them to the chart and attach to the series. | |
|
19 | ||
|
20 | \snippet ../examples/logvalueaxis/main.cpp 3 | |
|
21 | ||
|
22 | Then create a QChartView object with QChart as a parameter. Enable antialiasing to have the rendered line look nicer. | |
|
23 | ||
|
24 | \snippet ../examples/logvalueaxis/main.cpp 4 | |
|
25 | ||
|
26 | Chart is ready to be shown. | |
|
27 | ||
|
28 | \snippet ../examples/logvalueaxis/main.cpp 5 | |
|
29 | ||
|
30 | */ |
@@ -0,0 +1,36 | |||
|
1 | /*! | |
|
2 | \example examples/multiaxis | |
|
3 | \title Multiple axes example | |
|
4 | \subtitle | |
|
5 | ||
|
6 | The example shows how to create simple chart with two vertical axes. One for each series. | |
|
7 | ||
|
8 | \image examples_multiaxis.png | |
|
9 | ||
|
10 | Create QChart instance, hide the legend of the chart and set its title. | |
|
11 | ||
|
12 | \snippet ../examples/multiaxis/main.cpp 1 | |
|
13 | ||
|
14 | Create a QValueAxis instance that will be used as a horizontal axis by both series and add it the bottom of the chart. | |
|
15 | Axis can be sharted between many series, but each series can have only one vertical and horizontal axis. | |
|
16 | ||
|
17 | \snippet ../examples/multiaxis/main.cpp 2 | |
|
18 | ||
|
19 | Create the first series, add the data to it, finally add the series to the chart. Instantiate its own Y-axis, add it to the chart then attach both the common X-axis and the series specific Y-axis. | |
|
20 | In this example the color of the axis line is set to be the same as the color of the series to make it possible to distinguish which axis is attached to which series. | |
|
21 | ||
|
22 | \snippet ../examples/multiaxis/main.cpp 3 | |
|
23 | ||
|
24 | Similarly prepare another series. This time different axis type is used. Additionally grid lines color is also set to be the same as the color of the series. | |
|
25 | ||
|
26 | \snippet ../examples/multiaxis/main.cpp 4 | |
|
27 | ||
|
28 | Create a QChartView object with QChart as a parameter. Enanle Antialiasing to have the rendered splines look nicer. | |
|
29 | ||
|
30 | \snippet ../examples/multiaxis/main.cpp 5 | |
|
31 | ||
|
32 | Chart is ready to be shown. | |
|
33 | ||
|
34 | \snippet ../examples/multiaxis/main.cpp 6 | |
|
35 | ||
|
36 | */ |
@@ -1,128 +1,137 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page examples.html |
|
3 | 3 | \keyword Examples |
|
4 | 4 | |
|
5 | 5 | \raw HTML |
|
6 | 6 | <div class="qchart"> |
|
7 | 7 | |
|
8 | 8 | <table> |
|
9 | 9 | <tr> |
|
10 | 10 | <td><a href="examples-areachart.html">Area Chart</a></td> |
|
11 | 11 | <td><a href="examples-barchart.html">Bar Chart</a></td> |
|
12 | 12 | </tr> |
|
13 | 13 | <tr> |
|
14 | 14 | <td><a href="examples-areachart.html"><img src="images/examples_areachart.png" width="300" alt="Area Chart" /></a></td> |
|
15 | 15 | <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="300" alt="Bar Chart" /></a></td> |
|
16 | 16 | </tr> |
|
17 | 17 | |
|
18 | 18 | <tr> |
|
19 | 19 | <td><a href="examples-barmodelmapper.html">Bar Chart from Model</a></td> |
|
20 | 20 | <td><a href="examples-customchart.html">Custom Chart</a></td> |
|
21 | 21 | </tr> |
|
22 | 22 | <tr> |
|
23 | 23 | <td><a href="examples-barmodelmapper.html"><img src="images/examples_barmodelmapper.png" width="300" alt="Bar Chart from Model" /></a></td> |
|
24 | 24 | <td><a href="examples-customchart.html"><img src="images/examples_customchart.png" width="300" alt="Custom Chart" /></a></td> |
|
25 | 25 | </tr> |
|
26 | 26 | |
|
27 | 27 | <tr> |
|
28 | 28 | <td><a href="examples-datetimeaxis.html">DateTimeAxis Example</a></td> |
|
29 | 29 | <td><a href="examples-donutbreakdown.html">Donut Breakdown Chart</a></td> |
|
30 | 30 | </tr> |
|
31 | 31 | <tr> |
|
32 | 32 | <td><a href="examples-datetimeaxis.html"><img src="images/examples_datetimeaxis.png" width="300" alt="DateTimeAxis Example" /></a></td> |
|
33 | 33 | <td><a href="examples-donutbreakdown.html"><img src="images/examples_donutbreakdown.png" width="300" alt="Donut Breakdown Chart" /></a></td> |
|
34 | 34 | </tr> |
|
35 | 35 | |
|
36 | 36 | <tr> |
|
37 | 37 | <td><a href="examples-donutchart.html">Donut Chart</a></td> |
|
38 | 38 | <td><a href="examples-horizontalbarchart.html">Horizontal Bar Chart</a></td> |
|
39 | 39 | </tr> |
|
40 | 40 | <tr> |
|
41 | 41 | <td><a href="examples-donutchart.html"><img src="images/examples_donutchart.png" width="300" alt="Donut Chart" /></a></td> |
|
42 | 42 | <td><a href="examples-horizontalbarchart.html"><img src="images/examples_horizontalbarchart.png" width="300" alt="Horizontal Bar Chart" /></a></td> |
|
43 | 43 | </tr> |
|
44 | 44 | |
|
45 | 45 | <tr> |
|
46 | 46 | <td><a href="examples-horizontalpercentbarchart.html">Horizontal Percent Bar Chart</a></td> |
|
47 | 47 | <td><a href="examples-horizontalstackedbarchart.html">Horizontal Stacked Bar Chart</a></td> |
|
48 | 48 | </tr> |
|
49 | 49 | <tr> |
|
50 | 50 | <td><a href="examples-horizontalpercentbarchart.html"><img src="images/examples_horizontalpercentbarchart.png" width="300" alt="Horizontal Percent Bar Chart" /></a></td> |
|
51 | 51 | <td><a href="examples-horizontalstackedbarchart.html"><img src="images/examples_horizontalstackedbarchart.png" width="300" alt="Horizontal Stacked Bar Chart" /></a></td> |
|
52 | 52 | </tr> |
|
53 | 53 | |
|
54 | 54 | <tr> |
|
55 | 55 | <td><a href="examples-legend.html">Legend</a></td> |
|
56 | 56 | <td><a href="examples-legendmarkers.html">Legend Markers</a></td> |
|
57 | 57 | </tr> |
|
58 | 58 | <tr> |
|
59 | 59 | <td><a href="examples-legend.html"><img src="images/examples_legend_detach.png" width="300" alt="Legend" /></a></td> |
|
60 | 60 | <td><a href="examples-legendmarkers.html"><img src="images/examples_legendmarkers.png" width="300" alt="Legend Markers" /></a></td> |
|
61 | 61 | </tr> |
|
62 | 62 | |
|
63 | 63 | <tr> |
|
64 | 64 | <td><a href="examples-lineandbar.html">Line and Barchart</a></td> |
|
65 | 65 | <td><a href="examples-linechart.html">Line Chart</a></td> |
|
66 | 66 | </tr> |
|
67 | 67 | <tr> |
|
68 | 68 | <td><a href="examples-lineandbar.html"><img src="images/examples_lineandbar.png" width="300" alt="Line and Barchart" /></a></td> |
|
69 | 69 | <td><a href="examples-linechart.html"><img src="images/examples_linechart.png" width="300" alt="Line Chart" /></a></td> |
|
70 | 70 | </tr> |
|
71 | 71 | |
|
72 | 72 | <tr> |
|
73 | <td><a href="examples-logvalueaxis.html">Logarythmic axis</a></td> | |
|
73 | 74 | <td><a href="examples-modeldata.html">Model Data</a></td> |
|
74 | <td><a href="examples-percentbarchart.html">Percent Bar Chart</a></td> | |
|
75 | 75 | </tr> |
|
76 | 76 | <tr> |
|
77 | <td><a href="examples-logvalueaxis.html"><img src="images/examples_logvalueaxis.png" width="300" alt="Logarythmix axis" /></a></td> | |
|
77 | 78 | <td><a href="examples-modeldata.html"><img src="images/examples_modeldata.png" width="300" alt="Model Data" /></a></td> |
|
79 | </tr> | |
|
80 | ||
|
81 | <tr> | |
|
82 | <td><a href="examples-multiaxis.html">Multiple axes</a></td> | |
|
83 | <td><a href="examples-percentbarchart.html">Percent Bar Chart</a></td> | |
|
84 | </tr> | |
|
85 | <tr> | |
|
86 | <td><a href="examples-multiaxis.html"><img src="images/examples_multiaxis.png" width="300" alt="Multiple axes" /></a></td> | |
|
78 | 87 | <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="300" alt="Percent Bar Chart" /></a></td> |
|
79 | 88 | </tr> |
|
80 | 89 | |
|
81 | 90 | <tr> |
|
82 | 91 | <td><a href="examples-piechart.html">Pie Chart</a></td> |
|
83 | 92 | <td><a href="examples-piechartdrilldown.html">Pie Chart Drilldown</a></td> |
|
84 | 93 | </tr> |
|
85 | 94 | <tr> |
|
86 | 95 | <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="300" alt="Pie Chart" /></a></td> |
|
87 | 96 | <td><a href="examples-piechartdrilldown.html"><img src="images/examples_piechartdrill2.png" width="300" alt="Pie Chart Drilldown" /></a></td> |
|
88 | 97 | </tr> |
|
89 | 98 | |
|
90 | 99 | <tr> |
|
91 | 100 | <td><a href="examples-scatterchart.html">Scatter chart</a></td> |
|
92 | 101 | <td><a href="examples-scatterinteractions.html">Scatter Interactions</a></td> |
|
93 | 102 | </tr> |
|
94 | 103 | <tr> |
|
95 | 104 | <td><a href="examples-scatterchart.html"><img src="images/examples_scatterchart.png" width="300" alt="Scatter chart" /></a></td> |
|
96 | 105 | <td><a href="examples-scatterinteractions.html"><img src="images/examples_scatterinteractions.png" width="300" alt="Scatter Interactions" /></a></td> |
|
97 | 106 | </tr> |
|
98 | 107 | |
|
99 | 108 | <tr> |
|
100 | 109 | <td><a href="examples-splinechart.html">Spline Chart</a></td> |
|
101 | 110 | <td><a href="examples-stackedbarchart.html">Stacked Bar Chart</a></td> |
|
102 | 111 | </tr> |
|
103 | 112 | <tr> |
|
104 | 113 | <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="300" alt="Spline Chart" /></a></td> |
|
105 | 114 | <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="300" alt="Stacked Bar Chart" /></a></td> |
|
106 | 115 | </tr> |
|
107 | 116 | |
|
108 | 117 | <tr> |
|
109 | 118 | <td><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown</a></td> |
|
110 | 119 | <td><a href="examples-temperaturerecords.html">Temperature Records</a></td> |
|
111 | 120 | </tr> |
|
112 | 121 | <tr> |
|
113 | 122 | <td><a href="examples-stackedbarchartdrilldown.html"><img src="images/examples_stackedbarchartdrilldown1.png" width="300" alt="Stacked Bar Chart Drilldown" /></a></td> |
|
114 | 123 | <td><a href="examples-temperaturerecords.html"><img src="images/examples_temperaturerecords.png" width="300" alt="Temperature Records" /></a></td> |
|
115 | 124 | </tr> |
|
116 | 125 | |
|
117 | 126 | <tr> |
|
118 | 127 | <td><a href="examples-zoomlinechart.html">Zoom Line</a></td> |
|
119 | 128 | </tr> |
|
120 | 129 | <tr> |
|
121 | 130 | <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart1.png" width="300" alt="Zoom Line" /></a></td> |
|
122 | 131 | </tr> |
|
123 | 132 | |
|
124 | 133 | </table> |
|
125 | 134 | </div> |
|
126 | 135 | \endraw |
|
127 | 136 | |
|
128 | 137 | */ |
@@ -1,74 +1,75 | |||
|
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 <QApplication> |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QLineSeries> |
|
25 | 25 | #include <QValueAxis> |
|
26 | 26 | #include <QLogValueAxis> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | int main(int argc, char *argv[]) |
|
31 | 31 | { |
|
32 | 32 | QApplication a(argc, argv); |
|
33 | 33 | |
|
34 | 34 | //![1] |
|
35 | 35 | QLineSeries *series = new QLineSeries(); |
|
36 | 36 | *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723); |
|
37 | 37 | //![1] |
|
38 | 38 | |
|
39 |
//![ |
|
|
39 | //![2] | |
|
40 | 40 | QChart *chart = new QChart(); |
|
41 | 41 | chart->addSeries(series); |
|
42 | 42 | chart->legend()->hide(); |
|
43 |
chart->setTitle(" |
|
|
44 |
//![ |
|
|
43 | chart->setTitle("Logarithmic axis example"); | |
|
44 | //![2] | |
|
45 | 45 | |
|
46 |
//![ |
|
|
46 | //![3] | |
|
47 | 47 | QValueAxis *axisX = new QValueAxis; |
|
48 | 48 | axisX->setTitleText("Data point"); |
|
49 | 49 | axisX->setTickCount(6); |
|
50 | 50 | axisX->setLabelFormat("%i"); |
|
51 | 51 | chart->addAxis(axisX, Qt::AlignBottom); |
|
52 | 52 | series->attachAxis(axisX); |
|
53 | 53 | |
|
54 | 54 | QLogValueAxis *axisY = new QLogValueAxis; |
|
55 | 55 | axisY->setLabelFormat("%g"); |
|
56 | 56 | axisY->setTitleText("Values"); |
|
57 | axisY->setBase(8); | |
|
57 | 58 | chart->addAxis(axisY, Qt::AlignLeft); |
|
58 | 59 | series->attachAxis(axisY); |
|
59 |
//![ |
|
|
60 | //![3] | |
|
60 | 61 | |
|
61 |
//![ |
|
|
62 | //![4] | |
|
62 | 63 | QChartView *chartView = new QChartView(chart); |
|
63 | 64 | chartView->setRenderHint(QPainter::Antialiasing); |
|
64 |
//![ |
|
|
65 | //![4] | |
|
65 | 66 | |
|
66 | 67 | //![6] |
|
67 | 68 | QMainWindow window; |
|
68 | 69 | window.setCentralWidget(chartView); |
|
69 | 70 | window.resize(400, 300); |
|
70 | 71 | window.show(); |
|
71 | 72 | //![6] |
|
72 | 73 | |
|
73 | 74 | return a.exec(); |
|
74 | 75 | } |
@@ -1,90 +1,92 | |||
|
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 <QApplication> |
|
22 | 22 | #include <QMainWindow> |
|
23 | 23 | #include <QChartView> |
|
24 | 24 | #include <QLineSeries> |
|
25 | 25 | #include <QSplineSeries> |
|
26 | 26 | #include <QValueAxis> |
|
27 | 27 | #include <QCategoryAxis> |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | int main(int argc, char *argv[]) |
|
32 | 32 | { |
|
33 | 33 | QApplication a(argc, argv); |
|
34 | 34 | |
|
35 | 35 | //![1] |
|
36 | QChart *chart = new QChart(); | |
|
36 | QChart *chart = new QChart(); | |
|
37 | chart->legend()->hide(); | |
|
38 | chart->setTitle("Multiaxis chart example"); | |
|
39 | //![1] | |
|
40 | ||
|
41 | //![2] | |
|
37 | 42 | QValueAxis *axisX = new QValueAxis; |
|
38 | 43 | axisX->setTickCount(10); |
|
44 | chart->addAxis(axisX, Qt::AlignBottom); | |
|
45 | //![2] | |
|
39 | 46 | |
|
47 | //![3] | |
|
40 | 48 | QSplineSeries *series = new QSplineSeries; |
|
41 | 49 | *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5); |
|
42 | 50 | chart->addSeries(series); |
|
43 | 51 | |
|
44 | 52 | QValueAxis *axisY = new QValueAxis; |
|
45 | 53 | axisY->setLinePenColor(series->pen().color()); |
|
46 | 54 | |
|
47 | chart->addAxis(axisX, Qt::AlignBottom); | |
|
48 | 55 | chart->addAxis(axisY, Qt::AlignLeft); |
|
49 | 56 | series->attachAxis(axisX); |
|
50 | 57 | series->attachAxis(axisY); |
|
58 | //![3] | |
|
51 | 59 | |
|
60 | //![4] | |
|
52 | 61 | series = new QSplineSeries; |
|
53 | 62 | *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5) |
|
54 | 63 | << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17); |
|
55 | 64 | chart->addSeries(series); |
|
56 | 65 | |
|
57 | 66 | QCategoryAxis *axisY3 = new QCategoryAxis; |
|
58 | 67 | axisY3->append("Low", 5); |
|
59 | 68 | axisY3->append("Medium", 12); |
|
60 | 69 | axisY3->append("High", 17); |
|
61 | 70 | axisY3->setLinePenColor(series->pen().color()); |
|
62 | 71 | axisY3->setGridLinePen((series->pen())); |
|
63 | 72 | |
|
64 | 73 | chart->addAxis(axisY3, Qt::AlignRight); |
|
65 | 74 | series->attachAxis(axisX); |
|
66 | 75 | series->attachAxis(axisY3); |
|
67 | ||
|
68 | //![2] | |
|
69 | ||
|
70 | //![3] | |
|
71 | chart->legend()->hide(); | |
|
72 | chart->setTitle("Multiaxis chart example"); | |
|
73 | //![3] | |
|
74 | ||
|
75 | 76 | //![4] |
|
77 | ||
|
78 | //![5] | |
|
76 | 79 | QChartView *chartView = new QChartView(chart); |
|
77 | 80 | chartView->setRenderHint(QPainter::Antialiasing); |
|
78 | //![4] | |
|
79 | ||
|
80 | ||
|
81 | 81 | //![5] |
|
82 | ||
|
83 | //![6] | |
|
82 | 84 | QMainWindow window; |
|
83 | 85 | window.setCentralWidget(chartView); |
|
84 | 86 | window.resize(800, 600); |
|
85 | 87 | window.show(); |
|
86 |
//![ |
|
|
88 | //![6] | |
|
87 | 89 | |
|
88 | 90 | return a.exec(); |
|
89 | 91 | } |
|
90 | 92 |
General Comments 0
You need to be logged in to leave comments.
Login now