My chart includes a series which is IGFinancialPriceSeries type. It displays everything properly except it's scroll position. It is like there is a -5 padding from top of the graph when it shows up for the first time. If I scroll top the chart, then it places the graph to the center of the view which is what I want to see. The graph itself is a candlestick. I have double checked the UIViewController on storyboard whether there is a constraint problem or not. I couldn't find anything wrong. So it is I guess a graph positioning issue.
My question is how can I tell the IGChartView to fit the candlestick graph? Is there a way to handle the chart scroll programatically? Thank you.
Also this what I am doing to add the series:
source = [[IGOHLCSeriesDataSourceHelper alloc] init];
source.openValues = openArr;
source.highValues = highArr;
source.lowValues = lowArr;
source.closeValues = closeArr;
source.volumeValues = volumeArr;
source.labels = labelsArr;
if (self.chartView.axes.count > 0)
{
@try
NSArray *axes = self.chartView.axes;
for (int i = 0; i < axes.count; i++)
[self.chartView removeAxis:axes[i]];
}
@catch (NSException *exception)
// do nothing
xAxis = [[IGCategoryXAxis alloc] initWithKey:@"xAxis"];
yAxis = [[IGNumericYAxis alloc] initWithKey:@"yAxis"];
xAxis.labelOrientationAngle = 45;
if (ix == 0)
xAxis.interval = openArr.count / 6;
[self.chartView addAxis:xAxis];
[self.chartView addAxis:yAxis];
if (financialPriceSeries)
[self.chartView removeSeries:financialPriceSeries];
[self calculateYAxisRange];
financialPriceSeries = [[IGFinancialPriceSeries alloc] initWithKey:@"financialPriceSeries"];
financialPriceSeries.xAxis = xAxis;
financialPriceSeries.yAxis = yAxis;
financialPriceSeries.yAxis.minimum = yAxisMin;
financialPriceSeries.yAxis.maximum = yAxisMax;
financialPriceSeries.dataSource = source;
financialPriceSeries.displayType = IGPriceDisplayTypeCandlestick;
financialPriceSeries.brush = [[IGBrush alloc]initWithColor:[UIColor greenColor]];
financialPriceSeries.negativeBrush = [[IGBrush alloc]initWithColor:[UIColor redColor]];
financialPriceSeries.xAxis.majorStrokeThickness = 0.6f;
financialPriceSeries.yAxis.majorStrokeThickness = 0.6f;
financialPriceSeries.xAxis.majorStroke = [[IGBrush alloc]initWithColor:[INVColor gray25]];
financialPriceSeries.yAxis.majorStroke = [[IGBrush alloc]initWithColor:[INVColor gray25]];
[self.chartView addSeries:financialPriceSeries];
IGChartThemeDefinition* theme = [[IGChartThemeDefinition alloc]init];
theme.font = [UIFont fontWithName:@"Helvetica" size:14];
theme.fontColor = [[IGBrush alloc] initWithR:106.0/255.0 andG:113.0/255.0 andB:120.0/255.0 andA:1];
self.chartView.theme = theme;
self.chartView.animateSeriesWhenAxisRangeChanges = YES;
Hi,
To answer your question about zooming and panning programmatically, yes, you can do so by using chart's zoomScale and zoomContentOffset properties.The zoomScale should be set to a value greater than 1 to see any zooming. Having said that, the chart always starts fully zoomed out (zoomScale = 1) and your code snippet doesn't indicate that you're doing any sort of zooming, so I don't understand how your scroll position can be off when there's no where to scroll. I was unable to reproduce this behavior on my end. Would you mind attaching a project for me to debug?
Thanks.
Hi Max,
Thank you for your suggestions. The following code fixed my problem.
self.chartView.zoomContentOffset = CGPointZero;