##// END OF EJS Templates
categorylinechart in chartviewer tweaked
Marek Rosa -
r1976:9231f93419e5
parent child
Show More
@@ -1,70 +1,70
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 "charts.h"
22 22 #include "qchart.h"
23 23 #include "qlineseries.h"
24 24 #include <QCategoryAxis>
25 25
26 26 class CategoryLineChart: public Chart
27 27 {
28 28 public:
29 29 QString name() { return QObject::tr("CategoryLineChart"); }
30 30 QString category() { return QObject::tr("XYSeries"); }
31 31 QString subCategory() { return QString::null; }
32 32
33 33 QChart* createChart(const DataTable& table) {
34 34
35 35 QChart* chart = new QChart();
36 36 chart->setTitle("Category Line chart");
37 37
38 38 QString name("Series ");
39 39 int nameIndex = 0;
40 40 foreach (DataList list, table) {
41 41 QLineSeries *series = new QLineSeries(chart);
42 42 foreach (Data data, list)
43 43 series->append(data.first);
44 44 series->setName(name + QString::number(nameIndex));
45 45 nameIndex++;
46 46 chart->addSeries(series);
47 47 }
48 48
49 49 // chart->createDefaultAxes();
50 50 QCategoryAxis *axisX = new QCategoryAxis;
51 51 axisX->append("low", 5);
52 axisX->append("optimal", 12);
52 axisX->append("avg.", 12);
53 53 axisX->append("high", 19);
54 axisX->setRange(-1, 20);
54 axisX->setRange(0, 20);
55 55 chart->setAxisX(axisX, chart->series().at(0));
56 56
57 57 QCategoryAxis *axisY = new QCategoryAxis;
58 axisY->append("low", 5);
59 axisY->append("optimal", 8);
60 axisY->append("high", 12);
61 axisY->setRange(-5, 20);
58 axisY->append("cheap", 5);
59 axisY->append("fair", 12);
60 axisY->append("pricy", 20);
61 axisY->setRange(0, 20);
62 62 chart->setAxisY(axisY, chart->series().at(0));
63 63
64 64 return chart;
65 65 }
66 66
67 67 };
68 68
69 69 DECLARE_CHART(CategoryLineChart)
70 70
General Comments 0
You need to be logged in to leave comments. Login now