在MPAndroidChart上显示其X轴值时,如何不在线图上绘制零值? [英] How to not draw zero values on a linechart while showing their X axis values on MPAndroidChart?
问题描述
我正在使用MPAndroidChart在折线图中显示我的数据.对于每个日期,我都有自己的价值.
这很好用.我现在要做的是不绘制0值,而是绘制2个相邻的非零值(如趋势线)之间的线,同时继续在x轴上显示零值的日期. /p>
我当前的图形:
所需图形应类似于此图形:
如何实现这种行为?
我在这里发布朋友的解决方案(工作原理很简单):
- 创建一个具有0个值的数据集.用透明颜色线绘制它.
- 创建一个不包含0的数据集.用所需的颜色绘制.
将(1)和(2)放在同一个LineChart上.
它将为您提供 x轴,其中包含x个值,其中 0个值,但不会为它们画一条线.
第二个数据集将显示数据行点,不包含0个值.
I'm using MPAndroidChart to display my data in a line graph. For each date I have its own value.
This works just fine. What I want to do now is to not draw the 0 values, but instead draw the line between 2 adjacent non-zero values (like a trend-line), while keep showing the dates on the x-axis for the zero values.
My current graph:
The desired graph should look similar to this graph:
How can I achieve this behavior?
I'm posting my friend's solution here (worked like a charm):
- Create a dataset with 0 values. Draw it but with line of transparent color.
- Create a dataset without 0. Draw it with the color that you need.
Put (1) and (2) on the same LineChart.
It will give you an x axis with x values where there are 0 values but will not draw a line for them.
The second dataset will show the line of data points without the 0 values.
这篇关于在MPAndroidChart上显示其X轴值时,如何不在线图上绘制零值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!