0
votes

1) I'm practicing stuff with graphs in order to add that feture to my app, I want the upper labels ( the xAxis base ) to be shown only where entries occur.

I haven't found a suitable solution online yet, and currently it appears on every xAxis from first entry to last entry as in the picture below:

enter image description here

I want it to be without the one sI deleted, as shown in the picture below:

enter image description here

2) and the second question I'm struggling with it is that I want to be able to draw for example in (x=5, y=7) and after it to draw at (x=1, y =3), but it wont let me add an entry with a smaller x that any other entry that already in the graph.

1
the people who downvote the question, care to say the reason? - Lidor Eliyahu Shelef
The reason for the downvote, in my opinion, is that it does not make sense to show something in a chart that has no value and no label. maybe it shouldn't be there. However, I did not vote down cause you may have your reasons. - Mohammad Reza Khahani
the labels should appear ONLY where there is entries, I Want to remove the ones that are above nothing. - Lidor Eliyahu Shelef

1 Answers

0
votes

You have to extend from ValueFormatter class.

for more detail take a look at link

You can pick your desired logic to make the label disappear with returning "".

for example:

public String getFormattedValue(float value) {
  if ((int)value <= 0) //your logic to evaluate correctness
      return "";  // make lable go away
  //...
}

UPDATE 2 (in Kotlin): There is another overload for getFormattedValue which have a AxisBase parameter and you can use mEntryCount or mEntries.

override fun getFormattedValue(value: Float, axis: AxisBase?): String {
    if (axis?.mEntryCount!! <= 0)
        return ""
}