Charts: How to set the xValues to the BarchartData ?

Created on 26 Oct 2016  路  8Comments  路  Source: danielgindi/Charts

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.

All 8 comments

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

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]];

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

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

@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];
}

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JW00332 picture JW00332  路  4Comments

cilasgimenez picture cilasgimenez  路  4Comments

newbiebie picture newbiebie  路  3Comments

sjdevlin picture sjdevlin  路  3Comments

brytnvmg picture brytnvmg  路  4Comments