##// END OF EJS Templates
Adds axis template to chartviewer
Michal Klocek -
r2010:af0ef2488fa2
parent child
Show More
@@ -0,0 +1,60
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "charts.h"
22 #include "qchart.h"
23 #include "qlineseries.h"
24 #include "qvalueaxis.h"
25 #include "qcategoryaxis.h"
26
27 class ValueAxis: public Chart
28 {
29 public:
30 QString name() { return "ValueAxis"; }
31 QString category() { return QObject::tr("Axis"); }
32 QString subCategory() { return QString::null; }
33
34 QChart* createChart(const DataTable& table) {
35
36 QChart* chart = new QChart();
37 chart->setTitle("Value X , Value Y");
38
39 QString name("Series ");
40 int nameIndex = 0;
41 foreach (DataList list, table) {
42 QLineSeries *series = new QLineSeries(chart);
43 foreach (Data data, list)
44 series->append(data.first);
45 series->setName(name + QString::number(nameIndex));
46 nameIndex++;
47 chart->addSeries(series);
48 }
49
50 chart->createDefaultAxes();
51 QValueAxis* axis = new QValueAxis();
52 foreach (QAbstractSeries* series,chart->series())
53 chart->setAxisX(axis,series);
54
55 return chart;
56 }
57
58 };
59
60 DECLARE_CHART(ValueAxis);
@@ -88,6 +88,7 public:
88 }
88 }
89 };
89 };
90
90
91 #define DECLARE_CHART(chartName) static ChartWrapper<chartName> chartName;
91 #define DECLARE_CHART(chartType) static ChartWrapper<chartType> chartType;
92 #define DECLARE_CHART_TEMPLATE(chartType,chartName) static ChartWrapper<chartType> chartName;
92
93
93 #endif
94 #endif
@@ -26,14 +26,14
26 class CategoryLineChart: public Chart
26 class CategoryLineChart: public Chart
27 {
27 {
28 public:
28 public:
29 QString name() { return QObject::tr("CategoryLineChart"); }
29 QString name() { return QObject::tr("CategoryAxis"); }
30 QString category() { return QObject::tr("XYSeries"); }
30 QString category() { return QObject::tr("Axis"); }
31 QString subCategory() { return QString::null; }
31 QString subCategory() { return QString::null; }
32
32
33 QChart* createChart(const DataTable& table) {
33 QChart* createChart(const DataTable& table) {
34
34
35 QChart* chart = new QChart();
35 QChart* chart = new QChart();
36 chart->setTitle("Category Line chart");
36 chart->setTitle("Category X , Category Y ");
37
37
38 QString name("Series ");
38 QString name("Series ");
39 int nameIndex = 0;
39 int nameIndex = 0;
@@ -46,7 +46,6 public:
46 chart->addSeries(series);
46 chart->addSeries(series);
47 }
47 }
48
48
49 // chart->createDefaultAxes();
50 QCategoryAxis *axisX = new QCategoryAxis;
49 QCategoryAxis *axisX = new QCategoryAxis;
51 axisX->append("low", 5);
50 axisX->append("low", 5);
52 axisX->append("avg.", 12);
51 axisX->append("avg.", 12);
@@ -6,7 +6,6 SOURCES += \
6 xyseries/scatterchart.cpp \
6 xyseries/scatterchart.cpp \
7 xyseries/splinechart.cpp \
7 xyseries/splinechart.cpp \
8 xyseries/areachart.cpp \
8 xyseries/areachart.cpp \
9 xyseries/categorylinechart.cpp \
10 barseries/verticalstackedbarchart.cpp \
9 barseries/verticalstackedbarchart.cpp \
11 barseries/horizontalstackedbarchart.cpp \
10 barseries/horizontalstackedbarchart.cpp \
12 barseries/verticalbarchart.cpp \
11 barseries/verticalbarchart.cpp \
@@ -14,4 +13,6 SOURCES += \
14 barseries/horizontalpercentbarchart.cpp \
13 barseries/horizontalpercentbarchart.cpp \
15 barseries/verticalpercentbarchart.cpp \
14 barseries/verticalpercentbarchart.cpp \
16 pieseries/piechart.cpp \
15 pieseries/piechart.cpp \
17 pieseries/donutchart.cpp
16 pieseries/donutchart.cpp \
17 axis/valueaxis.cpp \
18 axis/categoryaxis.cpp
General Comments 0
You need to be logged in to leave comments. Login now