MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

How to draw the line chart with gaps if the value is 0?

Open DeveloperAdam opened this issue 4 years ago • 4 comments

I have consumption values based on months. Like for current year 2021 the current month is Sep so in this case i have data till sep. But my X-Axis will be till December. So the question is how not to draw the lines for rest of the month. Please have a look at this example,

CF320C1D-D00A-491B-9566-DFB2C5CA4A4D_1_201_a

DeveloperAdam avatar Sep 15 '21 11:09 DeveloperAdam

The easy way, just do not add entry to the dataset, if all the remaining entries are ZEROs. See the below chart, I added entries for the columns, but stopped for the remaining where ZEROs.

Screen Shot 2021-09-16 at 8 24 45 AM

alahdal avatar Sep 16 '21 05:09 alahdal

If i didn't add entry then the xaxis reduces to the last entry means if i have data till jun so the xaxis only display the labels till june. Anyways thanks for your response

DeveloperAdam avatar Sep 16 '21 05:09 DeveloperAdam

The only workaround that would come to my mind as of now, you use a combined chart with columns. Add all the columns entries till end of the period with ZERO values and hide the labels.

I hope this help.

Screen Shot 2021-09-16 at 9 14 40 AM

alahdal avatar Sep 16 '21 05:09 alahdal

you can set x max value to 11,but only add 6 entry

gs666 avatar Jun 09 '22 07:06 gs666