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