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

How to set the xValues to the BarchartData ? #1718

Closed
Ashmika opened this issue Oct 26, 2016 · 8 comments
Closed

How to set the xValues to the BarchartData ? #1718

Ashmika opened this issue Oct 26, 2016 · 8 comments

Comments

@Ashmika
Copy link

Ashmika commented Oct 26, 2016

In previous version i have set the xValues to barchartdata using the below code but now latest library only able to set the Datasets. So how to set the xValues as any value.
Old Version -
BarChartData *data = [[BarChartData alloc] initWithXVals:xVals dataSets:dataSets];

New Version-

BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];

Please how i set the xValues of any type in new library.

@pmairoldi
Copy link
Collaborator

You now set the x value on the DataEntry which can be seen in here example here

@Ashmika
Copy link
Author

Ashmika commented Oct 26, 2016

Yes I have already use that one but its only accept the double value so for string or any xValue not accept by that. Even i use below code also to set value but seems not work properly.

[yVals addObject:[[BarChartDataEntry alloc]initWithX:i y:val]];

@pmairoldi pmairoldi reopened this Oct 26, 2016
@liuxuan30
Copy link
Member

you can conform to IChartAxisValueFormatter to format those x/y double values.

@Ashmika
Copy link
Author

Ashmika commented Oct 27, 2016

Its given error if I am changing the x/y double to string format.

@Ashmika
Copy link
Author

Ashmika commented Oct 27, 2016

@liuxuan30 Yes its work I use the below code to change the value formatter. Thanks Really....Appreciate with your help..

- (NSString *)stringForValue:(double)value
                        axis:(ChartAxisBase *)axis
{
    return months[(int)value % months.count];
}

@nezihe
Copy link

nezihe commented Nov 2, 2016

@Ashmika , I have the same problem. I can not figure out where I need to change IChartAxisValueFormatter ? Any help appreciated. Thank you.

@Ashmika
Copy link
Author

Ashmika commented Nov 7, 2016

@nezihe Sorry for late reply you should have to set it in the ex.LineChartViewController.m file.Where you use to set the data.Also set the delegate for that i.e IChartAxisValueFormatter

Also set the delegate to xaxis as below so that the method will be call.

xAxis.valueFormatter = self;

@nezihe
Copy link

nezihe commented Nov 9, 2016

@Ashmika Thanks for your help, I appreciate it. I managed to do it with your help!

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

4 participants