@@ -7,7 +7,6 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |||
|
7 | 7 | m_chart(new QChart(this)) |
|
8 | 8 | { |
|
9 | 9 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
10 | // m_chart->setMargin(50); // TODO: should not be needed? | |
|
11 | 10 | } |
|
12 | 11 | |
|
13 | 12 | DeclarativeChart::ChartTheme DeclarativeChart::theme() |
@@ -18,8 +17,21 DeclarativeChart::ChartTheme DeclarativeChart::theme() | |||
|
18 | 17 | |
|
19 | 18 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
20 | 19 | { |
|
21 | if (newGeometry.isValid()) | |
|
22 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
|
20 | qDebug() << "geometryChanged " << this << " old geometry: " << oldGeometry; | |
|
21 | if (newGeometry.isValid()) { | |
|
22 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
|
23 | // TODO: setting margin should not be needed to make axis visible? | |
|
24 | const int margin = 30; | |
|
25 | if (m_chart->margin() == 0 | |
|
26 | && newGeometry.width() > (margin * 2) | |
|
27 | && newGeometry.height() > (margin * 2)) { | |
|
28 | m_chart->setMargin(margin); | |
|
29 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
|
30 | } else { | |
|
31 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
|
32 | } | |
|
33 | } | |
|
34 | } | |
|
23 | 35 | } |
|
24 | 36 | |
|
25 | 37 | #include "moc_declarativechart.cpp" |
@@ -86,15 +86,6 void DeclarativeSeries::initSeries() | |||
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | QVariant DeclarativeSeries::itemChange(GraphicsItemChange change, | |
|
90 | const QVariant &value) | |
|
91 | { | |
|
92 | // For debugging purposes only: | |
|
93 | // qDebug() << QString::number(change) << " : " << value.toString(); | |
|
94 | return QGraphicsItem::itemChange(change, value); | |
|
95 | } | |
|
96 | ||
|
97 | ||
|
98 | 89 | #include "moc_declarativeseries.cpp" |
|
99 | 90 | |
|
100 | 91 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -34,9 +34,6 signals: | |||
|
34 | 34 | public slots: |
|
35 | 35 | void setParentForSeries(); |
|
36 | 36 | |
|
37 | public: // from QDeclarativeItem | |
|
38 | QVariant itemChange(GraphicsItemChange, const QVariant &); | |
|
39 | ||
|
40 | 37 | public: |
|
41 | 38 | void setSeriesType(SeriesType type); |
|
42 | 39 | SeriesType seriesType() { return m_seriesType; } |
@@ -30,28 +30,6 Rectangle { | |||
|
30 | 30 | // console.log("Component.onCompleted: " + chartModel.get(0).dataX); |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | // TODO: a bug: drawing order affects the drawing; if you draw chart1 first (by changing the | |
|
34 | // z-order), then chart2 is not shown at all. By drawing chart2 first, both are visible. | |
|
35 | Chart { | |
|
36 | id: chart2 | |
|
37 | anchors.top: chart1.bottom | |
|
38 | anchors.bottom: parent.bottom | |
|
39 | anchors.left: parent.left | |
|
40 | anchors.right: parent.right | |
|
41 | theme: Chart.ThemeScientific | |
|
42 | ||
|
43 | ScatterSeries { | |
|
44 | id: scatterSeries | |
|
45 | data: [ | |
|
46 | ScatterElement { x: 1.1; y: 2.1 }, | |
|
47 | ScatterElement { x: 1.2; y: 2.0 }, | |
|
48 | ScatterElement { x: 1.4; y: 2.3 }, | |
|
49 | ScatterElement { x: 3.1; y: 5.3 }, | |
|
50 | ScatterElement { x: 4.1; y: 3.7 } | |
|
51 | ] | |
|
52 | } | |
|
53 | } | |
|
54 | ||
|
55 | 33 | Chart { |
|
56 | 34 | id: chart1 |
|
57 | 35 | anchors.top: parent.top |
@@ -59,19 +37,60 Rectangle { | |||
|
59 | 37 | anchors.right: parent.right |
|
60 | 38 | height: parent.height / 2 |
|
61 | 39 | theme: Chart.ThemeIcy |
|
62 |
|
|
|
40 | // opacity: 0.3 | |
|
63 | 41 | |
|
64 | 42 | Series { |
|
65 | 43 | seriesType: Series.SeriesTypePie |
|
66 | 44 | } |
|
67 | 45 | |
|
68 | Series { | |
|
69 | seriesType: Series.SeriesTypeLine | |
|
70 | } | |
|
46 | // TODO: a bug: drawing order affects the drawing; if you draw chart1 first (by changing the | |
|
47 | // z-order), then chart2 is not shown at all. By drawing chart2 first, both are visible. | |
|
48 | // Also, if you don't draw line series on chart1 (only pie), both charts are visible. | |
|
49 | // Series { | |
|
50 | // seriesType: Series.SeriesTypeLine | |
|
51 | // } | |
|
71 | 52 | // TODO: |
|
72 | 53 |
|
|
73 | 54 | // seriesType: Series.SeriesTypeBar |
|
74 | 55 | // } |
|
75 | 56 | } |
|
76 | 57 | |
|
58 | ||
|
59 | Chart { | |
|
60 | id: chart2 | |
|
61 | anchors.top: chart1.bottom | |
|
62 | anchors.bottom: parent.bottom | |
|
63 | anchors.left: parent.left | |
|
64 | anchors.right: parent.right | |
|
65 | theme: Chart.ThemeScientific | |
|
66 | ||
|
67 | ScatterSeries { | |
|
68 | data: [ | |
|
69 | ScatterElement { x: 1.1; y: 2.1 }, | |
|
70 | ScatterElement { x: 1.2; y: 2.0 }, | |
|
71 | ScatterElement { x: 1.4; y: 2.3 } | |
|
72 | ] | |
|
73 | } | |
|
74 | ScatterSeries { | |
|
75 | data: [ | |
|
76 | ScatterElement { x: 1.2; y: 2.2 }, | |
|
77 | ScatterElement { x: 1.3; y: 2.2 }, | |
|
78 | ScatterElement { x: 1.7; y: 2.6 } | |
|
79 | ] | |
|
80 | } | |
|
81 | ScatterSeries { | |
|
82 | data: [ | |
|
83 | ScatterElement { x: 1.3; y: 2.3 }, | |
|
84 | ScatterElement { x: 1.5; y: 2.4 }, | |
|
85 | ScatterElement { x: 2.0; y: 2.9 } | |
|
86 | ] | |
|
87 | } | |
|
88 | ScatterSeries { | |
|
89 | data: [ | |
|
90 | ScatterElement { x: 1.4; y: 2.4 }, | |
|
91 | ScatterElement { x: 1.8; y: 2.7 }, | |
|
92 | ScatterElement { x: 2.5; y: 3.2 } | |
|
93 | ] | |
|
94 | } | |
|
95 | } | |
|
77 | 96 | } |
General Comments 0
You need to be logged in to leave comments.
Login now