Can I add IGRelativeStrengthIndexIndicator to a chart that has IGSplineSeries? I tried it already but it does not work. Only the IGRelativeStrengthIndexIndicator is displayed on the chart.
The relative strength indicator will change the range of the axis, typically to a 0-100 range. If your spline series data is above or below that range, you will not see it.Try using two separate Y axes, one for the spline series and one for the indicator.
Here's a quick example of having a spline and the indicator on the same chart, but different Y axes. Note, that the data isn't very useful, as there are only a few data points. The indicator needs to have quite a bit more points to make sense. This is primarily to illustrate the approach.
NSArray *data = @[@5, @6, @3]; NSArray *openValues = @[@5, @16, @15,]; NSArray *closeValues = @[@15, @6, @23]; NSArray *highValues = @[@20, @20, @29]; NSArray *lowValues = @[@1, @0, @5];
_chart = [[IGChartView alloc]initWithFrame:self.view.frame];
_categoryHelper = [[IGCategorySeriesDataSourceHelper alloc]initWithValues:data];
_ohlcHelper = [[IGOHLCSeriesDataSourceHelper alloc]initWithOpenValues:openValues highValues:highValues lowValues:lowValues andCloseValues:closeValues];
[_chart addSeriesForType:[IGSplineSeries class] usingKey:@"series" withDataSource:_categoryHelper firstAxisKey:@"x" secondAxisKey:@"y"]; [_chart addSeriesForType:[IGRelativeStrengthIndexIndicator class] usingKey:@"rsi" withDataSource:_ohlcHelper firstAxisKey:@"x" secondAxisKey:@"y2"];
[self.view addSubview:_chart];
There seems to be a problem. When i add the second yAxis it seems to get added to the left. The Axis values are not visible. See BadChart.png
Can you give me a complete example that has yAxis on both side of the chart like this
Finally figured this out.
-(NSString*)chartView:(IGChartView*)chartView labelForAxis:(IGAxis*)axis withItem:(NSObject*)item
was returning nil for the newly added axis on the right!
Thanks for all the help.
Okay i see the same in a test app. Now i need to go figure why it does not work on the production app.
This is what I get. Did you try the code snippet I posted or used the axis property setting in your app? Can you see what framework version and build number you're using?
-Max
Now I see a big empty space on the right. the y-axis labels are still not visible.
Send me the screenshot of the chart that the above code produces.
You just have to set the labelsLocation property on the y axis to OutsideRight and you'll see the labels on the right side.
_chart = [[IGChartView alloc]initWithFrame:self.view.frame]; _categoryHelper = [[IGCategorySeriesDataSourceHelper alloc]initWithValues:data]; _ohlcHelper = [[IGOHLCSeriesDataSourceHelper alloc]initWithOpenValues:openValues highValues:highValues lowValues:lowValues andCloseValues:closeValues];
[_chart addSeriesForType:[IGSplineSeries class] usingKey:@"series" withDataSource:_categoryHelper firstAxisKey:@"x" secondAxisKey:@"y"];
[_chart addSeriesForType:[IGRelativeStrengthIndexIndicator class] usingKey:@"rsi" withDataSource:_ohlcHelper firstAxisKey:@"x" secondAxisKey:@"y2"];
IGNumericYAxis *y = [_chart findAxisByKey:@"y"]; y.labelsLocation = IGAxisLabelsLocationOutsideRight;