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..
Hello Manish,
I have created support case CAS-135092-C5H0X1 to track this and I have submitted this to our engineers. I will update this thread when I have more information.
The order of displayed series should be the same as the order you've added them to the chart.series array. Looks like there could be a bug that's rendering the stacked series before the column series, even though the column series is added first. We'll have to investigate this a bit closer. In the meantime, I'll contact our support group to create a case for you.
Sorry for the inconvenience.
Thanks a lot Max. It worked.
One last question. How do you order the series to make one behind the another?
What we noticed that the series added last is shown on the top.
But this doesn't seem to work when adding one IGColumnSeries and second IGStackColumnSeries. IGColumnseries is always shown on top.
Even when the order of the below two code lines are interchanged (one written on top of the other), the IGColumnSeries is always shown on top. I want the stackcolumn series to be shown on top.
IGStackedColumnSeries * stackSeries = (IGStackedColumnSeries *)[infraChart addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"series2" withDataSource:stackedChartDataSourceHelper firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
IGColumnSeries * colSeries = (IGColumnSeries *)[infraChart addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:source firstAxisKey:@"xAxis1" secondAxisKey:@"yAxis"];
The grouping of your series is only determined by the X axis. If it's the same, the series will be grouped, otherwise, they will overlap.
The Y axis can be the same for both of your series, regardless of grouping. Set both your series to use the same Y axis, but different X axes and you will get overlapping series that use the same Y axis.
Hello Max,
I have set the properties as you have described for an issue of shifting y-Axis in chart view. Now it works perfectly. But my ultimate goal is still not being fulfilled.Let me explain you in brief. I have three type of values first is Goal Value second is Sales value and third one is Pending value.So my requirement is to draw a chart with column series for Goal value and StackedColumnSeries for Sales and Pending values.
In this demo example, i took one ColumnSeries and one StackedColumnSeries.
See the first snap shot.Graph displays single y-Axis as i have given same key for both ColumnSeries and StackedColumnSeries.
i.e. [infraChart addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"series2" withDataSource:stackedChartDataSourceHelper firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];[infraChart addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:source firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
I don't want side by side series as in first snap shot.
now have a look at second snap shot.
This graph displays two y-Axis since i have set two different keys for both series.
i.e. [infraChart addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"series2" withDataSource:stackedChartDataSourceHelper firstAxisKey:@"xAxis1" secondAxisKey:@"yAxis1"];[infraChart addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:source firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
Here, first y-Axis depicts StackedColumnSeries labels and second y-Axis depicts ColumnSeries labels.
So i want the same output as second snap shot has. I want ColumnSeries overlapped by StackedColumnSeries as in second snap shot. However an issue is,it displaying two y-Axis for two different series. Can i set single y-Axis labels for both ColumnSeries and StackedColumnSeries that can provide the values for both series ?
Have a look at the last snap shot. This is what i want to do.
Following code snippet that i am using to draw a graph.
@interface GraphObject : NSObject
@property (nonatomic,retain) NSString *territory;
@property (nonatomic,assign) double productCost;
@end
@implementation GraphObject
@synthesize territory,productCost;
@interface DataModel : NSObject
@property (nonatomic,retain) NSString *territory1;
@property (nonatomic, assign) double cost1;
@property (nonatomic, assign) double cost2;
@implementation DataModel
@synthesize cost1, territory1,cost2;
- (void)viewDidLoad
{
[super viewDidLoad];
arrGoal = [[NSMutableArray alloc] initWithObjects:@"70",@"20",@"30",@"40",@"50", nil]; // Blue Color Bar
arrSales = [[NSMutableArray alloc] initWithObjects:@"20",@"80",@"90",@"20",@"40", nil]; // Orange Color Bar
arrPending = [[NSMutableArray alloc] initWithObjects:@"20",@"180",@"190",@"120",@"140", nil]; // Yellow Color Bar
[self generateData];
IGChartView *infraChart = [[IGChartView alloc] initWithFrame:self.view.frame];
[infraChart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
infraChart.delegate = self;
// Stacked column series
IGStackedSeriesDataSourceHelper* stackedChartDataSourceHelper = [[IGStackedSeriesDataSourceHelper alloc]initWithData:data2 fields:[[NSArray alloc]initWithObjects: @"territory1", @"cost1",@"cost2", nil]];
[infraChart addStackedSeriesForType:[IGStackedColumnSeries class] usingKey:@"series2" withDataSource:stackedChartDataSourceHelper firstAxisKey:@"xAxis1" secondAxisKey:@"yAxis1"];
//coulmn series
IGCategorySeriesDataSourceHelper *source = [[IGCategorySeriesDataSourceHelper alloc] init];
source.data = data;
source.valuePath = @"productCost";
source.labelPath = @"territory";
[infraChart addSeriesForType:[IGColumnSeries class] usingKey:@"series" withDataSource:source firstAxisKey:@"xAxis" secondAxisKey:@"yAxis"];
[self.view addSubview:infraChart];
}
-(void)generateData
{ territories = [NSArray arrayWithObjects:@"Canada", @"Finland", @"Holland", @"Japan", @"USA", nil];
data = [[NSMutableArray alloc] init];
for (int i = 0; i < 5; i++)
GraphObject *graphObject = [[GraphObject alloc] init];
graphObject.territory = [territories objectAtIndex:i];
graphObject.productCost = [[arrGoal objectAtIndex:i]doubleValue];
[data addObject:graphObject];
data2 = [[NSMutableArray alloc] init];
for (int j = 0; j < 5; j++)
{ DataModel *graphObject = [[DataModel alloc] init];
graphObject.territory1 = [territories objectAtIndex:j];
graphObject.cost1 = [[arrSales objectAtIndex:j] doubleValue];
graphObject.cost2 = [[arrPending objectAtIndex:j] doubleValue];
[data2 addObject:graphObject];
Please, give me your valuable suggestion. If you help me to get out of this issue that will be so glad.
Thanks.