##// END OF EJS Templates
Added mapToXxx methods to ChartView...
Titta Heikkala -
r2786:956ee548c718
parent child
Show More
@@ -250,6 +250,17 QT_CHARTS_BEGIN_NAMESPACE
250 */
250 */
251
251
252 /*!
252 /*!
253 \qmlmethod point ChartView::mapToValue(point position, AbstractSeries series)
254 Returns the value in the \a series domain that corresponds to the \a position relative to the
255 chart.
256 */
257
258 /*!
259 \qmlmethod point ChartView::mapToPosition(point value, AbstractSeries series)
260 Returns the position on the chart that corresponds to the \a value in the \a series domain.
261 */
262
263 /*!
253 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
264 \qmlsignal ChartView::seriesAdded(AbstractSeries series)
254 The \a series has been added to the chart.
265 The \a series has been added to the chart.
255 */
266 */
@@ -1037,6 +1048,16 void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes
1037 axes->setAxisY(defaultAxis(Qt::Vertical, series));
1048 axes->setAxisY(defaultAxis(Qt::Vertical, series));
1038 }
1049 }
1039
1050
1051 QPointF DeclarativeChart::mapToValue(const QPointF &position, QAbstractSeries *series)
1052 {
1053 return m_chart->mapToValue(position, series);
1054 }
1055
1056 QPointF DeclarativeChart::mapToPosition(const QPointF &value, QAbstractSeries *series)
1057 {
1058 return m_chart->mapToPosition(value, series);
1059 }
1060
1040 #include "moc_declarativechart.cpp"
1061 #include "moc_declarativechart.cpp"
1041
1062
1042 QT_CHARTS_END_NAMESPACE
1063 QT_CHARTS_END_NAMESPACE
@@ -167,6 +167,11 public:
167 Q_INVOKABLE void scrollRight(qreal pixels);
167 Q_INVOKABLE void scrollRight(qreal pixels);
168 Q_INVOKABLE void scrollUp(qreal pixels);
168 Q_INVOKABLE void scrollUp(qreal pixels);
169 Q_INVOKABLE void scrollDown(qreal pixels);
169 Q_INVOKABLE void scrollDown(qreal pixels);
170 Q_REVISION(5) Q_INVOKABLE QPointF mapToValue(const QPointF &position,
171 QAbstractSeries *series = 0);
172 Q_REVISION(5) Q_INVOKABLE QPointF mapToPosition(const QPointF &value,
173 QAbstractSeries *series = 0);
174
170
175
171 Q_SIGNALS:
176 Q_SIGNALS:
172 void axisLabelsChanged();
177 void axisLabelsChanged();
@@ -1114,6 +1114,32 Module {
1114 name: "scrollDown"
1114 name: "scrollDown"
1115 Parameter { name: "pixels"; type: "double" }
1115 Parameter { name: "pixels"; type: "double" }
1116 }
1116 }
1117 Method {
1118 name: "mapToValue"
1119 revision: 5
1120 type: "QPointF"
1121 Parameter { name: "position"; type: "QPointF" }
1122 Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true }
1123 }
1124 Method {
1125 name: "mapToValue"
1126 revision: 5
1127 type: "QPointF"
1128 Parameter { name: "position"; type: "QPointF" }
1129 }
1130 Method {
1131 name: "mapToPosition"
1132 revision: 5
1133 type: "QPointF"
1134 Parameter { name: "value"; type: "QPointF" }
1135 Parameter { name: "series"; type: "QAbstractSeries"; isPointer: true }
1136 }
1137 Method {
1138 name: "mapToPosition"
1139 revision: 5
1140 type: "QPointF"
1141 Parameter { name: "value"; type: "QPointF" }
1142 }
1117 }
1143 }
1118 Component {
1144 Component {
1119 name: "QtCharts::DeclarativeHorizontalBarSeries"
1145 name: "QtCharts::DeclarativeHorizontalBarSeries"
@@ -111,4 +111,22 ChartView {
111 NumberAnimation { duration: 800 }
111 NumberAnimation { duration: 800 }
112 }
112 }
113 }
113 }
114
115 MouseArea {
116 id: zoomArea
117 anchors.fill: parent
118 acceptedButtons: Qt.LeftButton
119 property point mousePoint;
120 property point valuePoint;
121
122 onPressed: {
123 mousePoint.x = mouse.x
124 mousePoint.y = mouse.y
125 valuePoint = chart.mapToValue(mousePoint, series("line"));
126 // Mouse point and position should be the same!
127 console.log("mouse point: " + mouse.x + ", " + mouse.y);
128 console.log("value point: " + valuePoint);
129 console.log("position: " + chart.mapToPosition(valuePoint, series("line")));
130 }
131 }
114 }
132 }
General Comments 0
You need to be logged in to leave comments. Login now