##// 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;
22 m_chart->resize(newGeometry.width(), newGeometry.height());
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 #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,28 +30,6 Rectangle {
30 // console.log("Component.onCompleted: " + chartModel.get(0).dataX);
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 Chart {
33 Chart {
56 id: chart1
34 id: chart1
57 anchors.top: parent.top
35 anchors.top: parent.top
@@ -59,19 +37,60 Rectangle {
59 anchors.right: parent.right
37 anchors.right: parent.right
60 height: parent.height / 2
38 height: parent.height / 2
61 theme: Chart.ThemeIcy
39 theme: Chart.ThemeIcy
62 opacity: 0.3
40 // opacity: 0.3
63
41
64 Series {
42 Series {
65 seriesType: Series.SeriesTypePie
43 seriesType: Series.SeriesTypePie
66 }
44 }
67
45
68 Series {
46 // TODO: a bug: drawing order affects the drawing; if you draw chart1 first (by changing the
69 seriesType: Series.SeriesTypeLine
47 // z-order), then chart2 is not shown at all. By drawing chart2 first, both are visible.
70 }
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 // TODO:
52 // TODO:
72 // Series {
53 // Series {
73 // seriesType: Series.SeriesTypeBar
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