Bullet graph


#1

How can we create a bullet graph by using Shinobi iOS library?

Here is the link of bullet graph:

-Nick


#2

Hi Nick,

You should be able to create a very thin chart with a single bar (for a horizontal bullet) or column (for a vertical bullet) series. You can add the coloured bands to the chart’s background using our SChartAnnotation API:

// Create a red horizontal band annotation spanning the full width of the chart, start at a Y value of 0, and ending at a Y value of 10.
SChartAnnotation *bandAnnotation = [SChartAnnotation horizontalBandAtPosition:@0 andMaxY:@10 withXAxis:self.chart.xAxis andYAxis:self.chart.yAxis withColor:[UIColor redColor]];

// Add the annotation to your chart.
[self.chart addAnnotation:bandAnnotation];

Thanks,
Jan


#3

Hi Jan,

Thanks for the reply.

I have tried your soultion with Bar series. But it’s not working. Since bar series may have any number of bar then how can annotation be added on every bar.

Below is the code.

-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(NSInteger)index {

 SChartBarSeries * barSeries = [[SChartBarSeriesalloc] init];
 
  SChartAnnotation *bandAnnotation = [SChartAnnotationhorizontalBandAtPosition:@0 andMaxY:@10withXAxis:chart.xAxisandYAxis:chart.yAxiswithColor:[UIColorredColor]];
 
 [chart addAnnotation:bandAnnotation];
 
 return barSeries;

}
Is there any other way to create bullet graph or can you please share some detail sample code.

  • Nick

#4

Hi Nick,

I was suggesting using a seperate chart for each bullet chart, so you’d simply size your chart to the correct size & add the annotation accross the whole width of the chart.

ShinobiCharts doesn’t directly support bullet charts so I don’t have any sample code to hand. However, I’m more than happy to give you advice on any problems you may run into whilst trying to find a suitable implementation.

Best regards,
Jan Akerman