Mpandroidchart: GetFormattedValue method returning wrong count

Created on 9 Jan 2017  路  7Comments  路  Source: PhilJay/MPAndroidChart

Hello guys

Does anyone know tell me why my overridden method "getFormattedValue" is called 10 times while my list of data goes from 0 to 8 only?

I can not identify this problem.

I am adding the methods with the value of 8

LineChart.setVisibleXRangeMinimum (8);
LineChart.setVisibleXRangeMaximum (8);
LineChart.getXAxis (). SetLabelCount (8, false);

This happens whenever I reload the chart with new values. Could I be forgetting to destroy the graph before?

Most helpful comment

anybody tell us the question that where the value in getFormattedValue(float value, AxisBase axis) from ?

All 7 comments

i don not know the reason,but i think a good method,this is you must make a protect for the data.
like this
XAxis xAxis = mLineChart.getXAxis();
xAxis.setValueFormatter(null);
IAxisValueFormatter formatter = new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {

            if (((int) value) >= xAxisPosition.size())
                return xAxisPosition.get(xAxisPosition.size()-1);
            else
                return xAxisPosition.get((int) value);
        }
    };

@wangyuxu @PhilJay
In the method getFormattedValue(float value, AxisBase axis), can you please tell me where does the 1st parameter - "float value" gets its data from? I want to know how is it called, and with which actual argument? I am getting "value" as -10, and thus my array index at location -10 would not work. Thanks in advance!

p.s. - I'm sorry for posting it in a wrong thread, but this was related to the same method and looks pretty recent.

@PhilJay I've got the same question as @arkojj - how does the value parameter derives its value? mEntries isn't the source, is it?

I've got the same question as @arkojj - how does the value parameter derives its value? mEntries isn't the source, is it?

Same question here.
The documentation seems quite patchy and there's a lot of depreciated stuff still in there.

anybody tell us the question that where the value in getFormattedValue(float value, AxisBase axis) from ?

anybody tell us the question that where the value in getFormattedValue(float value, AxisBase axis) from ?

It comes from drawLabels method of XAxisRenderer class.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SutharRohit picture SutharRohit  路  3Comments

thanhcly920 picture thanhcly920  路  3Comments

galex picture galex  路  3Comments

ChenZeFengHi picture ChenZeFengHi  路  3Comments

botondbutuza picture botondbutuza  路  3Comments