java - 如何在折线图中设置左右 y 轴的填充

标签 java android mpandroidchart

如图所示,如何设置折线图中左 y 轴和右 y 轴的内边距?数据的范围为 1n 点。可见的 x 轴范围最大为 5 点。

a picture of a line chart where the first point is not flush with the y-axis and the last point is not flush with the right-hand edge of the chart

最佳答案

以下内容应该适合您:

mChart.getXAxis().setSpaceMin(5f);
mChart.getAxis().setSpaceMax(5f);

这是javadoc对于这两种方法:

Sets extra spacing for axisMinimum to be added to automatically calculated axisMinimum

和:

Sets extra spacing for axisMaximum to be added to automatically calculated axisMaximum

如您所见,它们基本上会自动在 x 轴上向最小值和最大值添加空间/填充,这正是我们想要的。

关于java - 如何在折线图中设置左右 y 轴的填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41793406/

相关文章:

java - 我无法使用sharedPreferences android studio 获取第一个字符串

java - 如何突出显示 JTextPane 中的所有文本?

android - 在 Achartengine 中显示图表值

android - 是否可以通过无线网络将我的项目部署到 Smartface 模拟器?

java - 彩色 Horizo​​ntalBarChart 的 MPAndroidchart 圆形边缘

android - MPAndroidChart 中的可滚动折线图

java - 在 Java 中读取 HTTP 消息

java - CORS 允许来源限制不会导致服务器拒绝请求

android - 会说话的应用程序就像会说话的汤姆猫一样,录音在所有设备上都不起作用

java - MPAndroidChart v3.1.0 在 github 上找不到