Closed goshki closed 9 years ago
@goshki You can use a custom ValueFormatter
to change the String
displayed above the entry. Depending on what exactly you want to achieve you can either just format the value or provide another String
. Unfortunately it doesn't provide the entry index though, so if you need that it'll get complex.
Good point. Unfortunately the label I need to apply is index-dependent.
@goshki Ok, then you could try this (you'll have to clone or fork the project):
getFormattedValue
(see Github search results): you can then change the occurrences in ValueFormatter
s to accept Entry
instead of float value
and the occurrences in Renderer
s to pass the Entry
. (Only in MPChartLib folder)Entry
Normally I would consider doing it myself and opening a pull request, but I'm short in time. Passing the Entry
definitely allows for more flexible formatting.
@goshki : I had the same issue. Solved it by defining a IValueFormatter:
myDataset.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
int idx = myData.getDataSetByIndex(dataSetIndex).getEntryIndex(entry);
...
}
};
Is it possible to attach custom text labels to each entry in a given dataset?