How to draw invisible line in Mpandroid chart?

Viewed 14

I need to build a line chart based on this Design. Basically when there is 0 value for Y axis the line must be either transparent or not drawn.

enter image description here

I tried this approach, making an array of colors and adding a color for every entry:

                                    if (this == null || this == 0f) {
                                        sleepDataSet.addEntry(Entry(it.key, 0f))
                                        val emptyColor = ContextCompat.getColor(
                                            MBodyDatabase.context,
                                            R.color.meditation_chart_color
                                        )
                                        sleepColorArray.add(emptyColor)
                                    } else {
                                        sleepDataSet.addEntry(Entry(it.key, this))
                                        val lineColor = ContextCompat.getColor(
                                            MBodyDatabase.context,
                                            R.color.sleep_chart_color
                                        )
                                        sleepColorArray.add(lineColor)
                                    }

But it is not working when line mode is :

mode = LineDataSet.Mode.HORIZONTAL_BEZIER

I also tried making two different data sets, one for entries with 0 values and another for the ones that have actual values, but it´s not working either. Any idea?

0 Answers
Related