@@ -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 |
@@ -1,34 +1,33 | |||||
1 | #ifndef DECLARATIVEBARSERIES_H |
|
1 | #ifndef DECLARATIVEBARSERIES_H | |
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 | |
9 |
|
8 | |||
10 | class QChart; |
|
9 | class QChart; | |
11 | class QBarSeries; |
|
10 | class QBarSeries; | |
12 |
|
11 | |||
13 | class DeclarativeBarSeries : public QDeclarativeItem |
|
12 | class DeclarativeBarSeries : public QDeclarativeItem | |
14 | { |
|
13 | { | |
15 | Q_OBJECT |
|
14 | Q_OBJECT | |
16 |
|
15 | |||
17 | public: |
|
16 | public: | |
18 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
17 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
19 |
|
18 | |||
20 | signals: |
|
19 | signals: | |
21 |
|
20 | |||
22 | public slots: |
|
21 | public slots: | |
23 |
|
22 | |||
24 | private slots: |
|
23 | private slots: | |
25 | void setParentForSeries(); |
|
24 | void setParentForSeries(); | |
26 |
|
25 | |||
27 | private: |
|
26 | private: | |
28 | QChart *m_chart; |
|
27 | QChart *m_chart; | |
29 | QBarSeries *m_series; |
|
28 | QBarSeries *m_series; | |
30 | }; |
|
29 | }; | |
31 |
|
30 | |||
32 | QTCOMMERCIALCHART_END_NAMESPACE |
|
31 | QTCOMMERCIALCHART_END_NAMESPACE | |
33 |
|
32 | |||
34 | #endif // DECLARATIVEBARSERIES_H |
|
33 | #endif // DECLARATIVEBARSERIES_H |
@@ -1,40 +1,45 | |||||
1 | #include "declarativechart.h" |
|
1 | #include "declarativechart.h" | |
2 | #include <QPainter> |
|
2 | #include <QPainter> | |
3 |
|
3 | |||
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
6 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
7 | : QDeclarativeItem(parent), |
|
7 | : QDeclarativeItem(parent), | |
8 | m_chart(new QChart(this)) |
|
8 | m_chart(new QChart(this)) | |
9 | { |
|
9 | { | |
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(); | |
16 | } |
|
21 | } | |
17 |
|
22 | |||
18 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
23 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
19 | { |
|
24 | { | |
20 | Q_UNUSED(oldGeometry) |
|
25 | Q_UNUSED(oldGeometry) | |
21 |
|
26 | |||
22 | if (newGeometry.isValid()) { |
|
27 | if (newGeometry.isValid()) { | |
23 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
28 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
24 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
29 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
25 | } |
|
30 | } | |
26 | } |
|
31 | } | |
27 | } |
|
32 | } | |
28 |
|
33 | |||
29 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
34 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
30 | { |
|
35 | { | |
31 | Q_UNUSED(option) |
|
36 | Q_UNUSED(option) | |
32 | Q_UNUSED(widget) |
|
37 | Q_UNUSED(widget) | |
33 |
|
38 | |||
34 | // TODO: optimized? |
|
39 | // TODO: optimized? | |
35 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
40 | painter->setRenderHint(QPainter::Antialiasing, true); | |
36 | } |
|
41 | } | |
37 |
|
42 | |||
38 | #include "moc_declarativechart.cpp" |
|
43 | #include "moc_declarativechart.cpp" | |
39 |
|
44 | |||
40 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,47 +1,48 | |||||
1 | #ifndef DECLARATIVECHART_H |
|
1 | #ifndef DECLARATIVECHART_H | |
2 | #define DECLARATIVECHART_H |
|
2 | #define DECLARATIVECHART_H | |
3 |
|
3 | |||
4 | #include <QtCore/QtGlobal> |
|
4 | #include <QtCore/QtGlobal> | |
5 | #include <QDeclarativeItem> |
|
5 | #include <QDeclarativeItem> | |
6 | #include <qchart.h> |
|
6 | #include <qchart.h> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class DeclarativeChart : public QDeclarativeItem |
|
10 | class DeclarativeChart : public QDeclarativeItem | |
11 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
11 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
12 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
12 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | Q_ENUMS(ChartTheme) |
|
15 | Q_ENUMS(ChartTheme) | |
16 | Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme) |
|
16 | Q_PROPERTY(ChartTheme theme READ theme WRITE setTheme) | |
17 |
|
17 | |||
18 | public: |
|
18 | public: | |
19 | enum ChartTheme { |
|
19 | enum ChartTheme { | |
20 | ThemeDefault, |
|
20 | ThemeDefault, | |
21 | ThemeLight, |
|
21 | ThemeLight, | |
22 | ThemeBlueCerulean, |
|
22 | ThemeBlueCerulean, | |
23 | ThemeDark, |
|
23 | ThemeDark, | |
24 | ThemeBrownSand, |
|
24 | ThemeBrownSand, | |
25 | ThemeBlueNcs, |
|
25 | ThemeBlueNcs, | |
26 | ThemeIcy, |
|
26 | ThemeIcy, | |
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); | |
33 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
34 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
34 |
|
35 | |||
35 | public: |
|
36 | public: | |
36 | void setTheme(ChartTheme theme) {m_chart->setChartTheme((QChart::ChartTheme) theme);} |
|
37 | void setTheme(ChartTheme theme) {m_chart->setChartTheme((QChart::ChartTheme) theme);} | |
37 | ChartTheme theme(); |
|
38 | ChartTheme theme(); | |
38 |
|
39 | |||
39 | public: |
|
40 | public: | |
40 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
41 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
41 | // multi inheritance, so we now have a QChart as a member instead |
|
42 | // multi inheritance, so we now have a QChart as a member instead | |
42 | QChart *m_chart; |
|
43 | QChart *m_chart; | |
43 | }; |
|
44 | }; | |
44 |
|
45 | |||
45 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | QTCOMMERCIALCHART_END_NAMESPACE | |
46 |
|
47 | |||
47 | #endif // DECLARATIVECHART_H |
|
48 | #endif // DECLARATIVECHART_H |
@@ -1,55 +1,55 | |||||
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 | QDeclarativeItem(parent) | |
10 | { |
|
10 | { | |
11 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
11 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
12 | connect(this, SIGNAL(parentChanged()), |
|
12 | connect(this, SIGNAL(parentChanged()), | |
13 | this, SLOT(setParentForSeries())); |
|
13 | this, SLOT(setParentForSeries())); | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | void DeclarativeLineSeries::setParentForSeries() |
|
16 | void DeclarativeLineSeries::setParentForSeries() | |
17 | { |
|
17 | { | |
18 | if (!m_series) { |
|
18 | if (!m_series) { | |
19 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); |
|
19 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); | |
20 |
|
20 | |||
21 | if (declarativeChart) { |
|
21 | if (declarativeChart) { | |
22 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
22 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
23 | qDebug() << "creating line series for chart: " << chart; |
|
23 | qDebug() << "creating line series for chart: " << chart; | |
24 | Q_ASSERT(chart); |
|
24 | Q_ASSERT(chart); | |
25 |
|
25 | |||
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 |
|
|
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); | |
33 | } |
|
33 | } | |
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< |
|
42 | void DeclarativeLineSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
43 |
|
|
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) { | |
47 | series->m_data.append(element); |
|
47 | series->m_data.append(element); | |
48 | if (series->m_series) |
|
48 | if (series->m_series) | |
49 | series->m_series->add(element->x(), element->y()); |
|
49 | series->m_series->add(element->x(), element->y()); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | #include "moc_declarativelineseries.cpp" |
|
53 | #include "moc_declarativelineseries.cpp" | |
54 |
|
54 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
55 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,39 +1,39 | |||||
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 "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 | |
9 |
|
9 | |||
10 | class QChart; |
|
10 | class QChart; | |
11 | class QLineSeries; |
|
11 | class QLineSeries; | |
12 |
|
12 | |||
13 | class DeclarativeLineSeries : public QDeclarativeItem |
|
13 | class DeclarativeLineSeries : public QDeclarativeItem | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
Q_PROPERTY(QDeclarativeListProperty< |
|
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< |
|
20 | QDeclarativeListProperty<DeclarativeXyPoint> data(); | |
21 |
|
21 | |||
22 | signals: |
|
22 | signals: | |
23 |
|
23 | |||
24 | public slots: |
|
24 | public slots: | |
25 |
static void appendData(QDeclarativeListProperty< |
|
25 | static void appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
26 |
|
|
26 | DeclarativeXyPoint *element); | |
27 |
|
27 | |||
28 | private slots: |
|
28 | private slots: | |
29 | void setParentForSeries(); |
|
29 | void setParentForSeries(); | |
30 |
|
30 | |||
31 | private: |
|
31 | private: | |
32 | QChart *m_chart; |
|
32 | QChart *m_chart; | |
33 | QLineSeries *m_series; |
|
33 | QLineSeries *m_series; | |
34 |
QList< |
|
34 | QList<DeclarativeXyPoint *> m_data; | |
35 | }; |
|
35 | }; | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_END_NAMESPACE |
|
37 | QTCOMMERCIALCHART_END_NAMESPACE | |
38 |
|
38 | |||
39 | #endif // DECLARATIVELINESERIES_H |
|
39 | #endif // DECLARATIVELINESERIES_H |
@@ -1,68 +1,108 | |||||
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 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
8 | |||
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 |
|
|
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 | 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 |
|
|
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 |
|
|
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< |
|
49 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::data() | |
45 | { |
|
50 | { | |
46 |
return QDeclarativeListProperty< |
|
51 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, | |
47 | &DeclarativeScatterSeries::appendData); |
|
52 | &DeclarativeScatterSeries::appendData); | |
48 | } |
|
53 | } | |
49 |
|
54 | |||
50 |
void DeclarativeScatterSeries::appendData(QDeclarativeListProperty< |
|
55 | void DeclarativeScatterSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
51 |
|
|
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; | |
55 | qDebug() << "appendData: " << element; |
|
60 | qDebug() << "appendData: " << element; | |
56 | qDebug() << "appendData: " << element->x(); |
|
61 | qDebug() << "appendData: " << element->x(); | |
57 | qDebug() << "appendData: " << element->y(); |
|
62 | qDebug() << "appendData: " << element->y(); | |
58 | qDebug() << "appendData: " << series->m_series; |
|
63 | qDebug() << "appendData: " << series->m_series; | |
59 | if (series) { |
|
64 | if (series) { | |
60 | series->m_data.append(element); |
|
65 | series->m_data.append(element); | |
61 | if (series->m_series) |
|
66 | if (series->m_series) | |
62 | series->m_series->add(element->x(), element->y()); |
|
67 | series->m_series->add(element->x(), element->y()); | |
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 |
@@ -1,41 +1,61 | |||||
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 " |
|
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< |
|
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 |
|
|
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< |
|
45 | static void appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
26 |
|
|
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 | |
40 |
|
60 | |||
41 | #endif // DECLARATIVESCATTERSERIES_H |
|
61 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,12 +1,12 | |||||
1 |
#include " |
|
1 | #include "declarativexypoint.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 |
|
|
5 | DeclarativeXyPoint::DeclarativeXyPoint(QObject *parent) : | |
6 | QObject(parent) |
|
6 | QObject(parent) | |
7 | { |
|
7 | { | |
8 | } |
|
8 | } | |
9 |
|
9 | |||
10 |
#include "moc_ |
|
10 | #include "moc_declarativexypoint.cpp" | |
11 |
|
11 | |||
12 | QTCOMMERCIALCHART_END_NAMESPACE |
|
12 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,30 +1,30 | |||||
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 |
|
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 |
|
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;} | |
20 | void setY(qreal y) {m_y = y;} |
|
20 | void setY(qreal y) {m_y = y;} | |
21 | qreal y() {return m_y;} |
|
21 | qreal y() {return m_y;} | |
22 |
|
22 | |||
23 | public: |
|
23 | public: | |
24 | qreal m_x; |
|
24 | qreal m_x; | |
25 | qreal m_y; |
|
25 | qreal m_y; | |
26 | }; |
|
26 | }; | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_END_NAMESPACE |
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |
29 |
|
29 | |||
30 |
#endif // |
|
30 | #endif // DECLARATIVE_XY_POINT_H |
@@ -1,37 +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 " |
|
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" | |
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"); | |
|
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, " |
|
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 | |||
31 | #include "plugin.moc" |
|
32 | #include "plugin.moc" | |
32 |
|
33 | |||
33 | QTCOMMERCIALCHART_END_NAMESPACE |
|
34 | QTCOMMERCIALCHART_END_NAMESPACE | |
34 |
|
35 | |||
35 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
36 | QTCOMMERCIALCHART_USE_NAMESPACE | |
36 |
|
37 | |||
37 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
38 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
@@ -1,45 +1,47 | |||||
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 \ |
|
27 | declarativescatterseries.cpp \ | |
28 |
|
|
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 | |
42 | qmldir.files += $$PWD/qmldir |
|
44 | qmldir.files += $$PWD/qmldir | |
43 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
45 | qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
44 |
|
46 | |||
45 | INSTALLS += target qmldir |
|
47 | INSTALLS += target qmldir |
@@ -1,102 +1,142 | |||||
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 |
|
|
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 |
|
|
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 | |
32 | anchors.top: parent.top |
|
67 | anchors.top: parent.top | |
33 | anchors.left: parent.left |
|
68 | anchors.left: parent.left | |
34 | anchors.right: parent.right |
|
69 | anchors.right: parent.right | |
35 | height: parent.height / 2 |
|
70 | height: parent.height / 2 | |
36 | theme: Chart.ThemeBlueCerulean |
|
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 | // 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 |
// |
|
86 | // PieSlice { label: "Ford"; value: 8.6 }, | |
46 |
// |
|
87 | // PieSlice { label: "Skoda"; value: 8.2 }, | |
47 |
// |
|
88 | // PieSlice { label: "Volvo"; value: 6.8 }, | |
48 |
// |
|
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 | } | |
54 |
|
93 | |||
55 |
|
94 | |||
56 | Chart { |
|
95 | Chart { | |
57 | id: chart2 |
|
96 | id: chart2 | |
58 | anchors.top: chart1.bottom |
|
97 | anchors.top: chart1.bottom | |
59 | anchors.bottom: parent.bottom |
|
98 | anchors.bottom: parent.bottom | |
60 | anchors.left: parent.left |
|
99 | anchors.left: parent.left | |
61 | anchors.right: parent.right |
|
100 | anchors.right: parent.right | |
62 | theme: Chart.ThemeScientific |
|
101 | theme: Chart.ThemeScientific | |
63 |
|
102 | |||
64 | LineSeries { |
|
103 | LineSeries { | |
65 | data: [ |
|
104 | data: [ | |
66 |
|
|
105 | XyPoint { x: 0.0; y: 0.0 }, | |
67 |
|
|
106 | XyPoint { x: 1.1; y: 2.1 }, | |
68 |
|
|
107 | XyPoint { x: 2.9; y: 4.9 }, | |
69 |
|
|
108 | XyPoint { x: 3.2; y: 3.0 } | |
70 | ] |
|
109 | ] | |
71 | } |
|
110 | } | |
72 |
|
111 | |||
73 |
|
|
112 | // ScatterSeries { | |
74 |
|
|
113 | // id: scatter | |
75 | ChartPointElement { x: 1.1; y: 1.1 }, |
|
114 | // data: [ | |
76 |
|
|
115 | // XyPoint { x: 1.1; y: 1.1 }, | |
77 |
|
|
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 |
|
|
122 | // XyPoint { x: 1.5; y: 1.5 }, | |
84 |
|
|
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 |
|
|
129 | // XyPoint { x: 2.0; y: 2.0 }, | |
91 |
|
|
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 |
|
|
136 | // XyPoint { x: 2.6; y: 2.6 }, | |
98 |
|
|
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