Android MPchart 在滚动后获取视图的 Y 位置
Android MPchart get Y-Position of view after scrolling
我使用 MPChart 实时绘制快速更新的数据。至关重要的是,用户可以在图表更新时沿 Y 轴自由滚动。每次更新后,我使用 myChart.moveViewToX()
自动沿 x 轴滚动。但是,moveViewToX()
也会沿 Y 轴将视图移动到 0。
由于moveViewToX
没有像“ignoreY”或“keepY”这样的参数,我想使用
mChart.moveViewTo(centerX, centerY, YAxis.AxisDependency.LEFT);
,其中 centerY
是用户滚动到的 Y 位置。
到目前为止,我还没有在 MPChart 文档中找到任何访问此值的方法。
您应该可以通过执行以下操作获得中心 Y:
MPPointF centerPointPx = mChart.getViewPortHandler().getContentCenter();
MPPointD centerPointValue = mChart.getValuesByTouchPoint(centerPointPx.x, centerPointPx.y, YAxis.AxisDependency.LEFT);
我使用 MPChart 实时绘制快速更新的数据。至关重要的是,用户可以在图表更新时沿 Y 轴自由滚动。每次更新后,我使用 myChart.moveViewToX()
自动沿 x 轴滚动。但是,moveViewToX()
也会沿 Y 轴将视图移动到 0。
由于moveViewToX
没有像“ignoreY”或“keepY”这样的参数,我想使用
mChart.moveViewTo(centerX, centerY, YAxis.AxisDependency.LEFT);
,其中 centerY
是用户滚动到的 Y 位置。
到目前为止,我还没有在 MPChart 文档中找到任何访问此值的方法。
您应该可以通过执行以下操作获得中心 Y:
MPPointF centerPointPx = mChart.getViewPortHandler().getContentCenter();
MPPointD centerPointValue = mChart.getValuesByTouchPoint(centerPointPx.x, centerPointPx.y, YAxis.AxisDependency.LEFT);