[英]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.