@@ -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); |
General Comments 0
You need to be logged in to leave comments.
Login now