##// END OF EJS Templates
Adds dettimeaxisy to chartviewer
Michal Klocek -
r2126:569ff81434f6
parent child
Show More
@@ -0,0 +1,62
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 DateTimeAxisY: public Chart
28 {
29 public:
30 QString name() { return "AxisY"; }
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("Value X , DateTime Y");
38 QValueAxis *valueaxis = new QValueAxis();
39 QDateTimeAxis *datetimeaxis = new QDateTimeAxis();
40 datetimeaxis->setTickCount(10);
41 datetimeaxis->setFormat("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 QPointF point = data.first;
49 series->append(point.x(),1000l*60l*60l*24l*365l*30l+point.y()*1000l*60l*60l*24l*365l);
50 }
51 series->setName(name + QString::number(nameIndex));
52 nameIndex++;
53 chart->addSeries(series);
54 chart->setAxisY(datetimeaxis, series);
55 chart->setAxisX(valueaxis, series);
56 }
57
58 return chart;
59 }
60 };
61
62 DECLARE_CHART(DateTimeAxisY);
1 NO CONTENT: file renamed from demos/chartviewer/charts/axis/datetimeaxis.cpp to demos/chartviewer/charts/axis/datetimeaxisx.cpp
@@ -18,4 +18,5 SOURCES += \
18 18 axis/categoryaxis.cpp \
19 19 axis/barcategoryaxisx.cpp \
20 20 axis/barcategoryaxisy.cpp \
21 axis/datetimeaxis.cpp
21 axis/datetimeaxisx.cpp \
22 axis/datetimeaxisy.cpp
General Comments 0
You need to be logged in to leave comments. Login now