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

I want to change ValueFormat of BarChartDataSet. I can't change it. #2764

Closed
IAmMonika opened this issue Aug 31, 2017 · 6 comments
Closed

I want to change ValueFormat of BarChartDataSet. I can't change it. #2764

IAmMonika opened this issue Aug 31, 2017 · 6 comments

Comments

@IAmMonika
Copy link

IAmMonika commented Aug 31, 2017

I want to set BLUE Box value Format same as RED Box. But I can't change Value format of BarChartDataSet

simulator screen shot 01-sep-2017 1 26 11 am

  • (void)setDataCount:(int)count range:(double)range ValuesArr:(NSMutableArray*)valArr
    {
    BarChartDataSet *set1 = nil;
    if (_chartView.data.dataSetCount > 0)
    {
    set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
    set1.values = valArr;
    [_chartView.data notifyDataChanged];
    [_chartView notifyDataSetChanged];
    }
    else
    {
    set1 = [[BarChartDataSet alloc] initWithValues:ValuesArr label:@"2014"];
    [set1 setColors:@[Blue_Color,Yellow_Color,Red_Color]];
    _chartView.barData.dataSets=@[[UIColor clearColor]];
    set1.drawIconsEnabled = NO;
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    [dataSets addObject:set1];
    BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
    [data setValueFont:[UIFont fontWithName:Font_Regular size:(isIphone) ? 10.f : 22.0f]];
    data.barWidth = 0.7;
    _chartView.data = data;
    }

    [super handleOption:@"animateY" forChartView:_chartView];

}](url)

@seenoevo
Copy link

seenoevo commented Sep 1, 2017

If you want to add a comma, you can do something like this, but it's written in Swift, so you have to convert it to Objective-C:

let decimalCostValue = NumberFormatter()
decimalCostValue.numberStyle = .decimal
         
chartData.setValueFormatter( DefaultValueFormatter(formatter: decimalCostValue) )

@IAmMonika
Copy link
Author

IAmMonika commented Sep 1, 2017

@seenoevo
comma_fmt = [[NSNumberFormatter alloc] init];
[comma_fmt setNumberStyle:NSNumberFormatterDecimalStyle]; // to get commas (or locale equivalent)
[comma_fmt setMaximumFractionDigits:0]; // to avoid any decimal

-------- please give some hint what value I have to passed in id _Nullable
[data setValueFormatter:(id _Nullable)];

@seenoevo
Copy link

seenoevo commented Sep 1, 2017

search for ChartDefaultValueFormatter in demo and you can see other graphs using it, then apply it to your own code

the demo contains a lot of useful information if you just search around ;)

@IAmMonika
Copy link
Author

IAmMonika commented Sep 1, 2017

@seenoevo Thanks I found the solution

@seenoevo
Copy link

seenoevo commented Sep 1, 2017

@patelmonika006 great!....please close if resolved

@RamohanReddy
Copy link

Hi @seenoevo and @IAmMonika
How to show this value 2040000 to $2.04M like this

Thanks&Regards
Ramohan Reddy

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