Hi,
I am using two different series in single IGChartView.
1) is IGColumnSeries and 2) is IGStackedColumnSeries.
Now problem is i couldn't apply two different series in single chart view. When i applied, it displayed some unnecessary white space between y-axis and its label. I have taken same axis for both series and set different keys for both of axis.
Is there any way to do this ?
Thanks..
The chart is capable of displaying multiple category series side by side. Here's a small example with a stacked column and column series. This code snippet assumes that you have an array called _data with objects that have value1 and value2 properties for stacked data, value property for column data and labelString property for the labels on the x axis. You should see that there is no extra space in the axes and the columns are displayed side by side.
- (void)viewDidLoad
{
NSArray *fields = @[@"value1", @"value2"];
_chartView = [[IGChartView alloc]initWithFrame:self.view.frame];
_categorySourceHelper = [[IGCategorySeriesDataSourceHelper alloc]initWithData:_data andValuePath:@"value"];
_stackedChartDataSourceHelper = [[IGStackedSeriesDataSourceHelper alloc]initWithData:_data fields:fields labelPath:@"labelString"];
IGColumnSeries *series = (IGColumnSeries*)[_chartView addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:_categorySourceHelper firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
IGStackedColumnSeries *stackedSeries = (IGStackedColumnSeries*)[_chartView addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"stackedSeries" withDataSource:_stackedChartDataSourceHelper firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
[self.view addSubview:_chartView];
}
Hi Max,
thanks for reply, i tried your given suggestion & got solution upto certain extend but i stuck on a following issue...
i tried your code this way....
IGCategorySeriesDataSourceHelper *source = [[IGCategorySeriesDataSourceHelper alloc] init];
source.data = data;
source.valuePath = @"cost";
source.labelPath = @"product";
infraChart = [[IGChartView alloc] initWithFrame:CGRectMake(0, 10, 295, 171)];
[infraChart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
infraChart.delegate = self;
IGCategoryXAxis *xAxis = [[IGCategoryXAxis alloc] initWithKey:@"xAxis"];
IGNumericYAxis *yAxis = [[IGNumericYAxis alloc] initWithKey:@"yAxis"];
[infraChart addAxis:xAxis];
[infraChart addAxis:yAxis];
IGColumnSeries *colSeries = (IGColumnSeries *) [infraChart addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:source firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
IGStackedSeriesDataSourceHelper* stackedChartDataSourceHelper = [[IGStackedSeriesDataSourceHelper alloc]initWithData:arrStackedBarSeries fields:[[NSArray alloc]initWithObjects: @"sales", @"pending", nil]];
IGStackedColumnSeries *stackedColSeries = (IGStackedColumnSeries *) [infraChart addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"series2" withDataSource:stackedChartDataSourceHelper firstAxisKey:@"xAxis1" secondAxisKey:@"yAxis1"];
colSeries.xAxis.gap = 0.7;
IGChartThemeDefinition *def = [IGChartDefaultThemes DefaultTheme];
infraChart.theme = def;
[goalSalesChart addSubview:infraChart];
& i got solution upto this .....
https://ramjansayyad.opendrive.com/files?Nl8zMDc0MTM1MV9hWVF3ag
But
if you see above screen shot here, I'm getting too much space between graph & it's Y-axis.
& I'm unable to reduce it.
Also,
In your solution you pass xAxis & yAxis same for IGColumnSeries & IGStackedColumnSeries ...but if i go with the same my code gets break so i pass (xAxis,yAxis) for IGColumnSeries & (xAxis1,yAxis1) for IGStackedColumnSeries ....
So please ,if you help me to get out of this issue that will be so glad.....