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 am not able to design multicolor bar chart #1324

Closed
ios-sagar opened this issue Aug 16, 2016 · 5 comments
Closed

I am not able to design multicolor bar chart #1324

ios-sagar opened this issue Aug 16, 2016 · 5 comments

Comments

@ios-sagar
Copy link

Hi,
I am using this library,
its a good one
I have around 6 pie charts and 6 bar charts
among them 2 bar charts are with two colours (like male-female ration in each dept.)
so my X-axis contains departments and Y-axis contains values.

I want male in one colour and female in other colour for particular dept.
can you pls guide for the same,

I asked same query on SO, but no answer yet.
here is the link, which contains my sample code as well.

http://stackoverflow.com/questions/38658402/multiple-colours-to-bar-charts-swift-one-above-the-other

@danielgindi
Copy link
Collaborator

danielgindi commented Aug 16, 2016

This is a stacked bar chart. In Charts' demos, you can see a stacked bar chart.

Basically, each BarChartDataEntry received either one value, or an array of values. Pass in an array of values - and you are good to go!

let entry = BarChartDataEntry(values: [4.6, 3.8], xIndex: 0)

@ios-sagar
Copy link
Author

I tried the same,
I can see the values in one above, but I failed to update the different colours.
I want different colours to set

@danielgindi
Copy link
Collaborator

danielgindi commented Aug 16, 2016

dataset.colors = [UIColor.cyanColor(), UIColor.greenColor()]
dataset.stackLabels = ["Inactive inventory", "Active inventory"]

@gaganindersingh
Copy link

gaganindersingh commented Sep 15, 2016

@danielgindi Please check the screenshot. I am able to draw the charts but only values are displaying no bars.

    set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"Energy Values (KWh)"];
    [set1 setColor:[UIColor cyanColor]];
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    [dataSets addObject:set1];

    BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
    [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];

    data.barWidth = 0.9f;

    self.barChartView.data = data;

What i am doing wrong?

screen shot 2016-08-25 at 11 48 41 pm

@gaganindersingh
Copy link

Anyway, I was using the wrong formatter for x-axis. The x-axis value should be in day of year format.

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

3 participants