@@ -0,0 +1,65 | |||||
|
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 "qhorizontalbarseries.h" | |||
|
24 | #include "qbarset.h" | |||
|
25 | #include "qvalueaxis.h" | |||
|
26 | #include "qbarcategoryaxis.h" | |||
|
27 | ||||
|
28 | class BarCategoryAxisY: public Chart | |||
|
29 | { | |||
|
30 | public: | |||
|
31 | QString name() { return "AxisY"; } | |||
|
32 | QString category() { return QObject::tr("Axis"); } | |||
|
33 | QString subCategory() { return "BarCategoryAxis"; } | |||
|
34 | ||||
|
35 | QChart *createChart(const DataTable &table) | |||
|
36 | { | |||
|
37 | QChart *chart = new QChart(); | |||
|
38 | chart->setTitle(" BarCateogry Y , Value X"); | |||
|
39 | ||||
|
40 | QString name("Series "); | |||
|
41 | QHorizontalBarSeries *series = new QHorizontalBarSeries(chart); | |||
|
42 | QValueAxis *valueaxis = new QValueAxis(); | |||
|
43 | QBarCategoryAxis *barcategory = new QBarCategoryAxis(); | |||
|
44 | for (int i(0); i < table.count(); i++) { | |||
|
45 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |||
|
46 | foreach (Data data, table[i]) | |||
|
47 | *set << data.first.y(); | |||
|
48 | series->append(set); | |||
|
49 | } | |||
|
50 | chart->addSeries(series); | |||
|
51 | ||||
|
52 | int count = series->barSets().first()->count(); | |||
|
53 | ||||
|
54 | for(int i =0 ; i < count ; i++){ | |||
|
55 | barcategory->append(QString::number(i)); | |||
|
56 | } | |||
|
57 | ||||
|
58 | chart->setAxisX(valueaxis, series); | |||
|
59 | chart->setAxisY(barcategory, series); | |||
|
60 | ||||
|
61 | return chart; | |||
|
62 | } | |||
|
63 | }; | |||
|
64 | ||||
|
65 | DECLARE_CHART(BarCategoryAxisY); |
General Comments 0
You need to be logged in to leave comments.
Login now