I’m trying to make the columns in my chart to be selectable and show more details of the selected column when clicked. Every column is represented by one series (you will understand in a second).
this is how i build each series:
-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(int)index {
SChartColumnSeries *series = [SChartColumnSeries new];
series.style.showAreaWithGradient = NO;
series.stackIndex = [NSNumber numberWithInt:0];
series.selectedStyle.showAreaWithGradient = NO;
CHART_COLOR_TYPE dataType = [TestGraphDataManager getDataType:index];
series.style.areaColor = (dataType == ACCOUNT)?
[UIColor colorWithRed:227.0f/255.0f green:179.0f/255.0f blue:0.0f/255.0f alpha:0.5f]:
[UIColor colorWithRed:0.0f/255.0f green:172.0f/255.0f blue:235.0f/255.0f alpha:0.5f];
series.selectedStyle.areaColor = [UIColor colorWithRed:129.0f/255.0f green:0.0f/255.0f blue:82.0f/255.0f alpha:0.5f];
series.selectionMode = SChartSelectionSeries;
series.style.lineColor = [UIColor clearColor];
series.selectedStyle.lineColor = [UIColor clearColor];
return series;
}
The problem I’m currently having is that only the first series is selectable. Also i made each bar represented by a different series so that i can toggle its color easly with series.selectionMode = SChartSelectionSeries
Finally I have this delegate event so that i can load the extra data but it’s also being called only for the first series
- (void)sChart:(ShinobiChart *)chart toggledSelectionForSeries:(SChartSeries *)series nearPoint:(SChartDataPoint *)dataPoint atPixelCoordinate:(CGPoint)pixelPoint{
NSLog(@"click event called");
//Display data
}
Does anyone know why this is happening? It’s been driving me insane all day.
Thank you, in advance for any help give.
EDIT:
I found the major problem as i do series.stackIndex = [NSNumber numberWithInt:0]; it makes all the bars with the same name stack (as nome of the names repeat its not a problem in my point of view), i do this so that all the bars are at the same distance from the tick marker and so that the bars aren’t very tine. But i believe that shinobi places invisible bars for those values and they are over the other, making only the first series selectable because its over the others. If i remove that line the graphic look horrible but all are clickable.
Any idea on how to bypass this or to avoid this problem?
how it should look (using stacking indexes) but it breaks the click events:

without stacking indexes all bars are clickable but it doesn’t look as good, and it gets worse the more bars i have this is using only 4 bars:
Rob here from Shinobi – thanks for getting in touch!
This can be solved by using subclassing, and returning zero for the column offset, like so: