QML move inside zoomed charts with Middle button

I'm working with QML Charts. I have now a plot :

import QtQuick 2.9
import QtQuick.Window 2.2
import QtCharts 2.0

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    ChartView {
        id: chartView
        anchors.fill: parent
        theme: ChartView.ChartThemeBrownSand
        antialiasing: true

        LineSeries {
            name: "LineSeries"
            XYPoint { x: 0; y: 0 }
            XYPoint { x: 1.1; y: 2.1 }
            XYPoint { x: 1.9; y: 3.3 }
            XYPoint { x: 2.1; y: 2.1 }
            XYPoint { x: 2.9; y: 4.9 }
            XYPoint { x: 3.4; y: 3.0 }
            XYPoint { x: 4.1; y: 3.3 }
        }

        MouseArea{
            anchors.fill: parent
            onDoubleClicked: chartView.zoomReset();
        }
    }
}

I can zoom in and out by using the ZoomIn(QRect)

var r = Qt.rect(x, y, w, h)
chartView.zoomIn(r)

after zooming done i need to move in zoomed plot with pressing middle button (wheel) and shift my place Right or left in chartView.

how i can get pressed middle button position and move ploted series based on that positions ?!



Read more here: https://stackoverflow.com/questions/65704300/qml-move-inside-zoomed-charts-with-middle-button

Content Attribution

This content was originally published by MohsenDh at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: