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