简体   繁体   English

MPAndroidChart:-如何减少折线图中x轴点之间的距离?

[英]MPAndroidChart:- How to reduce the distance between the x axis points in a line chart?

I am plotting a real time data using MPAndroidChart. 我正在使用MPAndroidChart绘制实时数据。 The X axis and Y axis are defined as below. X轴和Y轴定义如下。 Data is populating to the graph without any issues. 数据正在填充到图中,没有任何问题。 The result is supposed to be in a wave form. 结果应该是波形形式。 Since the Y axis range is too high I am getting the values as lines. 由于Y轴范围太大,因此我将这些值表示为线。 Could anyone help me on how to adjust the X axis range based on the Y axis vale, so that it can plot the values correctly. 谁能帮助我如何基于Y轴调整X轴范围,以便它可以正确绘制值。

    XAxis xl = mChart.getXAxis();
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setDrawLabels(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setSpaceBetweenLabels(5);
    xl.setEnabled(true);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setAxisMaxValue(4000f);
    leftAxis.setAxisMinValue(-4000f);
    leftAxis.setDrawGridLines(true);

在此处输入图片说明

Setting the chart property chart.setVisibleXRange(100,100) properly solved my issue. 设置图表属性chart.setVisibleXRange(100,100)可以正确解决我的问题。 There was nothing to do with the X-axis value. 与X轴值无关。

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

相关问题 mpandroidchart折线图x轴标签重叠问题发生 - mpandroidchart line chart x axis labels overlap issue occuring Kotlin:在折线图 Mpandroidchart 的 x 轴上设置自定义标签 - Kotlin: setting custom labels on x axis in line chart Mpandroidchart Mpandroidchart 文本未正确显示在折线图的 x 轴上 - Mpandroidchart text not properly showing on x axis on line chart MPAndroidChart条形图 - 如何在组之间对随机x轴间隔的条形图进行分组? - MPAndroidChart Bar Chart - how to group bars with random x-axis intervals in between groups? MPAndroidChart如何将x轴设置到图表的底部? - MPAndroidChart how to set x-axis to the bottom of the chart? MPAndroidChart - 如何设置独立于图表数据的 x 轴标签 - MPAndroidChart - How to set x axis labels independent of chart data 如何在 MPAndroidChart 中的 x 轴标签之间创建空间? - How to create space between x-axis labels in MPAndroidChart? 在MPAndroidChart中创建自定义X轴线 - Create custom X axis line in MPAndroidChart 标签的日期和时间没有在mpandroidchart库的x轴(折线图)上显示? - Date and time as label didn't get on x-axis(Line chart) in mpandroidchart library? 如何根据 y 轴值是正值还是负值来更改 MPAndroidChart 折线图的线条和填充颜色 - How to change line and fill color of MPAndroidChart line chart based on if y axis value is positive or negative
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM