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