Is there a IGGaugeRange equivalent for IGChartView that allows me to place brushed bands across a series?
Something like this...
You would have to use another series as the range. Unfortunately, there isn't a simple way to break apart an axis into colored ranges. It might be a neat feature to have something like an IGRangeOverlay that behaves like an IGOverlay, but instead of a line, shows an area. At the moment, the only way to have such ranges is to use another series as the first series in the chart. You could either try a StackedColumnSeries or a couple of RangeAreaSeries. Ranges can share your existing Y axis, but not the X axis.
IGHighLowSeriesDataSourceHelper *dsh1 = [[IGHighLowSeriesDataSourceHelper alloc]initWithHighValues:@[@10,@10] andLowValues:@[@0,@0]];
IGRangeAreaSeries *fill = (IGRangeAreaSeries*)[_chartView addSeriesForType:[IGRangeAreaSeries class] usingKey:@"fill" withDataSource:dsh1 firstAxisKey:@"fillXAxis" secondAxisKey:@"y"];
IGCategoryXAxis *fillAxis = (IGCategoryXAxis*)[_chartView findAxisByKey:@"fillXAxis"];
fillAxis.labelsVisible = NO;
This idea dovetails nicely into what I need to do. I'll give it a shot and report back.
I tried to convert your sample from a DSH to self being the data source.
Getting this crash:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[IGCategoryDatePoint lowValue]: unrecognized selector sent to instance 0x16e98660'
#pragma mark - Data Source
-(NSInteger)numberOfPointsInSeries:(IGSeries*)series
{
NSInteger count = 0;
if([series isEqual:self.lineSeries])
count = self.trendData.count;
}
else if([series isEqual:self.rangeSeries])
count = 2;
return count;
-(IGDataPoint*)series:(IGSeries*)series pointAtIndex:(NSInteger)index
IGDataPoint *point = nil;
point = self.trendData[index];
point = [[IGHighLowPoint alloc] initWithHigh:10.0 andLow:0.0 andLabel:nil];
return point;
Wait... Will I need a series for each color I want to represent? If so, whew... that's going to be nasty.
The only series that can display multiple colors are the stacked series, but then you're substituting number of series for number of stacked fragments, so not that much different. I'm not entirely sure why you're getting the crash, but the only time that could happen is when you pass a IGCategoryDatePoint into a range series. Somehow your range series isn't getting the correct data point. Maybe a stacked series approach would be cleaner. You would need a single datasource and a small data model class that holds a numeric property for each range. I'm afraid there isn't anything cleaner than that.