Stacked bar chart in Objective C


#1

Is it possible to create stacked bar chart in Objective C, as below ?

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.1/Premium/Normal/user-guide/how-to-stacked-column-series.html

https://www.google.co.in/imgres?imgurl=http://www.yaksis.com/static/img/03/large/StackedColumnChart.png&imgrefurl=http://www.yaksis.com/posts/r-chart-chooser.html&h=1916&w=2587&tbnid=ch3aFpcqWBVmNM:&docid=eW52ZhpFUXNFPM&ei=TYlyVrrbFYzguQSumoz4Aw&tbm=isch&ved=0ahUKEwj6tcL80uLJAhUMcI4KHS4NAz8QMwg_KA4wDg


#2

Hello Vimi,

Yes this is possible. I’d recommend you take a look at the Column Series sample that is available with our free trial.

To make the series stacked go to the SChart method that configures the series and you will have to set the stackIndex property to the same value for all of the series you want to stack.

-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(NSInteger)index {
    SChartColumnSeries *columnSeries = [[SChartColumnSeries alloc] init];
    columnSeries.title = index == 0 ? @"2011" : @"2012";
    columnSeries.stackIndex = 0 // add this line
    return columnSeries;
}

There must also be a value for each element. For example if you wanted to achieve this in the Column Series sample you will have to provide Okra with a paired value (that is not present by default in the sample).

_sales[0] = @{@"Broccoli" : @5.65, @"Carrots" : @12.6, @"Mushrooms" : @8.4, @"Okra" : 0.7};
    _sales[1] = @{@"Broccoli" : @4.35, @"Carrots" : @13.2, @"Mushrooms" : @4.6, @"Okra" : @0.6};

I hope this answers your question for you.

Matt Webber