##// END OF EJS Templates
Enable default axes in spline and scatter charts
Marek Rosa -
r1610:4694192f0264
parent child
Show More
@@ -1,56 +1,57
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 "chartview.h"
21 #include "chartview.h"
22 #include <QScatterSeries>
22 #include <QScatterSeries>
23
23
24 ChartView::ChartView(QWidget *parent) :
24 ChartView::ChartView(QWidget *parent) :
25 QChartView(new QChart(), parent)
25 QChartView(new QChart(), parent)
26 {
26 {
27 //![1]
27 //![1]
28 QScatterSeries *series0 = new QScatterSeries();
28 QScatterSeries *series0 = new QScatterSeries();
29 series0->setName("scatter1");
29 series0->setName("scatter1");
30 series0->setMarkerShape(QScatterSeries::MarkerShapeCircle);
30 series0->setMarkerShape(QScatterSeries::MarkerShapeCircle);
31 series0->setMarkerSize(15.0);
31 series0->setMarkerSize(15.0);
32
32
33 QScatterSeries *series1 = new QScatterSeries();
33 QScatterSeries *series1 = new QScatterSeries();
34 series1->setName("scatter2");
34 series1->setName("scatter2");
35 series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);
35 series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);
36 series1->setMarkerSize(20.0);
36 series1->setMarkerSize(20.0);
37 //![1]
37 //![1]
38
38
39 //![2]
39 //![2]
40 series0->append(0, 6);
40 series0->append(0, 6);
41 series0->append(2, 4);
41 series0->append(2, 4);
42 series0->append(3, 8);
42 series0->append(3, 8);
43 series0->append(7, 4);
43 series0->append(7, 4);
44 series0->append(10, 5);
44 series0->append(10, 5);
45
45
46 *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
46 *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
47 //![2]
47 //![2]
48
48
49 //![3]
49 //![3]
50 setRenderHint(QPainter::Antialiasing);
50 setRenderHint(QPainter::Antialiasing);
51 chart()->addSeries(series0);
51 chart()->addSeries(series0);
52 chart()->addSeries(series1);
52 chart()->addSeries(series1);
53 chart()->setTitle("Simple scatterchart example");
53 chart()->setTitle("Simple scatterchart example");
54 chart()->createDefaultAxes();
54 chart()->setDropShadowEnabled(false);
55 chart()->setDropShadowEnabled(false);
55 //![3]
56 //![3]
56 }
57 }
@@ -1,67 +1,68
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 <QSplineSeries>
24 #include <QSplineSeries>
25
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
27
28 int main(int argc, char *argv[])
28 int main(int argc, char *argv[])
29 {
29 {
30 QApplication a(argc, argv);
30 QApplication a(argc, argv);
31
31
32 //![1]
32 //![1]
33 QSplineSeries* series = new QSplineSeries();
33 QSplineSeries* series = new QSplineSeries();
34 series->setName("spline");
34 series->setName("spline");
35 //![1]
35 //![1]
36
36
37 //![2]
37 //![2]
38 series->append(0, 6);
38 series->append(0, 6);
39 series->append(2, 4);
39 series->append(2, 4);
40 series->append(3, 8);
40 series->append(3, 8);
41 series->append(7, 4);
41 series->append(7, 4);
42 series->append(10, 5);
42 series->append(10, 5);
43 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
43 *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
44 //![2]
44 //![2]
45
45
46 //![3]
46 //![3]
47 QChart* chart = new QChart();
47 QChart* chart = new QChart();
48 chart->legend()->hide();
48 chart->legend()->hide();
49 chart->addSeries(series);
49 chart->addSeries(series);
50 chart->setTitle("Simple spline chart example");
50 chart->setTitle("Simple spline chart example");
51 chart->createDefaultAxes();
51 chart->axisY()->setRange(0, 10);
52 chart->axisY()->setRange(0, 10);
52 //![3]
53 //![3]
53
54
54 //![4]
55 //![4]
55 QChartView* chartView = new QChartView(chart);
56 QChartView* chartView = new QChartView(chart);
56 chartView->setRenderHint(QPainter::Antialiasing);
57 chartView->setRenderHint(QPainter::Antialiasing);
57 //![4]
58 //![4]
58
59
59 //![5]
60 //![5]
60 QMainWindow window;
61 QMainWindow window;
61 window.setCentralWidget(chartView);
62 window.setCentralWidget(chartView);
62 window.resize(400, 300);
63 window.resize(400, 300);
63 window.show();
64 window.show();
64 //![5]
65 //![5]
65
66
66 return a.exec();
67 return a.exec();
67 }
68 }
General Comments 0
You need to be logged in to leave comments. Login now