##// END OF EJS Templates
logvalueaxis and multiaxis examples documented
Marek Rosa -
r2374:01d2a7083c00
parent child
Show More
@@ -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 \page examples.html
2 \page examples.html
3 \keyword Examples
3 \keyword Examples
4
4
5 \raw HTML
5 \raw HTML
6 <div class="qchart">
6 <div class="qchart">
7
7
8 <table>
8 <table>
9 <tr>
9 <tr>
10 <td><a href="examples-areachart.html">Area Chart</a></td>
10 <td><a href="examples-areachart.html">Area Chart</a></td>
11 <td><a href="examples-barchart.html">Bar Chart</a></td>
11 <td><a href="examples-barchart.html">Bar Chart</a></td>
12 </tr>
12 </tr>
13 <tr>
13 <tr>
14 <td><a href="examples-areachart.html"><img src="images/examples_areachart.png" width="300" alt="Area Chart" /></a></td>
14 <td><a href="examples-areachart.html"><img src="images/examples_areachart.png" width="300" alt="Area Chart" /></a></td>
15 <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="300" alt="Bar Chart" /></a></td>
15 <td><a href="examples-barchart.html"><img src="images/examples_barchart.png" width="300" alt="Bar Chart" /></a></td>
16 </tr>
16 </tr>
17
17
18 <tr>
18 <tr>
19 <td><a href="examples-barmodelmapper.html">Bar Chart from Model</a></td>
19 <td><a href="examples-barmodelmapper.html">Bar Chart from Model</a></td>
20 <td><a href="examples-customchart.html">Custom Chart</a></td>
20 <td><a href="examples-customchart.html">Custom Chart</a></td>
21 </tr>
21 </tr>
22 <tr>
22 <tr>
23 <td><a href="examples-barmodelmapper.html"><img src="images/examples_barmodelmapper.png" width="300" alt="Bar Chart from Model" /></a></td>
23 <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-customchart.html"><img src="images/examples_customchart.png" width="300" alt="Custom Chart" /></a></td>
24 <td><a href="examples-customchart.html"><img src="images/examples_customchart.png" width="300" alt="Custom Chart" /></a></td>
25 </tr>
25 </tr>
26
26
27 <tr>
27 <tr>
28 <td><a href="examples-datetimeaxis.html">DateTimeAxis Example</a></td>
28 <td><a href="examples-datetimeaxis.html">DateTimeAxis Example</a></td>
29 <td><a href="examples-donutbreakdown.html">Donut Breakdown Chart</a></td>
29 <td><a href="examples-donutbreakdown.html">Donut Breakdown Chart</a></td>
30 </tr>
30 </tr>
31 <tr>
31 <tr>
32 <td><a href="examples-datetimeaxis.html"><img src="images/examples_datetimeaxis.png" width="300" alt="DateTimeAxis Example" /></a></td>
32 <td><a href="examples-datetimeaxis.html"><img src="images/examples_datetimeaxis.png" width="300" alt="DateTimeAxis Example" /></a></td>
33 <td><a href="examples-donutbreakdown.html"><img src="images/examples_donutbreakdown.png" width="300" alt="Donut Breakdown Chart" /></a></td>
33 <td><a href="examples-donutbreakdown.html"><img src="images/examples_donutbreakdown.png" width="300" alt="Donut Breakdown Chart" /></a></td>
34 </tr>
34 </tr>
35
35
36 <tr>
36 <tr>
37 <td><a href="examples-donutchart.html">Donut Chart</a></td>
37 <td><a href="examples-donutchart.html">Donut Chart</a></td>
38 <td><a href="examples-horizontalbarchart.html">Horizontal Bar Chart</a></td>
38 <td><a href="examples-horizontalbarchart.html">Horizontal Bar Chart</a></td>
39 </tr>
39 </tr>
40 <tr>
40 <tr>
41 <td><a href="examples-donutchart.html"><img src="images/examples_donutchart.png" width="300" alt="Donut Chart" /></a></td>
41 <td><a href="examples-donutchart.html"><img src="images/examples_donutchart.png" width="300" alt="Donut Chart" /></a></td>
42 <td><a href="examples-horizontalbarchart.html"><img src="images/examples_horizontalbarchart.png" width="300" alt="Horizontal Bar Chart" /></a></td>
42 <td><a href="examples-horizontalbarchart.html"><img src="images/examples_horizontalbarchart.png" width="300" alt="Horizontal Bar Chart" /></a></td>
43 </tr>
43 </tr>
44
44
45 <tr>
45 <tr>
46 <td><a href="examples-horizontalpercentbarchart.html">Horizontal Percent Bar Chart</a></td>
46 <td><a href="examples-horizontalpercentbarchart.html">Horizontal Percent Bar Chart</a></td>
47 <td><a href="examples-horizontalstackedbarchart.html">Horizontal Stacked Bar Chart</a></td>
47 <td><a href="examples-horizontalstackedbarchart.html">Horizontal Stacked Bar Chart</a></td>
48 </tr>
48 </tr>
49 <tr>
49 <tr>
50 <td><a href="examples-horizontalpercentbarchart.html"><img src="images/examples_horizontalpercentbarchart.png" width="300" alt="Horizontal Percent Bar Chart" /></a></td>
50 <td><a href="examples-horizontalpercentbarchart.html"><img src="images/examples_horizontalpercentbarchart.png" width="300" alt="Horizontal Percent Bar Chart" /></a></td>
51 <td><a href="examples-horizontalstackedbarchart.html"><img src="images/examples_horizontalstackedbarchart.png" width="300" alt="Horizontal Stacked Bar Chart" /></a></td>
51 <td><a href="examples-horizontalstackedbarchart.html"><img src="images/examples_horizontalstackedbarchart.png" width="300" alt="Horizontal Stacked Bar Chart" /></a></td>
52 </tr>
52 </tr>
53
53
54 <tr>
54 <tr>
55 <td><a href="examples-legend.html">Legend</a></td>
55 <td><a href="examples-legend.html">Legend</a></td>
56 <td><a href="examples-legendmarkers.html">Legend Markers</a></td>
56 <td><a href="examples-legendmarkers.html">Legend Markers</a></td>
57 </tr>
57 </tr>
58 <tr>
58 <tr>
59 <td><a href="examples-legend.html"><img src="images/examples_legend_detach.png" width="300" alt="Legend" /></a></td>
59 <td><a href="examples-legend.html"><img src="images/examples_legend_detach.png" width="300" alt="Legend" /></a></td>
60 <td><a href="examples-legendmarkers.html"><img src="images/examples_legendmarkers.png" width="300" alt="Legend Markers" /></a></td>
60 <td><a href="examples-legendmarkers.html"><img src="images/examples_legendmarkers.png" width="300" alt="Legend Markers" /></a></td>
61 </tr>
61 </tr>
62
62
63 <tr>
63 <tr>
64 <td><a href="examples-lineandbar.html">Line and Barchart</a></td>
64 <td><a href="examples-lineandbar.html">Line and Barchart</a></td>
65 <td><a href="examples-linechart.html">Line Chart</a></td>
65 <td><a href="examples-linechart.html">Line Chart</a></td>
66 </tr>
66 </tr>
67 <tr>
67 <tr>
68 <td><a href="examples-lineandbar.html"><img src="images/examples_lineandbar.png" width="300" alt="Line and Barchart" /></a></td>
68 <td><a href="examples-lineandbar.html"><img src="images/examples_lineandbar.png" width="300" alt="Line and Barchart" /></a></td>
69 <td><a href="examples-linechart.html"><img src="images/examples_linechart.png" width="300" alt="Line Chart" /></a></td>
69 <td><a href="examples-linechart.html"><img src="images/examples_linechart.png" width="300" alt="Line Chart" /></a></td>
70 </tr>
70 </tr>
71
71
72 <tr>
72 <tr>
73 <td><a href="examples-logvalueaxis.html">Logarythmic axis</a></td>
73 <td><a href="examples-modeldata.html">Model Data</a></td>
74 <td><a href="examples-modeldata.html">Model Data</a></td>
74 <td><a href="examples-percentbarchart.html">Percent Bar Chart</a></td>
75 </tr>
75 </tr>
76 <tr>
76 <tr>
77 <td><a href="examples-logvalueaxis.html"><img src="images/examples_logvalueaxis.png" width="300" alt="Logarythmix axis" /></a></td>
77 <td><a href="examples-modeldata.html"><img src="images/examples_modeldata.png" width="300" alt="Model Data" /></a></td>
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 <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="300" alt="Percent Bar Chart" /></a></td>
87 <td><a href="examples-percentbarchart.html"><img src="images/examples_percentbarchart.png" width="300" alt="Percent Bar Chart" /></a></td>
79 </tr>
88 </tr>
80
89
81 <tr>
90 <tr>
82 <td><a href="examples-piechart.html">Pie Chart</a></td>
91 <td><a href="examples-piechart.html">Pie Chart</a></td>
83 <td><a href="examples-piechartdrilldown.html">Pie Chart Drilldown</a></td>
92 <td><a href="examples-piechartdrilldown.html">Pie Chart Drilldown</a></td>
84 </tr>
93 </tr>
85 <tr>
94 <tr>
86 <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="300" alt="Pie Chart" /></a></td>
95 <td><a href="examples-piechart.html"><img src="images/examples_piechart.png" width="300" alt="Pie Chart" /></a></td>
87 <td><a href="examples-piechartdrilldown.html"><img src="images/examples_piechartdrill2.png" width="300" alt="Pie Chart Drilldown" /></a></td>
96 <td><a href="examples-piechartdrilldown.html"><img src="images/examples_piechartdrill2.png" width="300" alt="Pie Chart Drilldown" /></a></td>
88 </tr>
97 </tr>
89
98
90 <tr>
99 <tr>
91 <td><a href="examples-scatterchart.html">Scatter chart</a></td>
100 <td><a href="examples-scatterchart.html">Scatter chart</a></td>
92 <td><a href="examples-scatterinteractions.html">Scatter Interactions</a></td>
101 <td><a href="examples-scatterinteractions.html">Scatter Interactions</a></td>
93 </tr>
102 </tr>
94 <tr>
103 <tr>
95 <td><a href="examples-scatterchart.html"><img src="images/examples_scatterchart.png" width="300" alt="Scatter chart" /></a></td>
104 <td><a href="examples-scatterchart.html"><img src="images/examples_scatterchart.png" width="300" alt="Scatter chart" /></a></td>
96 <td><a href="examples-scatterinteractions.html"><img src="images/examples_scatterinteractions.png" width="300" alt="Scatter Interactions" /></a></td>
105 <td><a href="examples-scatterinteractions.html"><img src="images/examples_scatterinteractions.png" width="300" alt="Scatter Interactions" /></a></td>
97 </tr>
106 </tr>
98
107
99 <tr>
108 <tr>
100 <td><a href="examples-splinechart.html">Spline Chart</a></td>
109 <td><a href="examples-splinechart.html">Spline Chart</a></td>
101 <td><a href="examples-stackedbarchart.html">Stacked Bar Chart</a></td>
110 <td><a href="examples-stackedbarchart.html">Stacked Bar Chart</a></td>
102 </tr>
111 </tr>
103 <tr>
112 <tr>
104 <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="300" alt="Spline Chart" /></a></td>
113 <td><a href="examples-splinechart.html"><img src="images/examples_splinechart.png" width="300" alt="Spline Chart" /></a></td>
105 <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="300" alt="Stacked Bar Chart" /></a></td>
114 <td><a href="examples-stackedbarchart.html"><img src="images/examples_stackedbarchart.png" width="300" alt="Stacked Bar Chart" /></a></td>
106 </tr>
115 </tr>
107
116
108 <tr>
117 <tr>
109 <td><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown</a></td>
118 <td><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown</a></td>
110 <td><a href="examples-temperaturerecords.html">Temperature Records</a></td>
119 <td><a href="examples-temperaturerecords.html">Temperature Records</a></td>
111 </tr>
120 </tr>
112 <tr>
121 <tr>
113 <td><a href="examples-stackedbarchartdrilldown.html"><img src="images/examples_stackedbarchartdrilldown1.png" width="300" alt="Stacked Bar Chart Drilldown" /></a></td>
122 <td><a href="examples-stackedbarchartdrilldown.html"><img src="images/examples_stackedbarchartdrilldown1.png" width="300" alt="Stacked Bar Chart Drilldown" /></a></td>
114 <td><a href="examples-temperaturerecords.html"><img src="images/examples_temperaturerecords.png" width="300" alt="Temperature Records" /></a></td>
123 <td><a href="examples-temperaturerecords.html"><img src="images/examples_temperaturerecords.png" width="300" alt="Temperature Records" /></a></td>
115 </tr>
124 </tr>
116
125
117 <tr>
126 <tr>
118 <td><a href="examples-zoomlinechart.html">Zoom Line</a></td>
127 <td><a href="examples-zoomlinechart.html">Zoom Line</a></td>
119 </tr>
128 </tr>
120 <tr>
129 <tr>
121 <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart1.png" width="300" alt="Zoom Line" /></a></td>
130 <td><a href="examples-zoomlinechart.html"><img src="images/examples_zoomlinechart1.png" width="300" alt="Zoom Line" /></a></td>
122 </tr>
131 </tr>
123
132
124 </table>
133 </table>
125 </div>
134 </div>
126 \endraw
135 \endraw
127
136
128 */
137 */
@@ -1,74 +1,75
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 <QLineSeries>
24 #include <QLineSeries>
25 #include <QValueAxis>
25 #include <QValueAxis>
26 #include <QLogValueAxis>
26 #include <QLogValueAxis>
27
27
28 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
29
29
30 int main(int argc, char *argv[])
30 int main(int argc, char *argv[])
31 {
31 {
32 QApplication a(argc, argv);
32 QApplication a(argc, argv);
33
33
34 //![1]
34 //![1]
35 QLineSeries *series = new QLineSeries();
35 QLineSeries *series = new QLineSeries();
36 *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723);
36 *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723);
37 //![1]
37 //![1]
38
38
39 //![3]
39 //![2]
40 QChart *chart = new QChart();
40 QChart *chart = new QChart();
41 chart->addSeries(series);
41 chart->addSeries(series);
42 chart->legend()->hide();
42 chart->legend()->hide();
43 chart->setTitle("QLogValueAxis chart example");
43 chart->setTitle("Logarithmic axis example");
44 //![3]
44 //![2]
45
45
46 //![4]
46 //![3]
47 QValueAxis *axisX = new QValueAxis;
47 QValueAxis *axisX = new QValueAxis;
48 axisX->setTitleText("Data point");
48 axisX->setTitleText("Data point");
49 axisX->setTickCount(6);
49 axisX->setTickCount(6);
50 axisX->setLabelFormat("%i");
50 axisX->setLabelFormat("%i");
51 chart->addAxis(axisX, Qt::AlignBottom);
51 chart->addAxis(axisX, Qt::AlignBottom);
52 series->attachAxis(axisX);
52 series->attachAxis(axisX);
53
53
54 QLogValueAxis *axisY = new QLogValueAxis;
54 QLogValueAxis *axisY = new QLogValueAxis;
55 axisY->setLabelFormat("%g");
55 axisY->setLabelFormat("%g");
56 axisY->setTitleText("Values");
56 axisY->setTitleText("Values");
57 axisY->setBase(8);
57 chart->addAxis(axisY, Qt::AlignLeft);
58 chart->addAxis(axisY, Qt::AlignLeft);
58 series->attachAxis(axisY);
59 series->attachAxis(axisY);
59 //![4]
60 //![3]
60
61
61 //![5]
62 //![4]
62 QChartView *chartView = new QChartView(chart);
63 QChartView *chartView = new QChartView(chart);
63 chartView->setRenderHint(QPainter::Antialiasing);
64 chartView->setRenderHint(QPainter::Antialiasing);
64 //![5]
65 //![4]
65
66
66 //![6]
67 //![6]
67 QMainWindow window;
68 QMainWindow window;
68 window.setCentralWidget(chartView);
69 window.setCentralWidget(chartView);
69 window.resize(400, 300);
70 window.resize(400, 300);
70 window.show();
71 window.show();
71 //![6]
72 //![6]
72
73
73 return a.exec();
74 return a.exec();
74 }
75 }
@@ -1,90 +1,92
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 <QLineSeries>
24 #include <QLineSeries>
25 #include <QSplineSeries>
25 #include <QSplineSeries>
26 #include <QValueAxis>
26 #include <QValueAxis>
27 #include <QCategoryAxis>
27 #include <QCategoryAxis>
28
28
29 QTCOMMERCIALCHART_USE_NAMESPACE
29 QTCOMMERCIALCHART_USE_NAMESPACE
30
30
31 int main(int argc, char *argv[])
31 int main(int argc, char *argv[])
32 {
32 {
33 QApplication a(argc, argv);
33 QApplication a(argc, argv);
34
34
35 //![1]
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 QValueAxis *axisX = new QValueAxis;
42 QValueAxis *axisX = new QValueAxis;
38 axisX->setTickCount(10);
43 axisX->setTickCount(10);
44 chart->addAxis(axisX, Qt::AlignBottom);
45 //![2]
39
46
47 //![3]
40 QSplineSeries *series = new QSplineSeries;
48 QSplineSeries *series = new QSplineSeries;
41 *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5);
49 *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5);
42 chart->addSeries(series);
50 chart->addSeries(series);
43
51
44 QValueAxis *axisY = new QValueAxis;
52 QValueAxis *axisY = new QValueAxis;
45 axisY->setLinePenColor(series->pen().color());
53 axisY->setLinePenColor(series->pen().color());
46
54
47 chart->addAxis(axisX, Qt::AlignBottom);
48 chart->addAxis(axisY, Qt::AlignLeft);
55 chart->addAxis(axisY, Qt::AlignLeft);
49 series->attachAxis(axisX);
56 series->attachAxis(axisX);
50 series->attachAxis(axisY);
57 series->attachAxis(axisY);
58 //![3]
51
59
60 //![4]
52 series = new QSplineSeries;
61 series = new QSplineSeries;
53 *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5)
62 *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5)
54 << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17);
63 << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17);
55 chart->addSeries(series);
64 chart->addSeries(series);
56
65
57 QCategoryAxis *axisY3 = new QCategoryAxis;
66 QCategoryAxis *axisY3 = new QCategoryAxis;
58 axisY3->append("Low", 5);
67 axisY3->append("Low", 5);
59 axisY3->append("Medium", 12);
68 axisY3->append("Medium", 12);
60 axisY3->append("High", 17);
69 axisY3->append("High", 17);
61 axisY3->setLinePenColor(series->pen().color());
70 axisY3->setLinePenColor(series->pen().color());
62 axisY3->setGridLinePen((series->pen()));
71 axisY3->setGridLinePen((series->pen()));
63
72
64 chart->addAxis(axisY3, Qt::AlignRight);
73 chart->addAxis(axisY3, Qt::AlignRight);
65 series->attachAxis(axisX);
74 series->attachAxis(axisX);
66 series->attachAxis(axisY3);
75 series->attachAxis(axisY3);
67
68 //![2]
69
70 //![3]
71 chart->legend()->hide();
72 chart->setTitle("Multiaxis chart example");
73 //![3]
74
75 //![4]
76 //![4]
77
78 //![5]
76 QChartView *chartView = new QChartView(chart);
79 QChartView *chartView = new QChartView(chart);
77 chartView->setRenderHint(QPainter::Antialiasing);
80 chartView->setRenderHint(QPainter::Antialiasing);
78 //![4]
79
80
81 //![5]
81 //![5]
82
83 //![6]
82 QMainWindow window;
84 QMainWindow window;
83 window.setCentralWidget(chartView);
85 window.setCentralWidget(chartView);
84 window.resize(800, 600);
86 window.resize(800, 600);
85 window.show();
87 window.show();
86 //![5]
88 //![6]
87
89
88 return a.exec();
90 return a.exec();
89 }
91 }
90
92
General Comments 0
You need to be logged in to leave comments. Login now