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.
Is it possible to mix stacked and non-stacked series on the same chart?
Can you help me out and post a sample IGStackedSeriesDataSourceHelper to mimic the image I supplied above? I don't know how to use the Stacked DSH properly... let alone improperly. ;)
I'll make a note of this and revisit in a few days. Thank you.
Are you using NucliOS 14.1 by chance? We've added a plotAreaRect property to the chart to get the chart's viewport bounds.
If you have two overlapping ranges that you want to represent on the chart.
60F - 105F = Range that represents habitable temperatures for humans
68F-74F = Range that represents ideal temperature for humans
Since it isn't possible to set the background for the series, but you can for the entire chart... Is it possible to get the coordinates of the series so I draw the image appropriately?
Caylan,
I'm not sure what you mean by the overlaps, can you give an example?
Unfortunately, you can't set a background image to the plot area.
Thank you for the sample. The issues are plenty... ah!
The one issue that stands out is how to handle overlaps. That's a tricky area, and something that needs to be supported. That said, I'm thinking about drawing a custom image. Is there a way to either: 1) set the series background as an image, or 2) get the bounds of the series so that an image context can be created and aligned successfully ?
Thanks!