##// END OF EJS Templates
d
Tero Ahola -
r722:3c81c15bc4ba
parent child
Show More
@@ -0,0 +1,52
1 #include "declarativetablemodel.h"
2 #include <QDebug>
3
4 DeclarativeTableModel::DeclarativeTableModel(QObject *parent) :
5 QAbstractTableModel(parent)
6 {
7 }
8
9 int DeclarativeTableModel::rowCount(const QModelIndex &/*parent*/) const
10 {
11 return 5;
12 }
13
14 int DeclarativeTableModel::columnCount(const QModelIndex &/*parent*/) const
15 {
16 return 4;
17 }
18
19 QVariant DeclarativeTableModel::headerData(int /*section*/, Qt::Orientation /*orientation*/, int /*role*/) const
20 {
21 return QString("headerData");
22 }
23
24 QVariant DeclarativeTableModel::data(const QModelIndex &index, int /*role*/) const
25 {
26 // return QString("data") + QString::number(index.row()) + QString::number(index.column());
27 QObject *element = this->findChild<QObject*>("ListElement");
28 if (element)
29 qDebug() << "property: " << element->property("time");
30 // element->setProperty("time", "0.1");
31 return index.row() + index.column();
32 }
33
34 bool DeclarativeTableModel::setData(const QModelIndex &/*index*/, const QVariant &/*value*/, int /*role*/)
35 {
36 return true;
37 }
38
39 Qt::ItemFlags DeclarativeTableModel::flags(const QModelIndex &/*index*/) const
40 {
41 return 0;
42 }
43
44 bool DeclarativeTableModel::insertRows(int /*row*/, int /*count*/, const QModelIndex &/*parent*/)
45 {
46 return true;
47 }
48
49 bool DeclarativeTableModel::removeRows(int /*row*/, int /*count*/, const QModelIndex &/*parent*/)
50 {
51 return true;
52 }
@@ -0,0 +1,28
1 #ifndef DECLARATIVETABLEMODEL_H
2 #define DECLARATIVETABLEMODEL_H
3
4 #include <QAbstractTableModel>
5
6 class DeclarativeTableModel : public QAbstractTableModel
7 {
8 Q_OBJECT
9 public:
10 explicit DeclarativeTableModel(QObject *parent = 0);
11
12 public:
13 int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
14 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
15 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
16 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
17 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
18 Qt::ItemFlags flags ( const QModelIndex & index ) const;
19 bool insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
20 bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
21
22 signals:
23
24 public slots:
25
26 };
27
28 #endif // DECLARATIVETABLEMODEL_H
@@ -2,7 +2,6
2 #define DECLARATIVEBARSERIES_H
2 #define DECLARATIVEBARSERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "scatterelement.h" // TODO: rename header
6 #include <QDeclarativeItem>
5 #include <QDeclarativeItem>
7
6
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -10,6 +10,11 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
10 setFlag(QGraphicsItem::ItemHasNoContents, false);
10 setFlag(QGraphicsItem::ItemHasNoContents, false);
11 }
11 }
12
12
13 DeclarativeChart::~DeclarativeChart()
14 {
15 delete m_chart;
16 }
17
13 DeclarativeChart::ChartTheme DeclarativeChart::theme()
18 DeclarativeChart::ChartTheme DeclarativeChart::theme()
14 {
19 {
15 return (ChartTheme) m_chart->chartTheme();
20 return (ChartTheme) m_chart->chartTheme();
@@ -27,6 +27,7 public:
27 ThemeScientific
27 ThemeScientific
28 };
28 };
29 DeclarativeChart(QDeclarativeItem *parent = 0);
29 DeclarativeChart(QDeclarativeItem *parent = 0);
30 ~DeclarativeChart();
30
31
31 public: // From QDeclarativeItem/QGraphicsItem
32 public: // From QDeclarativeItem/QGraphicsItem
32 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
33 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
@@ -26,7 +26,7 void DeclarativeLineSeries::setParentForSeries()
26 m_series = new QLineSeries();
26 m_series = new QLineSeries();
27 Q_ASSERT(m_series);
27 Q_ASSERT(m_series);
28 for (int i(0); i < m_data.count(); i++) {
28 for (int i(0); i < m_data.count(); i++) {
29 ScatterElement *element = m_data.at(i);
29 DeclarativeXyPoint *element = m_data.at(i);
30 m_series->add(element->x(), element->y());
30 m_series->add(element->x(), element->y());
31 }
31 }
32 chart->addSeries(m_series);
32 chart->addSeries(m_series);
@@ -34,13 +34,13 void DeclarativeLineSeries::setParentForSeries()
34 }
34 }
35 }
35 }
36
36
37 QDeclarativeListProperty<ScatterElement> DeclarativeLineSeries::data()
37 QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::data()
38 {
38 {
39 return QDeclarativeListProperty<ScatterElement>(this, 0, &DeclarativeLineSeries::appendData);
39 return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeLineSeries::appendData);
40 }
40 }
41
41
42 void DeclarativeLineSeries::appendData(QDeclarativeListProperty<ScatterElement> *list,
42 void DeclarativeLineSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list,
43 ScatterElement *element)
43 DeclarativeXyPoint *element)
44 {
44 {
45 DeclarativeLineSeries *series = qobject_cast<DeclarativeLineSeries *>(list->object);
45 DeclarativeLineSeries *series = qobject_cast<DeclarativeLineSeries *>(list->object);
46 if (series) {
46 if (series) {
@@ -2,7 +2,7
2 #define DECLARATIVELINESERIES_H
2 #define DECLARATIVELINESERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "scatterelement.h" // TODO: rename header
5 #include "declarativexypoint.h"
6 #include <QDeclarativeItem>
6 #include <QDeclarativeItem>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -13,17 +13,17 class QLineSeries;
13 class DeclarativeLineSeries : public QDeclarativeItem
13 class DeclarativeLineSeries : public QDeclarativeItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 Q_PROPERTY(QDeclarativeListProperty<ScatterElement> data READ data)
16 Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> data READ data)
17
17
18 public:
18 public:
19 explicit DeclarativeLineSeries(QDeclarativeItem *parent = 0);
19 explicit DeclarativeLineSeries(QDeclarativeItem *parent = 0);
20 QDeclarativeListProperty<ScatterElement> data();
20 QDeclarativeListProperty<DeclarativeXyPoint> data();
21
21
22 signals:
22 signals:
23
23
24 public slots:
24 public slots:
25 static void appendData(QDeclarativeListProperty<ScatterElement> *list,
25 static void appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list,
26 ScatterElement *element);
26 DeclarativeXyPoint *element);
27
27
28 private slots:
28 private slots:
29 void setParentForSeries();
29 void setParentForSeries();
@@ -31,7 +31,7 private slots:
31 private:
31 private:
32 QChart *m_chart;
32 QChart *m_chart;
33 QLineSeries *m_series;
33 QLineSeries *m_series;
34 QList<ScatterElement *> m_data;
34 QList<DeclarativeXyPoint *> m_data;
35 };
35 };
36
36
37 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,5 +1,6
1 #include "declarativescatterseries.h"
1 #include "declarativescatterseries.h"
2 #include "declarativechart.h"
2 #include "declarativechart.h"
3 #include "declarativetablemodel.h"
3 #include "qchart.h"
4 #include "qchart.h"
4 #include "qscatterseries.h"
5 #include "qscatterseries.h"
5
6
@@ -8,47 +9,51 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 DeclarativeScatterSeries::DeclarativeScatterSeries(QDeclarativeItem *parent) :
9 DeclarativeScatterSeries::DeclarativeScatterSeries(QDeclarativeItem *parent) :
9 QDeclarativeItem(parent),
10 QDeclarativeItem(parent),
10 m_chart(0),
11 m_chart(0),
11 m_series(0)
12 m_series(0),
13 m_model(0),
14 m_xColumn(0),
15 m_yColumn(1)
12 {
16 {
13 setFlag(QGraphicsItem::ItemHasNoContents, false);
17 setFlag(QGraphicsItem::ItemHasNoContents, false);
14 connect(this, SIGNAL(parentChanged()),
15 this, SLOT(setParentForSeries()));
16 }
18 }
17
19
18 void DeclarativeScatterSeries::setParentForSeries()
20 DeclarativeScatterSeries::~DeclarativeScatterSeries()
19 {
21 {
20 if (!m_series)
21 initSeries();
22 }
22 }
23
23
24 void DeclarativeScatterSeries::initSeries()
24 void DeclarativeScatterSeries::componentComplete()
25 {
25 {
26 Q_ASSERT(!m_series);
26 Q_ASSERT(!m_series);
27 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
27 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
28
28
29 if (declarativeChart) {
29 if (declarativeChart) {
30 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
30 m_chart = qobject_cast<QChart *>(declarativeChart->m_chart);
31 qDebug() << "creating scatter series for chart: " << chart;
31 qDebug() << "creating scatter series for chart: " << m_chart;
32 Q_ASSERT(chart);
32 Q_ASSERT(m_chart);
33
33
34 m_series = new QScatterSeries();
34 m_series = new QScatterSeries();
35 Q_ASSERT(m_series);
35 // if (!m_model)
36 // m_model = new DeclarativeTableModel();
37 if (m_model) {
38 m_series->setModel(m_model);
39 m_series->setModelMapping(m_xColumn, m_yColumn);
40 }
36 for (int i(0); i < m_data.count(); i++) {
41 for (int i(0); i < m_data.count(); i++) {
37 ScatterElement *element = m_data.at(i);
42 DeclarativeXyPoint *element = m_data.at(i);
38 *m_series << QPointF(element->x(), element->y());
43 *m_series << QPointF(element->x(), element->y());
39 }
44 }
40 chart->addSeries(m_series);
45 m_chart->addSeries(m_series);
41 }
46 }
42 }
47 }
43
48
44 QDeclarativeListProperty<ScatterElement> DeclarativeScatterSeries::data()
49 QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::data()
45 {
50 {
46 return QDeclarativeListProperty<ScatterElement>(this, 0,
51 return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0,
47 &DeclarativeScatterSeries::appendData);
52 &DeclarativeScatterSeries::appendData);
48 }
53 }
49
54
50 void DeclarativeScatterSeries::appendData(QDeclarativeListProperty<ScatterElement> *list,
55 void DeclarativeScatterSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list,
51 ScatterElement *element)
56 DeclarativeXyPoint *element)
52 {
57 {
53 DeclarativeScatterSeries *series = qobject_cast<DeclarativeScatterSeries *>(list->object);
58 DeclarativeScatterSeries *series = qobject_cast<DeclarativeScatterSeries *>(list->object);
54 qDebug() << "appendData: " << series;
59 qDebug() << "appendData: " << series;
@@ -63,6 +68,41 void DeclarativeScatterSeries::appendData(QDeclarativeListProperty<ScatterElemen
63 }
68 }
64 }
69 }
65
70
71 DeclarativeTableModel *DeclarativeScatterSeries::model()
72 {
73 if (m_series)
74 return (DeclarativeTableModel *) m_series->model();
75 else
76 return m_model;
77 }
78
79 void DeclarativeScatterSeries::setModel(DeclarativeTableModel *model)
80 {
81 m_model = model;
82 if (m_chart && m_series) {
83 // Hack: remove and add the series to force an update for the chart range
84 m_chart->removeSeries(m_series);
85 m_series = new QScatterSeries();
86 m_series->setModel(m_model);
87 m_series->setModelMapping(m_xColumn, m_yColumn);
88 m_chart->addSeries(m_series);
89 }
90 }
91
92 void DeclarativeScatterSeries::setXColumn(int xColumn)
93 {
94 m_xColumn = xColumn;
95 if (m_series && m_series->model())
96 m_series->setModelMapping(m_xColumn, m_yColumn);
97 }
98
99 void DeclarativeScatterSeries::setYColumn(int yColumn)
100 {
101 m_yColumn = yColumn;
102 if (m_series && m_series->model())
103 m_series->setModelMapping(m_xColumn, m_yColumn);
104 }
105
66 #include "moc_declarativescatterseries.cpp"
106 #include "moc_declarativescatterseries.cpp"
67
107
68 QTCOMMERCIALCHART_END_NAMESPACE
108 QTCOMMERCIALCHART_END_NAMESPACE
@@ -2,38 +2,58
2 #define DECLARATIVESCATTERSERIES_H
2 #define DECLARATIVESCATTERSERIES_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "scatterelement.h"
5 #include "declarativetablemodel.h"
6 #include "declarativexypoint.h"
6 #include <QDeclarativeItem>
7 #include <QDeclarativeItem>
8 #include <QDeclarativeParserStatus>
7
9
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
11
10 class QChart;
12 class QChart;
11 class QScatterSeries;
13 class QScatterSeries;
12
14
13 class DeclarativeScatterSeries : public QDeclarativeItem
15 class DeclarativeScatterSeries : public QDeclarativeItem//, public QDeclarativeParserStatus
14 {
16 {
15 Q_OBJECT
17 Q_OBJECT
16 Q_PROPERTY(QDeclarativeListProperty<ScatterElement> data READ data)
18 Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> data READ data)
19 Q_PROPERTY(DeclarativeTableModel *model READ model WRITE setModel)
20 // Q_PROPERTY(QObject *listModel READ listModel WRITE setListModel)
21 Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn)
22 Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn)
17
23
18 public:
24 public:
19 explicit DeclarativeScatterSeries(QDeclarativeItem *parent = 0);
25 explicit DeclarativeScatterSeries(QDeclarativeItem *parent = 0);
20 QDeclarativeListProperty<ScatterElement> data();
26 ~DeclarativeScatterSeries();
27
28 public: // from QDeclarativeParserStatus
29 void componentComplete();
30
31 public:
32 QDeclarativeListProperty<DeclarativeXyPoint> data();
33 DeclarativeTableModel *model();
34 void setModel(DeclarativeTableModel *model);
35 //QObject *listModel();
36 //void setListModel(QObject *model);
37 int xColumn() { return m_xColumn; }
38 void setXColumn(int xColumn);
39 int yColumn() { return m_yColumn; }
40 void setYColumn(int yColumn);
21
41
22 signals:
42 signals:
23
43
24 public slots:
44 public slots:
25 static void appendData(QDeclarativeListProperty<ScatterElement> *list,
45 static void appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list,
26 ScatterElement *element);
46 DeclarativeXyPoint *element);
27
47
28 private slots:
48 private slots:
29 void setParentForSeries();
30
49
31 public:
50 public:
32 void initSeries();
51 QChart *m_chart; // not owned
33
52 QScatterSeries *m_series; // not owned
34 QChart *m_chart;
53 DeclarativeTableModel *m_model; // not owned
35 QScatterSeries *m_series;
54 QList<DeclarativeXyPoint *> m_data;
36 QList<ScatterElement *> m_data;
55 int m_xColumn;
56 int m_yColumn;
37 };
57 };
38
58
39 QTCOMMERCIALCHART_END_NAMESPACE
59 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,12 +1,12
1 #include "scatterelement.h"
1 #include "declarativexypoint.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 ScatterElement::ScatterElement(QObject *parent) :
5 DeclarativeXyPoint::DeclarativeXyPoint(QObject *parent) :
6 QObject(parent)
6 QObject(parent)
7 {
7 {
8 }
8 }
9
9
10 #include "moc_scatterelement.cpp"
10 #include "moc_declarativexypoint.cpp"
11
11
12 QTCOMMERCIALCHART_END_NAMESPACE
12 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,19 +1,19
1 #ifndef SCATTERELEMENT_H
1 #ifndef DECLARATIVE_XY_POINT_H
2 #define SCATTERELEMENT_H
2 #define DECLARATIVE_XY_POINT_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include <QObject>
5 #include <QObject>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 class ScatterElement : public QObject
9 class DeclarativeXyPoint : public QObject
10 {
10 {
11 Q_OBJECT
11 Q_OBJECT
12 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
12 Q_PROPERTY(qreal x READ x WRITE setX /*NOTIFY dataXChanged*/)
13 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
13 Q_PROPERTY(qreal y READ y WRITE setY /*NOTIFY dataYChanged*/)
14
14
15 public:
15 public:
16 explicit ScatterElement(QObject *parent = 0);
16 explicit DeclarativeXyPoint(QObject *parent = 0);
17
17
18 void setX(qreal x) {m_x = x;}
18 void setX(qreal x) {m_x = x;}
19 qreal x() {return m_x;}
19 qreal x() {return m_x;}
@@ -27,4 +27,4 public:
27
27
28 QTCOMMERCIALCHART_END_NAMESPACE
28 QTCOMMERCIALCHART_END_NAMESPACE
29
29
30 #endif // SCATTERELEMENT_H
30 #endif // DECLARATIVE_XY_POINT_H
@@ -1,7 +1,8
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 "scatterelement.h"
4 #include "declarativetablemodel.h"
5 #include "declarativexypoint.h"
5 #include "declarativescatterseries.h"
6 #include "declarativescatterseries.h"
6 #include "declarativelineseries.h"
7 #include "declarativelineseries.h"
7 #include "declarativebarseries.h"
8 #include "declarativebarseries.h"
@@ -18,13 +19,13 public:
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");
22 qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartTableModel");
23 qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint");
21 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
24 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
22 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
25 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
23 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
26 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
24 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
27 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
25 qmlRegisterType<QPieSlice>(uri, 1, 0, "ChartPieElement");
28 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
26 // TODO: rename ScatterElement class to something like "PointElement"
27 qmlRegisterType<ScatterElement>(uri, 1, 0, "ChartPointElement");
28 }
29 }
29 };
30 };
30
31
@@ -25,17 +25,19 SOURCES += \
25 plugin.cpp \
25 plugin.cpp \
26 declarativechart.cpp \
26 declarativechart.cpp \
27 declarativescatterseries.cpp \
27 declarativescatterseries.cpp \
28 scatterelement.cpp \
28 declarativexypoint.cpp \
29 declarativepieseries.cpp \
29 declarativepieseries.cpp \
30 declarativelineseries.cpp \
30 declarativelineseries.cpp \
31 declarativebarseries.cpp
31 declarativebarseries.cpp \
32 declarativetablemodel.cpp
32 HEADERS += \
33 HEADERS += \
33 declarativechart.h \
34 declarativechart.h \
34 declarativescatterseries.h \
35 declarativescatterseries.h \
35 scatterelement.h \
36 declarativexypoint.h \
36 declarativepieseries.h \
37 declarativepieseries.h \
37 declarativelineseries.h \
38 declarativelineseries.h \
38 declarativebarseries.h
39 declarativebarseries.h \
40 declarativetablemodel.h
39
41
40 TARGETPATH = QtCommercial/Chart
42 TARGETPATH = QtCommercial/Chart
41 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
43 target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
@@ -20,12 +20,47 Rectangle {
20 // }
20 // }
21
21
22 Component.onCompleted: {
22 Component.onCompleted: {
23 // console.log("Component.onCompleted: " + chartModel.get(0).dataX);
23 console.log("model: " + myModel);
24 // console.log("model:" + myModel.item(0));
25 // myModel.insert(1, {"time":1.4; "speed":41.1 });
26 // scatter.appendData();
24 }
27 }
25
28
26 // ChartModel {
29 ListModel {
27 // id: dynamicData
30 ListElement {
28 // }
31 time: 0.0
32 speed: 45.2
33 }
34 }
35 ChartTableModel {
36 id: myModel
37
38 // ListElement {
39 // time: 0.0
40 // speed: 45.2
41 // }
42 // ListElement {
43 // time: 0.5
44 // speed: 48.9
45 // }
46 // ListElement {
47 // time: 1.1
48 // speed: 42.6
49 // }
50
51 // ChartTableElement {
52 // time: 0.0
53 // speed: 45.2
54 // }
55 // ChartTableElement {
56 // time: 0.5
57 // speed: 48.9
58 // }
59 // ChartTableElement {
60 // time: 1.1
61 // speed: 42.6
62 // }
63 }
29
64
30 Chart {
65 Chart {
31 id: chart1
66 id: chart1
@@ -35,19 +70,23 Rectangle {
35 height: parent.height / 2
70 height: parent.height / 2
36 theme: Chart.ThemeBlueCerulean
71 theme: Chart.ThemeBlueCerulean
37
72
38 BarSeries {
73 // BarSeries {
74 // }
75
76 ScatterSeries {
77 model: myModel
78 // xColumn: time
79 // yColumn: speed
39 }
80 }
40
81
41 // PieSeries {
82 // PieSeries {
42 // data: [
83 // data: [
43 // // TODO: "NnElement" matches the naming convention of for example ListModel...
84 // PieSlice { label: "Volkswagen"; value: 13.5 },
44 // // But PieSlice would match the naming of QtCommercial Charts C++ api
85 // PieSlice { label: "Toyota"; value: 10.9 },
45 // ChartPieElement { label: "Volkswagen"; value: 13.5 },
86 // PieSlice { label: "Ford"; value: 8.6 },
46 // ChartPieElement { label: "Toyota"; value: 10.9 },
87 // PieSlice { label: "Skoda"; value: 8.2 },
47 // ChartPieElement { label: "Ford"; value: 8.6 },
88 // PieSlice { label: "Volvo"; value: 6.8 },
48 // ChartPieElement { label: "Skoda"; value: 8.2 },
89 // PieSlice { label: "Others"; value: 52.0 }
49 // ChartPieElement { label: "Volvo"; value: 6.8 },
50 // ChartPieElement { label: "Others"; value: 52.0 }
51 // ]
90 // ]
52 // }
91 // }
53 }
92 }
@@ -63,40 +102,41 Rectangle {
63
102
64 LineSeries {
103 LineSeries {
65 data: [
104 data: [
66 ChartPointElement { x: 0.0; y: 0.0 },
105 XyPoint { x: 0.0; y: 0.0 },
67 ChartPointElement { x: 1.1; y: 2.1 },
106 XyPoint { x: 1.1; y: 2.1 },
68 ChartPointElement { x: 2.9; y: 4.9 },
107 XyPoint { x: 2.9; y: 4.9 },
69 ChartPointElement { x: 3.2; y: 3.0 }
108 XyPoint { x: 3.2; y: 3.0 }
70 ]
109 ]
71 }
110 }
72
111
73 ScatterSeries {
112 // ScatterSeries {
74 data: [
113 // id: scatter
75 ChartPointElement { x: 1.1; y: 1.1 },
114 // data: [
76 ChartPointElement { x: 1.1; y: 1.2 },
115 // XyPoint { x: 1.1; y: 1.1 },
77 ChartPointElement { x: 1.17; y: 1.15 }
116 // XyPoint { x: 1.1; y: 1.2 },
78 ]
117 // XyPoint { x: 1.17; y: 1.15 }
79 }
118 // ]
80 ScatterSeries {
119 // }
81 data: [
120 // ScatterSeries {
82 ChartPointElement { x: 1.5; y: 1.5 },
121 // data: [
83 ChartPointElement { x: 1.5; y: 1.6 },
122 // XyPoint { x: 1.5; y: 1.5 },
84 ChartPointElement { x: 1.57; y: 1.55 }
123 // XyPoint { x: 1.5; y: 1.6 },
85 ]
124 // XyPoint { x: 1.57; y: 1.55 }
86 }
125 // ]
87 ScatterSeries {
126 // }
88 data: [
127 // ScatterSeries {
89 ChartPointElement { x: 2.0; y: 2.0 },
128 // data: [
90 ChartPointElement { x: 2.0; y: 2.1 },
129 // XyPoint { x: 2.0; y: 2.0 },
91 ChartPointElement { x: 2.07; y: 2.05 }
130 // XyPoint { x: 2.0; y: 2.1 },
92 ]
131 // XyPoint { x: 2.07; y: 2.05 }
93 }
132 // ]
94 ScatterSeries {
133 // }
95 data: [
134 // ScatterSeries {
96 ChartPointElement { x: 2.6; y: 2.6 },
135 // data: [
97 ChartPointElement { x: 2.6; y: 2.7 },
136 // XyPoint { x: 2.6; y: 2.6 },
98 ChartPointElement { x: 2.67; y: 2.65 }
137 // XyPoint { x: 2.6; y: 2.7 },
99 ]
138 // XyPoint { x: 2.67; y: 2.65 }
100 }
139 // ]
140 // }
101 }
141 }
102 }
142 }
General Comments 0
You need to be logged in to leave comments. Login now