##// END OF EJS Templates
Adds datetimeaxis chart to chartviewer
Michal Klocek -
r2124:2ff0cd030cff
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 "qdatetimeaxis.h"
26
27 class DateTimeAxisX: public Chart
28 {
29 public:
30 QString name() { return "AxisX"; }
31 QString category() { return QObject::tr("Axis"); }
32 QString subCategory() { return "DateTimeAxis"; }
33
34 QChart *createChart(const DataTable &table)
35 {
36 QChart *chart = new QChart();
37 chart->setTitle("DateTime X , Value Y");
38 QValueAxis *valueaxis = new QValueAxis();
39 QDateTimeAxis *datetimeaxis = new QDateTimeAxis();
40 datetimeaxis->setTickCount(10);
41 datetimeaxis->setFormat("MMM yyyy");
42
43 QString name("Series ");
44 int nameIndex = 0;
45 foreach (DataList list, table) {
46 QLineSeries *series = new QLineSeries(chart);
47 foreach (Data data, list)
48 series->append(data.first);
49 series->setName(name + QString::number(nameIndex));
50 nameIndex++;
51 chart->addSeries(series);
52 chart->setAxisX(datetimeaxis, series);
53 chart->setAxisY(valueaxis, series);
54 }
55
56 return chart;
57 }
58 };
59
60 DECLARE_CHART(DateTimeAxisX);
@@ -1,20 +1,21
1 INCLUDEPATH += $$PWD
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
2 DEPENDPATH += $$PWD
3 SOURCES += \
3 SOURCES += \
4 font/font.cpp \
4 font/font.cpp \
5 xyseries/linechart.cpp \
5 xyseries/linechart.cpp \
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 barseries/verticalstackedbarchart.cpp \
9 barseries/verticalstackedbarchart.cpp \
10 barseries/horizontalstackedbarchart.cpp \
10 barseries/horizontalstackedbarchart.cpp \
11 barseries/verticalbarchart.cpp \
11 barseries/verticalbarchart.cpp \
12 barseries/horizontalbarchart.cpp \
12 barseries/horizontalbarchart.cpp \
13 barseries/horizontalpercentbarchart.cpp \
13 barseries/horizontalpercentbarchart.cpp \
14 barseries/verticalpercentbarchart.cpp \
14 barseries/verticalpercentbarchart.cpp \
15 pieseries/piechart.cpp \
15 pieseries/piechart.cpp \
16 pieseries/donutchart.cpp \
16 pieseries/donutchart.cpp \
17 axis/valueaxis.cpp \
17 axis/valueaxis.cpp \
18 axis/categoryaxis.cpp \
18 axis/categoryaxis.cpp \
19 axis/barcategoryaxisx.cpp \
19 axis/barcategoryaxisx.cpp \
20 axis/barcategoryaxisy.cpp
20 axis/barcategoryaxisy.cpp \
21 axis/datetimeaxis.cpp
General Comments 0
You need to be logged in to leave comments. Login now