@@ -0,0 +1,41 | |||
|
1 | #include "declarativesplineseries.h" | |
|
2 | #include "declarativechart.h" | |
|
3 | #include "qchart.h" | |
|
4 | ||
|
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
6 | ||
|
7 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |
|
8 | QSplineSeries(parent) | |
|
9 | { | |
|
10 | } | |
|
11 | ||
|
12 | void DeclarativeSplineSeries::seriesComplete() | |
|
13 | { | |
|
14 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |
|
15 | ||
|
16 | if (declarativeChart) { | |
|
17 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
|
18 | Q_ASSERT(chart); | |
|
19 | chart->addSeries(this); | |
|
20 | } | |
|
21 | } | |
|
22 | ||
|
23 | QObject *DeclarativeSplineSeries::seriesObject() | |
|
24 | { | |
|
25 | return this; | |
|
26 | } | |
|
27 | ||
|
28 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeSplineSeries::points() | |
|
29 | { | |
|
30 | return DeclarativeXySeries::points(); | |
|
31 | } | |
|
32 | ||
|
33 | void DeclarativeSplineSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
34 | DeclarativeXyPoint *element) | |
|
35 | { | |
|
36 | DeclarativeXySeries::appendPoints(list, element); | |
|
37 | } | |
|
38 | ||
|
39 | #include "moc_declarativesplineseries.cpp" | |
|
40 | ||
|
41 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -5,11 +5,38 | |||
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 7 | |
|
8 |
DeclarativeLineSeries::DeclarativeLineSeries(Q |
|
|
9 | DeclarativeXySeries(QSeries::SeriesTypeLine, parent) | |
|
8 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |
|
9 | QLineSeries(parent) | |
|
10 | 10 | { |
|
11 | 11 | } |
|
12 | 12 | |
|
13 | void DeclarativeLineSeries::seriesComplete() | |
|
14 | { | |
|
15 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |
|
16 | ||
|
17 | if (declarativeChart) { | |
|
18 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
|
19 | Q_ASSERT(chart); | |
|
20 | chart->addSeries(this); | |
|
21 | } | |
|
22 | } | |
|
23 | ||
|
24 | QObject *DeclarativeLineSeries::seriesObject() | |
|
25 | { | |
|
26 | return this; | |
|
27 | } | |
|
28 | ||
|
29 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::points() | |
|
30 | { | |
|
31 | return DeclarativeXySeries::points(); | |
|
32 | } | |
|
33 | ||
|
34 | void DeclarativeLineSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
35 | DeclarativeXyPoint *element) | |
|
36 | { | |
|
37 | DeclarativeXySeries::appendPoints(list, element); | |
|
38 | } | |
|
39 | ||
|
13 | 40 | #include "moc_declarativelineseries.cpp" |
|
14 | 41 | |
|
15 | 42 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -2,17 +2,30 | |||
|
2 | 2 | #define DECLARATIVELINESERIES_H |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | #include "qlineseries.h" | |
|
5 | 6 | #include "declarativexyseries.h" |
|
6 |
#include <QDeclarative |
|
|
7 | #include <QDeclarativeParserStatus> | |
|
7 | 8 | |
|
8 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 10 | |
|
10 | class DeclarativeLineSeries : public DeclarativeXySeries | |
|
11 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries | |
|
11 | 12 | { |
|
12 | 13 | Q_OBJECT |
|
14 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
|
13 | 15 | |
|
14 | 16 | public: |
|
15 |
explicit DeclarativeLineSeries(Q |
|
|
17 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
|
18 | ||
|
19 | public: | |
|
20 | void seriesComplete(); | |
|
21 | QObject *seriesObject(); | |
|
22 | ||
|
23 | public: | |
|
24 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
|
25 | ||
|
26 | public slots: | |
|
27 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
28 | DeclarativeXyPoint *element); | |
|
16 | 29 | }; |
|
17 | 30 | |
|
18 | 31 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,56 +1,41 | |||
|
1 | 1 | #include "declarativepieseries.h" |
|
2 | 2 | #include "declarativechart.h" |
|
3 | 3 | #include "qchart.h" |
|
4 | #include "qpieseries.h" | |
|
5 | 4 | |
|
6 | 5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 6 | |
|
8 |
DeclarativePieSeries::DeclarativePieSeries(Q |
|
|
9 |
Q |
|
|
10 |
m_chart(0) |
|
|
11 | m_series(0) | |
|
7 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : | |
|
8 | QPieSeries(parent), | |
|
9 | m_chart(0) | |
|
12 | 10 | { |
|
13 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
|
14 | connect(this, SIGNAL(parentChanged()), | |
|
15 | this, SLOT(setParentForSeries())); | |
|
16 | 11 | } |
|
17 | 12 | |
|
18 |
void DeclarativePieSeries:: |
|
|
13 | void DeclarativePieSeries::classBegin() | |
|
14 | { | |
|
15 | } | |
|
16 | ||
|
17 | void DeclarativePieSeries::componentComplete() | |
|
19 | 18 | { |
|
20 | if (!m_series) { | |
|
21 | 19 |
|
|
22 | 20 |
|
|
23 | 21 |
|
|
24 | qDebug() << "creating pie series for chart: " << chart; | |
|
25 | 22 |
|
|
26 | ||
|
27 | m_series = new QPieSeries(); | |
|
28 | Q_ASSERT(m_series); | |
|
29 | foreach (QPieSlice* slice, m_data) { | |
|
30 | // Have to duplicate the data | |
|
31 | m_series->add(slice->value(), slice->label()); | |
|
32 | } | |
|
33 | chart->addSeries(m_series); | |
|
34 | //chart->axisY(); | |
|
35 | } | |
|
23 | qDebug() << "parent for pie:" << chart; | |
|
24 | chart->addSeries(this); | |
|
36 | 25 | } |
|
37 | 26 | } |
|
38 | 27 | |
|
39 |
QDeclarativeListProperty<QPieSlice> DeclarativePieSeries:: |
|
|
28 | QDeclarativeListProperty<QPieSlice> DeclarativePieSeries::slices() | |
|
40 | 29 | { |
|
41 |
return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::append |
|
|
30 | return QDeclarativeListProperty<QPieSlice>(this, 0, &DeclarativePieSeries::appendSlice); | |
|
42 | 31 | } |
|
43 | 32 | |
|
44 |
void DeclarativePieSeries::append |
|
|
33 | void DeclarativePieSeries::appendSlice(QDeclarativeListProperty<QPieSlice> *list, | |
|
45 | 34 | QPieSlice *slice) |
|
46 | 35 | { |
|
47 | 36 | DeclarativePieSeries *series = qobject_cast<DeclarativePieSeries *>(list->object); |
|
48 |
if (series) |
|
|
49 | series->m_data.append(slice); | |
|
50 | // Have to duplicate the data | |
|
51 | if (series->m_series) | |
|
52 | series->m_series->add(slice->value(), slice->label()); | |
|
53 | } | |
|
37 | if (series) | |
|
38 | series->add(slice->value(), slice->label()); | |
|
54 | 39 | } |
|
55 | 40 | |
|
56 | 41 | #include "moc_declarativepieseries.cpp" |
@@ -3,35 +3,33 | |||
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include "qpieslice.h" |
|
6 | #include "qpieseries.h" | |
|
6 | 7 | #include <QDeclarativeItem> |
|
7 | 8 | |
|
8 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 10 | |
|
10 | class QPieSeries; | |
|
11 | 11 | class QChart; |
|
12 | 12 | |
|
13 |
class DeclarativePieSeries : public QDeclarative |
|
|
13 | class DeclarativePieSeries : public QPieSeries, public QDeclarativeParserStatus | |
|
14 | 14 | { |
|
15 | 15 | Q_OBJECT |
|
16 | Q_PROPERTY(QDeclarativeListProperty<QPieSlice> data READ data) | |
|
16 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
17 | Q_PROPERTY(QDeclarativeListProperty<QPieSlice> slices READ slices) | |
|
17 | 18 | |
|
18 | 19 | public: |
|
19 |
explicit DeclarativePieSeries(Q |
|
|
20 |
QDeclarativeListProperty<QPieSlice> |
|
|
20 | explicit DeclarativePieSeries(QObject *parent = 0); | |
|
21 | QDeclarativeListProperty<QPieSlice> slices(); | |
|
21 | 22 | |
|
22 | Q_SIGNALS: | |
|
23 | public: // from QDeclarativeParserStatus | |
|
24 | void classBegin(); | |
|
25 | void componentComplete(); | |
|
23 | 26 | |
|
24 | 27 | public Q_SLOTS: |
|
25 |
static void append |
|
|
28 | static void appendSlice(QDeclarativeListProperty<QPieSlice> *list, | |
|
26 | 29 | QPieSlice *element); |
|
27 | 30 | |
|
28 | private Q_SLOTS: | |
|
29 | void setParentForSeries(); | |
|
30 | ||
|
31 | 31 | private: |
|
32 | 32 | QChart *m_chart; |
|
33 | QPieSeries *m_series; | |
|
34 | QList<QPieSlice *> m_data; | |
|
35 | 33 | }; |
|
36 | 34 | |
|
37 | 35 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -5,10 +5,37 | |||
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 7 | |
|
8 |
DeclarativeScatterSeries::DeclarativeScatterSeries(Q |
|
|
9 | DeclarativeXySeries(QSeries::SeriesTypeScatter, parent) | |
|
8 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
|
9 | QScatterSeries(parent) | |
|
10 | 10 | { |
|
11 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
|
11 | } | |
|
12 | ||
|
13 | void DeclarativeScatterSeries::seriesComplete() | |
|
14 | { | |
|
15 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |
|
16 | ||
|
17 | if (declarativeChart) { | |
|
18 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
|
19 | Q_ASSERT(chart); | |
|
20 | qDebug() << "chart:" << chart; | |
|
21 | chart->addSeries(this); | |
|
22 | } | |
|
23 | } | |
|
24 | ||
|
25 | QObject *DeclarativeScatterSeries::seriesObject() | |
|
26 | { | |
|
27 | return this; | |
|
28 | } | |
|
29 | ||
|
30 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() | |
|
31 | { | |
|
32 | return DeclarativeXySeries::points(); | |
|
33 | } | |
|
34 | ||
|
35 | void DeclarativeScatterSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
36 | DeclarativeXyPoint *element) | |
|
37 | { | |
|
38 | DeclarativeXySeries::appendPoints(list, element); | |
|
12 | 39 | } |
|
13 | 40 | |
|
14 | 41 | #include "moc_declarativescatterseries.cpp" |
@@ -2,17 +2,30 | |||
|
2 | 2 | #define DECLARATIVESCATTERSERIES_H |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | #include "qscatterseries.h" | |
|
5 | 6 | #include "declarativexyseries.h" |
|
6 |
#include <QDeclarative |
|
|
7 | #include <QDeclarativeParserStatus> | |
|
7 | 8 | |
|
8 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 10 | |
|
10 | class DeclarativeScatterSeries : public DeclarativeXySeries | |
|
11 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries | |
|
11 | 12 | { |
|
12 | 13 | Q_OBJECT |
|
14 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
|
13 | 15 | |
|
14 | 16 | public: |
|
15 |
explicit DeclarativeScatterSeries(Q |
|
|
17 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
|
18 | ||
|
19 | public: | |
|
20 | void seriesComplete(); | |
|
21 | QObject *seriesObject(); | |
|
22 | ||
|
23 | public: | |
|
24 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
|
25 | ||
|
26 | public slots: | |
|
27 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
28 | DeclarativeXyPoint *element); | |
|
16 | 29 | }; |
|
17 | 30 | |
|
18 | 31 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -2,21 +2,31 | |||
|
2 | 2 | #define DECLARATIVESPLINESERIES_H |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | #include "qsplineseries.h" | |
|
5 | 6 | #include "declarativexyseries.h" |
|
6 |
#include <QDeclarative |
|
|
7 | #include <QDeclarativeParserStatus> | |
|
7 | 8 | |
|
8 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 10 | |
|
10 | class DeclarativeSplineSeries : public DeclarativeXySeries | |
|
11 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |
|
11 | 12 | { |
|
12 | 13 | Q_OBJECT |
|
14 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
|
13 | 15 | |
|
14 | 16 | public: |
|
15 |
explicit DeclarativeSplineSeries(Q |
|
|
16 | DeclarativeXySeries(QSeries::SeriesTypeSpline, parent) {} | |
|
17 | }; | |
|
17 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
|
18 | ||
|
19 | public: | |
|
20 | void seriesComplete(); | |
|
21 | QObject *seriesObject(); | |
|
18 | 22 | |
|
19 | #include "moc_declarativesplineseries.cpp" | |
|
23 | public: | |
|
24 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
|
25 | ||
|
26 | public slots: | |
|
27 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
|
28 | DeclarativeXyPoint *element); | |
|
29 | }; | |
|
20 | 30 | |
|
21 | 31 | QTCOMMERCIALCHART_END_NAMESPACE |
|
22 | 32 |
@@ -5,6 +5,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
5 | 5 | DeclarativeXyPoint::DeclarativeXyPoint(QObject *parent) : |
|
6 | 6 | QObject(parent) |
|
7 | 7 | { |
|
8 | setX(0.0); | |
|
9 | setY(0.0); | |
|
8 | 10 | } |
|
9 | 11 | |
|
10 | 12 | #include "moc_declarativexypoint.cpp" |
@@ -3,10 +3,11 | |||
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include <QObject> |
|
6 | #include <QPointF> | |
|
6 | 7 | |
|
7 | 8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | 9 | |
|
9 | class DeclarativeXyPoint : public QObject | |
|
10 | class DeclarativeXyPoint : public QObject, public QPointF | |
|
10 | 11 | { |
|
11 | 12 | Q_OBJECT |
|
12 | 13 | Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/) |
@@ -14,15 +15,6 class DeclarativeXyPoint : public QObject | |||
|
14 | 15 | |
|
15 | 16 | public: |
|
16 | 17 | explicit DeclarativeXyPoint(QObject *parent = 0); |
|
17 | ||
|
18 | void setX(qreal x) {m_x = x;} | |
|
19 | qreal x() {return m_x;} | |
|
20 | void setY(qreal y) {m_y = y;} | |
|
21 | qreal y() {return m_y;} | |
|
22 | ||
|
23 | public: | |
|
24 | qreal m_x; | |
|
25 | qreal m_y; | |
|
26 | 18 | }; |
|
27 | 19 | |
|
28 | 20 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,86 +1,37 | |||
|
1 | 1 | //#include "DeclarativeXySeries.h" |
|
2 | 2 | #include "declarativexyseries.h" |
|
3 | #include "declarativechart.h" | |
|
4 | #include "qchart.h" | |
|
5 | 3 | #include "qxyseries.h" |
|
6 | #include "qareaseries.h" | |
|
7 | #include "qsplineseries.h" | |
|
8 | #include "qscatterseries.h" | |
|
9 | 4 | |
|
10 | 5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | 6 | |
|
12 |
DeclarativeXySeries::DeclarativeXySeries( |
|
|
13 | QDeclarativeItem(parent), | |
|
14 | m_seriesType(type), | |
|
15 | m_chart(0), | |
|
16 | m_series(0) | |
|
7 | DeclarativeXySeries::DeclarativeXySeries() | |
|
17 | 8 | { |
|
18 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
|
19 | 9 | } |
|
20 | 10 | |
|
21 | 11 | DeclarativeXySeries::~DeclarativeXySeries() |
|
22 | 12 | { |
|
23 | 13 | } |
|
24 | 14 | |
|
25 |
void DeclarativeXySeries::c |
|
|
15 | void DeclarativeXySeries::classBegin() | |
|
26 | 16 | { |
|
27 | Q_ASSERT(!m_series); | |
|
28 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |
|
29 | ||
|
30 | if (declarativeChart) { | |
|
31 | m_chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
|
32 | Q_ASSERT(m_chart); | |
|
33 | ||
|
34 | switch (m_seriesType) { | |
|
35 | case QSeries::SeriesTypeLine: | |
|
36 | qDebug() << "creating line series for chart: " << m_chart; | |
|
37 | m_series = new QLineSeries(); | |
|
38 | break; | |
|
39 | case QSeries::SeriesTypeArea: | |
|
40 | qDebug() << "TODO: creating area series for chart: " << m_chart; | |
|
41 | // m_series = new QAreaSeries(); | |
|
42 | break; | |
|
43 | case QSeries::SeriesTypeSpline: | |
|
44 | qDebug() << "creating spline series for chart: " << m_chart; | |
|
45 | m_series = new QSplineSeries(); | |
|
46 | break; | |
|
47 | case QSeries::SeriesTypeScatter: | |
|
48 | qDebug() << "creating scatter series for chart: " << m_chart; | |
|
49 | m_series = new QScatterSeries(); | |
|
50 | break; | |
|
51 | default: | |
|
52 | Q_ASSERT(false); | |
|
53 | 17 | } |
|
54 | 18 | |
|
55 | for (int i(0); i < m_points.count(); i++) { | |
|
56 | DeclarativeXyPoint *element = m_points.at(i); | |
|
57 | m_series->add(element->x(), element->y()); | |
|
58 | } | |
|
59 | m_chart->addSeries(m_series); | |
|
60 | } | |
|
19 | void DeclarativeXySeries::componentComplete() | |
|
20 | { | |
|
21 | seriesComplete(); | |
|
61 | 22 | } |
|
62 | 23 | |
|
63 | 24 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeXySeries::points() |
|
64 | 25 | { |
|
65 |
return QDeclarativeListProperty<DeclarativeXyPoint>( |
|
|
26 | return QDeclarativeListProperty<DeclarativeXyPoint>(seriesObject(), 0, &DeclarativeXySeries::appendPoints); | |
|
66 | 27 | } |
|
67 | 28 | |
|
68 | 29 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
69 | 30 | DeclarativeXyPoint *element) |
|
70 | 31 | { |
|
71 |
|
|
|
72 | qDebug() << "appendPoints: " << series; | |
|
73 | qDebug() << "appendPoints: " << element; | |
|
74 | qDebug() << "appendPoints: " << element->x(); | |
|
75 | qDebug() << "appendPoints: " << element->y(); | |
|
76 | qDebug() << "appendPoints: " << series->m_series; | |
|
77 | if (series) { | |
|
78 | series->m_points.append(element); | |
|
79 | if (series->m_series) | |
|
80 | series->m_series->add(element->x(), element->y()); | |
|
32 | QXYSeries *series = qobject_cast<QXYSeries *>(list->object); | |
|
33 | if (series) | |
|
34 | series->add(QPointF(element->x(), element->y())); | |
|
81 | 35 | } |
|
82 | } | |
|
83 | ||
|
84 | #include "moc_declarativexyseries.cpp" | |
|
85 | 36 | |
|
86 | 37 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -3,41 +3,35 | |||
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include "declarativexypoint.h" |
|
6 | #include "qxyseries.h" | |
|
7 |
#include <QDeclarative |
|
|
6 | #include <QDeclarativeParserStatus> | |
|
7 | #include <QDeclarativeListProperty> | |
|
8 | 8 | |
|
9 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | 10 | |
|
11 | 11 | class QChart; |
|
12 | 12 | |
|
13 |
class DeclarativeXySeries : public QDeclarative |
|
|
13 | class DeclarativeXySeries : public QDeclarativeParserStatus | |
|
14 | 14 | { |
|
15 | Q_OBJECT | |
|
16 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
|
15 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
17 | 16 | |
|
18 | 17 | public: |
|
19 | explicit DeclarativeXySeries(QSeries::QSeriesType type, QDeclarativeItem *parent = 0); | |
|
18 | explicit DeclarativeXySeries(); | |
|
20 | 19 | ~DeclarativeXySeries(); |
|
21 | 20 | |
|
22 | 21 | public: // from QDeclarativeParserStatus |
|
22 | void classBegin(); | |
|
23 | 23 | void componentComplete(); |
|
24 | 24 | |
|
25 | 25 | public: |
|
26 | 26 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
27 | 27 | |
|
28 | Q_SIGNALS: | |
|
29 | ||
|
30 | 28 | public Q_SLOTS: |
|
31 | 29 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
32 | 30 | DeclarativeXyPoint *element); |
|
33 | 31 | |
|
34 | private Q_SLOTS: | |
|
35 | ||
|
36 | public: | |
|
37 | QSeries::QSeriesType m_seriesType; | |
|
38 | QChart *m_chart; | |
|
39 | QXYSeries *m_series; | |
|
40 | QList<DeclarativeXyPoint *> m_points; | |
|
32 | protected: | |
|
33 | virtual void seriesComplete() = 0; | |
|
34 | virtual QObject *seriesObject() = 0; | |
|
41 | 35 | }; |
|
42 | 36 | |
|
43 | 37 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -24,16 +24,17 RCC_DIR = $$CHART_BUILD_DIR/plugin | |||
|
24 | 24 | SOURCES += \ |
|
25 | 25 | plugin.cpp \ |
|
26 | 26 | declarativechart.cpp \ |
|
27 | declarativexypoint.cpp \ | |
|
28 | 27 | declarativexyseries.cpp \ |
|
28 | declarativexypoint.cpp \ | |
|
29 | 29 | declarativelineseries.cpp \ |
|
30 | declarativesplineseries.cpp \ | |
|
30 | 31 | declarativescatterseries.cpp \ |
|
31 | 32 | declarativepieseries.cpp \ |
|
32 | 33 | declarativebarseries.cpp |
|
33 | 34 | HEADERS += \ |
|
34 | 35 | declarativechart.h \ |
|
35 | declarativexypoint.h \ | |
|
36 | 36 | declarativexyseries.h \ |
|
37 | declarativexypoint.h \ | |
|
37 | 38 | declarativelineseries.h \ |
|
38 | 39 | declarativesplineseries.h \ |
|
39 | 40 | declarativescatterseries.h \ |
@@ -47,9 +47,8 QPainterPath PieSliceItem::shape() const | |||
|
47 | 47 | |
|
48 | 48 | void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) |
|
49 | 49 | { |
|
50 | painter->setClipRect(parentItem()->boundingRect()); | |
|
51 | ||
|
52 | 50 | painter->save(); |
|
51 | painter->setClipRect(parentItem()->boundingRect()); | |
|
53 | 52 | painter->setPen(m_data.m_slicePen); |
|
54 | 53 | painter->setBrush(m_data.m_sliceBrush); |
|
55 | 54 | painter->drawPath(m_slicePath); |
@@ -23,6 +23,8 Rectangle { | |||
|
23 | 23 | // console.log("model:" + myModel.item(0)); |
|
24 | 24 | // myModel.insert(1, {"time":1.4; "speed":41.1 }); |
|
25 | 25 | // scatter.appendData(); |
|
26 | // chart1.theme = Chart.ThemeHighContrast; | |
|
27 | // chart2.theme = Chart.ThemeHighContrast; | |
|
26 | 28 | } |
|
27 | 29 | |
|
28 | 30 | |
@@ -36,21 +38,18 Rectangle { | |||
|
36 | 38 | |
|
37 | 39 | BarSeries { |
|
38 | 40 | barCategories: [ "2008", "2009", "2010", "2011", "2012" ] |
|
39 | // data: [ | |
|
40 | // BarSet { } | |
|
41 | // ] | |
|
42 | 41 |
|
|
43 | 42 | |
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
43 | PieSeries { | |
|
44 | slices: [ | |
|
45 | PieSlice { label: "Volkswagen"; value: 13.5 }, | |
|
46 | PieSlice { label: "Toyota"; value: 10.9 }, | |
|
47 | PieSlice { label: "Ford"; value: 8.6 }, | |
|
48 | PieSlice { label: "Skoda"; value: 8.2 }, | |
|
49 | PieSlice { label: "Volvo"; value: 6.8 }, | |
|
50 | PieSlice { label: "Others"; value: 52.0 } | |
|
51 | ] | |
|
52 | } | |
|
54 | 53 |
|
|
55 | 54 | |
|
56 | 55 | |
@@ -72,13 +71,13 Rectangle { | |||
|
72 | 71 | } |
|
73 | 72 | |
|
74 | 73 | SplineSeries { |
|
75 | id: scatter | |
|
76 | 74 | points: [ |
|
77 | 75 | XyPoint { x: 0.0; y: 0.3 }, |
|
78 | 76 | XyPoint { x: 1.1; y: 3.2 }, |
|
79 | 77 | XyPoint { x: 4.17; y: 3.15 } |
|
80 | 78 | ] |
|
81 | 79 | } |
|
80 | ||
|
82 | 81 | ScatterSeries { |
|
83 | 82 | points: [ |
|
84 | 83 | XyPoint { x: 1.5; y: 1.5 }, |
General Comments 0
You need to be logged in to leave comments.
Login now