bardao
bardao

Reputation: 954

QML chartview get X,Y of Lineseries.onPointAdded

How can I get the X and Y of the point added in Lineseries?
This code is placed inside a simple ChartView.

If I have the following:

LineSeries {
        id: data
        name: "name"
        axisX: axisX
        axisY: axisY
        onPointAdded: {
            //retrieve x and y
    }
}

What should replace the comment inside onPointAdded?
Thanks.

Upvotes: 1

Views: 949

Answers (1)

eyllanesc
eyllanesc

Reputation: 243907

The pointAdded signal passes as a parameter the index of the added element, this index must be used next to the method at() to obtain the point:

onPointAdded: {
    var point = data.at(index);
    console.log(point.x, point.y)
}

Upvotes: 1

Related Questions