繁体   English   中英

Android GraphView:setMinX(0)无法正常工作并产生负x轴值

[英]Android GraphView: setMinX(0) not working and produces negative x axis values

我一直试图在我的Android项目中使用GraphView库来基于x轴绘制时间绘制一些点。 为此,我想将我的x轴约束为0到60(代表秒)。 我使用以下代码进行了此操作:

    graph = (GraphView) findViewById(R.id.graph);

    grapRend= graph.getGridLabelRenderer();


    graph.getViewport().setScrollable(true);
    graph.getViewport().setXAxisBoundsManual(true);
    graph.getViewport().setMinX(0);
    graph.getViewport().setMaxX(60);

但是当我输入例如x值为0和1的前两个数据点时

    series = new LineGraphSeries<DataPoint>(new DataPoint[] {});
    series.appendData(new DataPoint(0,70), true, 100);
    series.appendData(new DataPoint(1,73), true, 100);

绘图的x轴突然移动,以至于最右边的x点是1,而左边的一切都是负的(我在图中用方框将其装箱了): 负的X轴图像

有什么方法可以冻结x轴,使其仅是正数? 谢谢

我打电话时发现了问题

series.appendData(new DataPoint(0,70), true, 100);

我只需要将参数从true更改为false。 根据GraphView docs,此值是(Boolean ScrolltoEnd),因此将其设置为false将消除x轴的偏移。 所以它应该看起来像这样:

series.appendData(new DataPoint(0,70), false, 100);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM