##// END OF EJS Templates
Set margins to 30 on QML impl
Tero Ahola -
r200:0c7a3adc2f0e
parent child
Show More
@@ -7,7 +7,6 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
7 m_chart(new QChart(this))
7 m_chart(new QChart(this))
8 {
8 {
9 setFlag(QGraphicsItem::ItemHasNoContents, false);
9 setFlag(QGraphicsItem::ItemHasNoContents, false);
10 // m_chart->setMargin(50); // TODO: should not be needed?
11 }
10 }
12
11
13 DeclarativeChart::ChartTheme DeclarativeChart::theme()
12 DeclarativeChart::ChartTheme DeclarativeChart::theme()
@@ -18,8 +17,21 DeclarativeChart::ChartTheme DeclarativeChart::theme()
18
17
19 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
18 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
20 {
19 {
21 if (newGeometry.isValid())
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);
22 m_chart->resize(newGeometry.width(), newGeometry.height());
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 #include "moc_declarativechart.cpp"
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 #include "moc_declarativeseries.cpp"
89 #include "moc_declarativeseries.cpp"
99
90
100 QTCOMMERCIALCHART_END_NAMESPACE
91 QTCOMMERCIALCHART_END_NAMESPACE
@@ -34,9 +34,6 signals:
34 public slots:
34 public slots:
35 void setParentForSeries();
35 void setParentForSeries();
36
36
37 public: // from QDeclarativeItem
38 QVariant itemChange(GraphicsItemChange, const QVariant &);
39
40 public:
37 public:
41 void setSeriesType(SeriesType type);
38 void setSeriesType(SeriesType type);
42 SeriesType seriesType() { return m_seriesType; }
39 SeriesType seriesType() { return m_seriesType; }
@@ -30,8 +30,32 Rectangle {
30 // console.log("Component.onCompleted: " + chartModel.get(0).dataX);
30 // console.log("Component.onCompleted: " + chartModel.get(0).dataX);
31 }
31 }
32
32
33 Chart {
34 id: chart1
35 anchors.top: parent.top
36 anchors.left: parent.left
37 anchors.right: parent.right
38 height: parent.height / 2
39 theme: Chart.ThemeIcy
40 // opacity: 0.3
41
42 Series {
43 seriesType: Series.SeriesTypePie
44 }
45
33 // TODO: a bug: drawing order affects the drawing; if you draw chart1 first (by changing the
46 // 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.
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 // }
52 // TODO:
53 // Series {
54 // seriesType: Series.SeriesTypeBar
55 // }
56 }
57
58
35 Chart {
59 Chart {
36 id: chart2
60 id: chart2
37 anchors.top: chart1.bottom
61 anchors.top: chart1.bottom
@@ -41,37 +65,32 Rectangle {
41 theme: Chart.ThemeScientific
65 theme: Chart.ThemeScientific
42
66
43 ScatterSeries {
67 ScatterSeries {
44 id: scatterSeries
45 data: [
68 data: [
46 ScatterElement { x: 1.1; y: 2.1 },
69 ScatterElement { x: 1.1; y: 2.1 },
47 ScatterElement { x: 1.2; y: 2.0 },
70 ScatterElement { x: 1.2; y: 2.0 },
48 ScatterElement { x: 1.4; y: 2.3 },
71 ScatterElement { x: 1.4; y: 2.3 }
49 ScatterElement { x: 3.1; y: 5.3 },
50 ScatterElement { x: 4.1; y: 3.7 }
51 ]
72 ]
52 }
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 ]
53 }
80 }
54
81 ScatterSeries {
55 Chart {
82 data: [
56 id: chart1
83 ScatterElement { x: 1.3; y: 2.3 },
57 anchors.top: parent.top
84 ScatterElement { x: 1.5; y: 2.4 },
58 anchors.left: parent.left
85 ScatterElement { x: 2.0; y: 2.9 }
59 anchors.right: parent.right
86 ]
60 height: parent.height / 2
61 theme: Chart.ThemeIcy
62 opacity: 0.3
63
64 Series {
65 seriesType: Series.SeriesTypePie
66 }
87 }
67
88 ScatterSeries {
68 Series {
89 data: [
69 seriesType: Series.SeriesTypeLine
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 ]
70 }
94 }
71 // TODO:
72 // Series {
73 // seriesType: Series.SeriesTypeBar
74 // }
75 }
95 }
76
77 }
96 }
General Comments 0
You need to be logged in to leave comments. Login now