Works ChartView :: Zoomin(Rect Rectangle)如何工作



我想在图表中使用rectang区域缩放一个选择:

import QtQuick 2.7
import QtCharts 2.1
ChartView{
    id: chart
    width: 400
    height: 400
    ScatterSeries{
        markerSize: 10
        XYPoint{x: 1; y: 1}
        XYPoint{x: 2; y: 2}
        XYPoint{x: 5; y: 5}
    }
    Rectangle{
        id: rectang
        color: "black"
        opacity: 0.6
        visible: false
    }
    MouseArea{
        anchors.fill: parent
        hoverEnabled: true
        acceptedButtons: Qt.AllButtons
        onPressed: {rectang.x = mouseX; rectang.y = mouseY; rectangle.visible = true}
        onMouseXChanged: {rectang.width = mouseX - rectang.x}
        onMouseYChanged: {rectang.height = mouseY - rectang.y}
        onReleased: {
            chart.zoomIn(rectang); // something wrong with that line, it doesn't work
            rectang.visible = false
        } 
    }
}

您能说出如何正确使用ChartView::zoomIn(rect rectangle)吗?我希望Zoom像Zoom Line示例一样工作。简单的ChartView::zoomIn()只需缩放一个中心2。

helpped:

onReleased: {
        chart.zoomIn(Qt.rect(rectang.x, rectang.y, rectang.width, rectang.height))
        rectang.visible = false
}

我错误地认为rectRectangle是相同的类型。

相关内容

  • 没有找到相关文章

最新更新