Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFormattedValue method returning wrong count #2693

Open
rcrepaldi opened this issue Jan 9, 2017 · 8 comments
Open

GetFormattedValue method returning wrong count #2693

rcrepaldi opened this issue Jan 9, 2017 · 8 comments

Comments

@rcrepaldi
Copy link

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?

@wangyuxu
Copy link

wangyuxu commented Feb 9, 2017

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);
        }
    };

@arkojj
Copy link

arkojj commented Feb 22, 2017

@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.

@patelkunala
Copy link

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

@ViewMikeZhou
Copy link

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

@Spectre-Dev
Copy link

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

@wantitmore
Copy link

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

@HosseinArabbeigi
Copy link

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

It comes from drawLabels method of XAxisRenderer class.

@Skylarkarms
Copy link

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

The problem is a misunderstanding of what the graph is doing in this particular scenario.
The issue is that with previous instances of the chart, especially types of charts in which NO X VALUES are inserted into the graph, the expected behavior of the x-axis format, is to place a tooltip exactly below the place where the point/bar/segment is placed.
This behavior changes completely when you provide an x float value.
Now the Data (maybe a String you provided) will only serve as a bubble for your point tooltip. End of the story.
The X axis will show lines at random that WILL NOT MATCH the points delivered to the graph BUT will remain on its scale non the less.
This means that the float values delivered by the method will ALMOST NEVER MATCH those of the collection of entries provided.
This means that you must know BEFOREHAND:

  1. What your X axis margins will be MAX and MIN
  2. How exactly any of the points within those margins you set, will get parsed on to a String.

After a proper function has been fore-(seen/saw), it is up to the getFormattedValue() function to deliver any float it may deem proper, depending on some other values set by the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants