@@ -0,0 +1,23 | |||||
|
1 | #ifndef DECLARATIVESPLINESERIES_H | |||
|
2 | #define DECLARATIVESPLINESERIES_H | |||
|
3 | ||||
|
4 | #include "qchartglobal.h" | |||
|
5 | #include "declarativexyseries.h" | |||
|
6 | #include <QDeclarativeItem> | |||
|
7 | ||||
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
9 | ||||
|
10 | class DeclarativeSplineSeries : public DeclarativeXySeries | |||
|
11 | { | |||
|
12 | Q_OBJECT | |||
|
13 | ||||
|
14 | public: | |||
|
15 | explicit DeclarativeSplineSeries(QDeclarativeItem *parent = 0) : | |||
|
16 | DeclarativeXySeries(QSeries::SeriesTypeSpline, parent) {} | |||
|
17 | }; | |||
|
18 | ||||
|
19 | #include "moc_declarativesplineseries.cpp" | |||
|
20 | ||||
|
21 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
22 | ||||
|
23 | #endif // DECLARATIVESPLINESERIES_H |
@@ -0,0 +1,85 | |||||
|
1 | #include "DeclarativeXySeries.h" | |||
|
2 | #include "declarativechart.h" | |||
|
3 | #include "qchart.h" | |||
|
4 | #include "qxyseries.h" | |||
|
5 | #include "qareaseries.h" | |||
|
6 | #include "qsplineseries.h" | |||
|
7 | #include "qscatterseries.h" | |||
|
8 | ||||
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
10 | ||||
|
11 | DeclarativeXySeries::DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent) : | |||
|
12 | QDeclarativeItem(parent), | |||
|
13 | m_seriesType(type), | |||
|
14 | m_chart(0), | |||
|
15 | m_series(0) | |||
|
16 | { | |||
|
17 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |||
|
18 | } | |||
|
19 | ||||
|
20 | DeclarativeXySeries::~DeclarativeXySeries() | |||
|
21 | { | |||
|
22 | } | |||
|
23 | ||||
|
24 | void DeclarativeXySeries::componentComplete() | |||
|
25 | { | |||
|
26 | Q_ASSERT(!m_series); | |||
|
27 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |||
|
28 | ||||
|
29 | if (declarativeChart) { | |||
|
30 | m_chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |||
|
31 | Q_ASSERT(m_chart); | |||
|
32 | ||||
|
33 | switch (m_seriesType) { | |||
|
34 | case QSeries::SeriesTypeLine: | |||
|
35 | qDebug() << "creating line series for chart: " << m_chart; | |||
|
36 | m_series = new QLineSeries(); | |||
|
37 | break; | |||
|
38 | case QSeries::SeriesTypeArea: | |||
|
39 | qDebug() << "TODO: creating area series for chart: " << m_chart; | |||
|
40 | // m_series = new QAreaSeries(); | |||
|
41 | break; | |||
|
42 | case QSeries::SeriesTypeSpline: | |||
|
43 | qDebug() << "creating spline series for chart: " << m_chart; | |||
|
44 | m_series = new QSplineSeries(); | |||
|
45 | break; | |||
|
46 | case QSeries::SeriesTypeScatter: | |||
|
47 | qDebug() << "creating scatter series for chart: " << m_chart; | |||
|
48 | m_series = new QScatterSeries(); | |||
|
49 | break; | |||
|
50 | default: | |||
|
51 | Q_ASSERT(false); | |||
|
52 | } | |||
|
53 | ||||
|
54 | for (int i(0); i < m_points.count(); i++) { | |||
|
55 | DeclarativeXyPoint *element = m_points.at(i); | |||
|
56 | m_series->add(element->x(), element->y()); | |||
|
57 | } | |||
|
58 | m_chart->addSeries(m_series); | |||
|
59 | } | |||
|
60 | } | |||
|
61 | ||||
|
62 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeXySeries::points() | |||
|
63 | { | |||
|
64 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); | |||
|
65 | } | |||
|
66 | ||||
|
67 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |||
|
68 | DeclarativeXyPoint *element) | |||
|
69 | { | |||
|
70 | DeclarativeXySeries *series = qobject_cast<DeclarativeXySeries *>(list->object); | |||
|
71 | qDebug() << "appendPoints: " << series; | |||
|
72 | qDebug() << "appendPoints: " << element; | |||
|
73 | qDebug() << "appendPoints: " << element->x(); | |||
|
74 | qDebug() << "appendPoints: " << element->y(); | |||
|
75 | qDebug() << "appendPoints: " << series->m_series; | |||
|
76 | if (series) { | |||
|
77 | series->m_points.append(element); | |||
|
78 | if (series->m_series) | |||
|
79 | series->m_series->add(element->x(), element->y()); | |||
|
80 | } | |||
|
81 | } | |||
|
82 | ||||
|
83 | #include "moc_declarativexyseries.cpp" | |||
|
84 | ||||
|
85 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,45 | |||||
|
1 | #ifndef DECLARATIVE_XY_SERIES_H | |||
|
2 | #define DECLARATIVE_XY_SERIES_H | |||
|
3 | ||||
|
4 | #include "qchartglobal.h" | |||
|
5 | #include "declarativexypoint.h" | |||
|
6 | #include "qxyseries.h" | |||
|
7 | #include <QDeclarativeItem> | |||
|
8 | ||||
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
10 | ||||
|
11 | class QChart; | |||
|
12 | ||||
|
13 | class DeclarativeXySeries : public QDeclarativeItem | |||
|
14 | { | |||
|
15 | Q_OBJECT | |||
|
16 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |||
|
17 | ||||
|
18 | public: | |||
|
19 | explicit DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent = 0); | |||
|
20 | ~DeclarativeXySeries(); | |||
|
21 | ||||
|
22 | public: // from QDeclarativeParserStatus | |||
|
23 | void componentComplete(); | |||
|
24 | ||||
|
25 | public: | |||
|
26 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |||
|
27 | ||||
|
28 | signals: | |||
|
29 | ||||
|
30 | public slots: | |||
|
31 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |||
|
32 | DeclarativeXyPoint *element); | |||
|
33 | ||||
|
34 | private slots: | |||
|
35 | ||||
|
36 | public: | |||
|
37 | QSeries::QSeriesType m_seriesType; | |||
|
38 | QChart *m_chart; | |||
|
39 | QXYSeries *m_series; | |||
|
40 | QList<DeclarativeXyPoint *> m_points; | |||
|
41 | }; | |||
|
42 | ||||
|
43 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
44 | ||||
|
45 | #endif // DECLARATIVE_XY_SERIES_H |
@@ -1,55 +1,15 | |||||
1 | #include "declarativelineseries.h" |
|
1 | #include "declarativelineseries.h" | |
2 | #include "declarativechart.h" |
|
2 | #include "declarativechart.h" | |
3 | #include "qchart.h" |
|
3 | #include "qchart.h" | |
4 | #include "qlineseries.h" |
|
4 | #include "qlineseries.h" | |
5 |
|
5 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
7 | |||
8 | DeclarativeLineSeries::DeclarativeLineSeries(QDeclarativeItem *parent) : |
|
8 | DeclarativeLineSeries::DeclarativeLineSeries(QDeclarativeItem *parent) : | |
9 | QDeclarativeItem(parent) |
|
9 | DeclarativeXySeries(QSeries::SeriesTypeLine, parent) | |
10 | { |
|
10 | { | |
11 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
|||
12 | connect(this, SIGNAL(parentChanged()), |
|
|||
13 | this, SLOT(setParentForSeries())); |
|
|||
14 | } |
|
|||
15 |
|
||||
16 | void DeclarativeLineSeries::setParentForSeries() |
|
|||
17 | { |
|
|||
18 | if (!m_series) { |
|
|||
19 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); |
|
|||
20 |
|
||||
21 | if (declarativeChart) { |
|
|||
22 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
|||
23 | qDebug() << "creating line series for chart: " << chart; |
|
|||
24 | Q_ASSERT(chart); |
|
|||
25 |
|
||||
26 | m_series = new QLineSeries(); |
|
|||
27 | Q_ASSERT(m_series); |
|
|||
28 | for (int i(0); i < m_data.count(); i++) { |
|
|||
29 | DeclarativeXyPoint *element = m_data.at(i); |
|
|||
30 | m_series->add(element->x(), element->y()); |
|
|||
31 | } |
|
|||
32 | chart->addSeries(m_series); |
|
|||
33 | } |
|
|||
34 | } |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::data() |
|
|||
38 | { |
|
|||
39 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeLineSeries::appendData); |
|
|||
40 | } |
|
|||
41 |
|
||||
42 | void DeclarativeLineSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
|||
43 | DeclarativeXyPoint *element) |
|
|||
44 | { |
|
|||
45 | DeclarativeLineSeries *series = qobject_cast<DeclarativeLineSeries *>(list->object); |
|
|||
46 | if (series) { |
|
|||
47 | series->m_data.append(element); |
|
|||
48 | if (series->m_series) |
|
|||
49 | series->m_series->add(element->x(), element->y()); |
|
|||
50 | } |
|
|||
51 | } |
|
11 | } | |
52 |
|
12 | |||
53 | #include "moc_declarativelineseries.cpp" |
|
13 | #include "moc_declarativelineseries.cpp" | |
54 |
|
14 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
15 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,39 +1,20 | |||||
1 | #ifndef DECLARATIVELINESERIES_H |
|
1 | #ifndef DECLARATIVELINESERIES_H | |
2 | #define DECLARATIVELINESERIES_H |
|
2 | #define DECLARATIVELINESERIES_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 |
#include "declarativexy |
|
5 | #include "declarativexyseries.h" | |
6 | #include <QDeclarativeItem> |
|
6 | #include <QDeclarativeItem> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QChart; |
|
10 | class DeclarativeLineSeries : public DeclarativeXySeries | |
11 | class QLineSeries; |
|
|||
12 |
|
||||
13 | class DeclarativeLineSeries : public QDeclarativeItem |
|
|||
14 | { |
|
11 | { | |
15 | Q_OBJECT |
|
12 | Q_OBJECT | |
16 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> data READ data) |
|
|||
17 |
|
13 | |||
18 | public: |
|
14 | public: | |
19 | explicit DeclarativeLineSeries(QDeclarativeItem *parent = 0); |
|
15 | explicit DeclarativeLineSeries(QDeclarativeItem *parent = 0); | |
20 | QDeclarativeListProperty<DeclarativeXyPoint> data(); |
|
|||
21 |
|
||||
22 | signals: |
|
|||
23 |
|
||||
24 | public slots: |
|
|||
25 | static void appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
|||
26 | DeclarativeXyPoint *element); |
|
|||
27 |
|
||||
28 | private slots: |
|
|||
29 | void setParentForSeries(); |
|
|||
30 |
|
||||
31 | private: |
|
|||
32 | QChart *m_chart; |
|
|||
33 | QLineSeries *m_series; |
|
|||
34 | QList<DeclarativeXyPoint *> m_data; |
|
|||
35 | }; |
|
16 | }; | |
36 |
|
17 | |||
37 | QTCOMMERCIALCHART_END_NAMESPACE |
|
18 | QTCOMMERCIALCHART_END_NAMESPACE | |
38 |
|
19 | |||
39 | #endif // DECLARATIVELINESERIES_H |
|
20 | #endif // DECLARATIVELINESERIES_H |
@@ -1,63 +1,16 | |||||
1 | #include "declarativescatterseries.h" |
|
1 | #include "declarativescatterseries.h" | |
2 | #include "declarativechart.h" |
|
2 | #include "declarativechart.h" | |
3 | #include "qchart.h" |
|
3 | #include "qchart.h" | |
4 | #include "qscatterseries.h" |
|
4 | #include "qscatterseries.h" | |
5 |
|
5 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
7 | |||
8 | DeclarativeScatterSeries::DeclarativeScatterSeries(QDeclarativeItem *parent) : |
|
8 | DeclarativeScatterSeries::DeclarativeScatterSeries(QDeclarativeItem *parent) : | |
9 | QDeclarativeItem(parent), |
|
9 | DeclarativeXySeries(QSeries::SeriesTypeScatter, parent) | |
10 | m_chart(0), |
|
|||
11 | m_series(0) |
|
|||
12 | { |
|
10 | { | |
13 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
11 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
14 | } |
|
12 | } | |
15 |
|
13 | |||
16 | DeclarativeScatterSeries::~DeclarativeScatterSeries() |
|
|||
17 | { |
|
|||
18 | } |
|
|||
19 |
|
||||
20 | void DeclarativeScatterSeries::componentComplete() |
|
|||
21 | { |
|
|||
22 | Q_ASSERT(!m_series); |
|
|||
23 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); |
|
|||
24 |
|
||||
25 | if (declarativeChart) { |
|
|||
26 | m_chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
|||
27 | qDebug() << "creating scatter series for chart: " << m_chart; |
|
|||
28 | Q_ASSERT(m_chart); |
|
|||
29 |
|
||||
30 | m_series = new QScatterSeries(); |
|
|||
31 | for (int i(0); i < m_points.count(); i++) { |
|
|||
32 | DeclarativeXyPoint *element = m_points.at(i); |
|
|||
33 | *m_series << QPointF(element->x(), element->y()); |
|
|||
34 | } |
|
|||
35 | m_chart->addSeries(m_series); |
|
|||
36 | } |
|
|||
37 | } |
|
|||
38 |
|
||||
39 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() |
|
|||
40 | { |
|
|||
41 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, |
|
|||
42 | &DeclarativeScatterSeries::appendPoints); |
|
|||
43 | } |
|
|||
44 |
|
||||
45 | void DeclarativeScatterSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
|||
46 | DeclarativeXyPoint *element) |
|
|||
47 | { |
|
|||
48 | DeclarativeScatterSeries *series = qobject_cast<DeclarativeScatterSeries *>(list->object); |
|
|||
49 | qDebug() << "appendPoints: " << series; |
|
|||
50 | qDebug() << "appendPoints: " << element; |
|
|||
51 | qDebug() << "appendPoints: " << element->x(); |
|
|||
52 | qDebug() << "appendPoints: " << element->y(); |
|
|||
53 | qDebug() << "appendPoints: " << series->m_series; |
|
|||
54 | if (series) { |
|
|||
55 | series->m_points.append(element); |
|
|||
56 | if (series->m_series) |
|
|||
57 | series->m_series->add(element->x(), element->y()); |
|
|||
58 | } |
|
|||
59 | } |
|
|||
60 |
|
||||
61 | #include "moc_declarativescatterseries.cpp" |
|
14 | #include "moc_declarativescatterseries.cpp" | |
62 |
|
15 | |||
63 | QTCOMMERCIALCHART_END_NAMESPACE |
|
16 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,44 +1,20 | |||||
1 | #ifndef DECLARATIVESCATTERSERIES_H |
|
1 | #ifndef DECLARATIVESCATTERSERIES_H | |
2 | #define DECLARATIVESCATTERSERIES_H |
|
2 | #define DECLARATIVESCATTERSERIES_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 |
#include "declarativexy |
|
5 | #include "declarativexyseries.h" | |
6 | #include <QDeclarativeItem> |
|
6 | #include <QDeclarativeItem> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QChart; |
|
10 | class DeclarativeScatterSeries : public DeclarativeXySeries | |
11 | class QScatterSeries; |
|
|||
12 |
|
||||
13 | class DeclarativeScatterSeries : public QDeclarativeItem |
|
|||
14 | { |
|
11 | { | |
15 | Q_OBJECT |
|
12 | Q_OBJECT | |
16 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) |
|
|||
17 |
|
13 | |||
18 | public: |
|
14 | public: | |
19 | explicit DeclarativeScatterSeries(QDeclarativeItem *parent = 0); |
|
15 | explicit DeclarativeScatterSeries(QDeclarativeItem *parent = 0); | |
20 | ~DeclarativeScatterSeries(); |
|
|||
21 |
|
||||
22 | public: // from QDeclarativeParserStatus |
|
|||
23 | void componentComplete(); |
|
|||
24 |
|
||||
25 | public: |
|
|||
26 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
|||
27 |
|
||||
28 | signals: |
|
|||
29 |
|
||||
30 | public slots: |
|
|||
31 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
|||
32 | DeclarativeXyPoint *element); |
|
|||
33 |
|
||||
34 | private slots: |
|
|||
35 |
|
||||
36 | public: |
|
|||
37 | QChart *m_chart; // not owned |
|
|||
38 | QScatterSeries *m_series; // not owned |
|
|||
39 | QList<DeclarativeXyPoint *> m_points; // not owned |
|
|||
40 | }; |
|
16 | }; | |
41 |
|
17 | |||
42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
18 | QTCOMMERCIALCHART_END_NAMESPACE | |
43 |
|
19 | |||
44 | #endif // DECLARATIVESCATTERSERIES_H |
|
20 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,36 +1,38 | |||||
1 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
1 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
2 | #include <QtDeclarative/qdeclarative.h> |
|
2 | #include <QtDeclarative/qdeclarative.h> | |
3 | #include "declarativechart.h" |
|
3 | #include "declarativechart.h" | |
4 | #include "declarativexypoint.h" |
|
4 | #include "declarativexypoint.h" | |
5 | #include "declarativescatterseries.h" |
|
|||
6 | #include "declarativelineseries.h" |
|
5 | #include "declarativelineseries.h" | |
|
6 | #include "declarativesplineseries.h" | |||
|
7 | #include "declarativescatterseries.h" | |||
7 | #include "declarativebarseries.h" |
|
8 | #include "declarativebarseries.h" | |
8 | #include "declarativepieseries.h" |
|
9 | #include "declarativepieseries.h" | |
9 |
|
10 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
12 | |||
12 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
13 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
13 | { |
|
14 | { | |
14 | Q_OBJECT |
|
15 | Q_OBJECT | |
15 | public: |
|
16 | public: | |
16 | virtual void registerTypes(const char *uri) |
|
17 | virtual void registerTypes(const char *uri) | |
17 | { |
|
18 | { | |
18 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
19 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
19 |
|
20 | |||
20 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart"); |
|
21 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "Chart"); | |
21 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
22 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); | |
22 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
23 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
23 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
24 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
|
25 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |||
24 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
26 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
25 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
27 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
26 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
28 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
27 | } |
|
29 | } | |
28 | }; |
|
30 | }; | |
29 |
|
31 | |||
30 | #include "plugin.moc" |
|
32 | #include "plugin.moc" | |
31 |
|
33 | |||
32 | QTCOMMERCIALCHART_END_NAMESPACE |
|
34 | QTCOMMERCIALCHART_END_NAMESPACE | |
33 |
|
35 | |||
34 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
36 | QTCOMMERCIALCHART_USE_NAMESPACE | |
35 |
|
37 | |||
36 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
38 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
@@ -1,45 +1,48 | |||||
1 | TEMPLATE = lib |
|
1 | TEMPLATE = lib | |
2 | TARGET = qtcommercialchartqml |
|
2 | TARGET = qtcommercialchartqml | |
3 | CONFIG += qt plugin |
|
3 | CONFIG += qt plugin | |
4 | QT += declarative |
|
4 | QT += declarative | |
5 |
|
5 | |||
6 | !include( ../common.pri ) { |
|
6 | !include( ../common.pri ) { | |
7 | error( "Couldn't find the common.pri file!" ) |
|
7 | error( "Couldn't find the common.pri file!" ) | |
8 | } |
|
8 | } | |
9 | !include( ../integrated.pri ) { |
|
9 | !include( ../integrated.pri ) { | |
10 | error( "Couldn't find the integrated.pri file !") |
|
10 | error( "Couldn't find the integrated.pri file !") | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 | DESTDIR = $$CHART_BUILD_PLUGIN_DIR |
|
13 | DESTDIR = $$CHART_BUILD_PLUGIN_DIR | |
14 | contains(QT_MAJOR_VERSION, 5) { |
|
14 | contains(QT_MAJOR_VERSION, 5) { | |
15 | # TODO: QtQuick2 not supported by the implementation currently |
|
15 | # TODO: QtQuick2 not supported by the implementation currently | |
16 | DEFINES += QTQUICK2 |
|
16 | DEFINES += QTQUICK2 | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | OBJECTS_DIR = $$CHART_BUILD_DIR/plugin |
|
19 | OBJECTS_DIR = $$CHART_BUILD_DIR/plugin | |
20 | MOC_DIR = $$CHART_BUILD_DIR/plugin |
|
20 | MOC_DIR = $$CHART_BUILD_DIR/plugin | |
21 | UI_DIR = $$CHART_BUILD_DIR/plugin |
|
21 | UI_DIR = $$CHART_BUILD_DIR/plugin | |
22 | RCC_DIR = $$CHART_BUILD_DIR/plugin |
|
22 | RCC_DIR = $$CHART_BUILD_DIR/plugin | |
23 |
|
23 | |||
24 | SOURCES += \ |
|
24 | SOURCES += \ | |
25 | plugin.cpp \ |
|
25 | plugin.cpp \ | |
26 | declarativechart.cpp \ |
|
26 | declarativechart.cpp \ | |
27 | declarativescatterseries.cpp \ |
|
|||
28 | declarativexypoint.cpp \ |
|
27 | declarativexypoint.cpp \ | |
29 |
declarative |
|
28 | declarativexyseries.cpp \ | |
30 | declarativelineseries.cpp \ |
|
29 | declarativelineseries.cpp \ | |
|
30 | declarativescatterseries.cpp \ | |||
|
31 | declarativepieseries.cpp \ | |||
31 | declarativebarseries.cpp |
|
32 | declarativebarseries.cpp | |
32 | HEADERS += \ |
|
33 | HEADERS += \ | |
33 | declarativechart.h \ |
|
34 | declarativechart.h \ | |
34 | declarativescatterseries.h \ |
|
|||
35 | declarativexypoint.h \ |
|
35 | declarativexypoint.h \ | |
36 |
declarative |
|
36 | declarativexyseries.h \ | |
37 | declarativelineseries.h \ |
|
37 | declarativelineseries.h \ | |
|
38 | declarativesplineseries.h \ | |||
|
39 | declarativescatterseries.h \ | |||
|
40 | declarativepieseries.h \ | |||
38 | declarativebarseries.h |
|
41 | declarativebarseries.h | |
39 |
|
42 | |||
40 | TARGETPATH = QtCommercial/Chart |
|
43 | TARGETPATH = QtCommercial/Chart | |
41 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
44 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
42 | qmldir.files += $$PWD/qmldir |
|
45 | qmldir.files += $$PWD/qmldir | |
43 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
46 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
44 |
|
47 | |||
45 | INSTALLS += target qmldir |
|
48 | INSTALLS += target qmldir |
@@ -1,104 +1,104 | |||||
1 | import QtQuick 1.0 |
|
1 | import QtQuick 1.0 | |
2 | import QtCommercial.Chart 1.0 |
|
2 | import QtCommercial.Chart 1.0 | |
3 |
|
3 | |||
4 | Rectangle { |
|
4 | Rectangle { | |
5 | width: parent.width |
|
5 | width: parent.width | |
6 | height: parent.height |
|
6 | height: parent.height | |
7 |
|
7 | |||
8 | // Another option for QML data api: |
|
8 | // Another option for QML data api: | |
9 | // ListModel { |
|
9 | // ListModel { | |
10 | // id: listModelForPie |
|
10 | // id: listModelForPie | |
11 | // // PieDataElement |
|
11 | // // PieDataElement | |
12 | // ListElement { |
|
12 | // ListElement { | |
13 | // label: "Apple" |
|
13 | // label: "Apple" | |
14 | // value: 4.3 |
|
14 | // value: 4.3 | |
15 | // } |
|
15 | // } | |
16 | // ListElement { |
|
16 | // ListElement { | |
17 | // label: "Blackberry" |
|
17 | // label: "Blackberry" | |
18 | // value: 15.1 |
|
18 | // value: 15.1 | |
19 | // } |
|
19 | // } | |
20 | // } |
|
20 | // } | |
21 |
|
21 | |||
22 | Component.onCompleted: { |
|
22 | Component.onCompleted: { | |
23 | // console.log("model:" + myModel.item(0)); |
|
23 | // console.log("model:" + myModel.item(0)); | |
24 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); |
|
24 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); | |
25 | // scatter.appendData(); |
|
25 | // scatter.appendData(); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | Chart { |
|
29 | Chart { | |
30 | id: chart1 |
|
30 | id: chart1 | |
31 | anchors.top: parent.top |
|
31 | anchors.top: parent.top | |
32 | anchors.left: parent.left |
|
32 | anchors.left: parent.left | |
33 | anchors.right: parent.right |
|
33 | anchors.right: parent.right | |
34 | height: parent.height / 2 |
|
34 | height: parent.height / 2 | |
35 | theme: Chart.ThemeBlueCerulean |
|
35 | theme: Chart.ThemeBlueCerulean | |
36 |
|
36 | |||
37 | BarSeries { |
|
37 | BarSeries { | |
38 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
38 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] | |
39 | // data: [ |
|
39 | // data: [ | |
40 | // BarSet { } |
|
40 | // BarSet { } | |
41 | // ] |
|
41 | // ] | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | // PieSeries { |
|
44 | // PieSeries { | |
45 | // data: [ |
|
45 | // data: [ | |
46 | // PieSlice { label: "Volkswagen"; value: 13.5 }, |
|
46 | // PieSlice { label: "Volkswagen"; value: 13.5 }, | |
47 | // PieSlice { label: "Toyota"; value: 10.9 }, |
|
47 | // PieSlice { label: "Toyota"; value: 10.9 }, | |
48 | // PieSlice { label: "Ford"; value: 8.6 }, |
|
48 | // PieSlice { label: "Ford"; value: 8.6 }, | |
49 | // PieSlice { label: "Skoda"; value: 8.2 }, |
|
49 | // PieSlice { label: "Skoda"; value: 8.2 }, | |
50 | // PieSlice { label: "Volvo"; value: 6.8 }, |
|
50 | // PieSlice { label: "Volvo"; value: 6.8 }, | |
51 | // PieSlice { label: "Others"; value: 52.0 } |
|
51 | // PieSlice { label: "Others"; value: 52.0 } | |
52 | // ] |
|
52 | // ] | |
53 | // } |
|
53 | // } | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 |
|
56 | |||
57 | Chart { |
|
57 | Chart { | |
58 | id: chart2 |
|
58 | id: chart2 | |
59 | anchors.top: chart1.bottom |
|
59 | anchors.top: chart1.bottom | |
60 | anchors.bottom: parent.bottom |
|
60 | anchors.bottom: parent.bottom | |
61 | anchors.left: parent.left |
|
61 | anchors.left: parent.left | |
62 | anchors.right: parent.right |
|
62 | anchors.right: parent.right | |
63 | theme: Chart.ThemeBrownSand |
|
63 | theme: Chart.ThemeBrownSand | |
64 |
|
64 | |||
65 | LineSeries { |
|
65 | LineSeries { | |
66 |
|
|
66 | points: [ | |
67 | XyPoint { x: 0.0; y: 0.0 }, |
|
67 | XyPoint { x: 0.0; y: 0.0 }, | |
68 | XyPoint { x: 1.1; y: 2.1 }, |
|
68 | XyPoint { x: 1.1; y: 2.1 }, | |
69 | XyPoint { x: 2.9; y: 4.9 }, |
|
69 | XyPoint { x: 2.9; y: 4.9 }, | |
70 | XyPoint { x: 3.2; y: 3.0 } |
|
70 | XyPoint { x: 3.2; y: 3.0 } | |
71 | ] |
|
71 | ] | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 |
S |
|
74 | SplineSeries { | |
75 | id: scatter |
|
75 | id: scatter | |
76 | points: [ |
|
76 | points: [ | |
77 |
XyPoint { x: |
|
77 | XyPoint { x: 0.0; y: 0.3 }, | |
78 |
XyPoint { x: 1.1; y: |
|
78 | XyPoint { x: 1.1; y: 3.2 }, | |
79 |
XyPoint { x: |
|
79 | XyPoint { x: 4.17; y: 3.15 } | |
80 | ] |
|
80 | ] | |
81 | } |
|
81 | } | |
82 | ScatterSeries { |
|
82 | ScatterSeries { | |
83 | points: [ |
|
83 | points: [ | |
84 | XyPoint { x: 1.5; y: 1.5 }, |
|
84 | XyPoint { x: 1.5; y: 1.5 }, | |
85 | XyPoint { x: 1.5; y: 1.6 }, |
|
85 | XyPoint { x: 1.5; y: 1.6 }, | |
86 | XyPoint { x: 1.57; y: 1.55 } |
|
86 | XyPoint { x: 1.57; y: 1.55 } | |
87 | ] |
|
87 | ] | |
88 | } |
|
88 | } | |
89 | ScatterSeries { |
|
89 | ScatterSeries { | |
90 | points: [ |
|
90 | points: [ | |
91 | XyPoint { x: 2.0; y: 2.0 }, |
|
91 | XyPoint { x: 2.0; y: 2.0 }, | |
92 | XyPoint { x: 2.0; y: 2.1 }, |
|
92 | XyPoint { x: 2.0; y: 2.1 }, | |
93 | XyPoint { x: 2.07; y: 2.05 } |
|
93 | XyPoint { x: 2.07; y: 2.05 } | |
94 | ] |
|
94 | ] | |
95 | } |
|
95 | } | |
96 | ScatterSeries { |
|
96 | ScatterSeries { | |
97 | points: [ |
|
97 | points: [ | |
98 | XyPoint { x: 2.6; y: 2.6 }, |
|
98 | XyPoint { x: 2.6; y: 2.6 }, | |
99 | XyPoint { x: 2.6; y: 2.7 }, |
|
99 | XyPoint { x: 2.6; y: 2.7 }, | |
100 | XyPoint { x: 2.67; y: 2.65 } |
|
100 | XyPoint { x: 2.67; y: 2.65 } | |
101 | ] |
|
101 | ] | |
102 | } |
|
102 | } | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } |
General Comments 0
You need to be logged in to leave comments.
Login now