Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
IGBarSeries xAxis scale doesn't match data
posted

I have a data point at 4212 yet the graph implies a value < 3000

self.chart = [[IGChartView alloc] init];
self.chart.frame = CGRectMake(0, 0, self.displayView.frame.size.width, self.displayView.frame.size.height);
self.chart.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleBottomMargin;
self.chart.theme = [IGChartDefaultThemes IGTheme];
self.displayView.backgroundColor = [UIColor blackColor];
self.chart.crosshairsVisibility = IGCrosshairsVisibilityVertical;
self.chart.tooltipPinLocation = IGTooltipPinLocationTop;
self.chart.delegate = self;

[self.view addSubview:self.chart];

IGBarSeries *barSeries1 = (IGBarSeries *)[self.chart addSeriesForType:[IGBarSeries class]
usingKey:@"seenSeries"
withDataSource:self
firstAxisKey:@"xAxis"
secondAxisKey:@"yAxis"];
barSeries1.title = @"Seen";
barSeries1.xAxis.extent = 45;
barSeries1.xAxis.interval = 1000;

graph image

The data points (as rendered bottom to top) are:

0.000000
1797.000000
977.000000
2172.000000
1520.000000
4212.000000
971.000000
352.000000

Parents
No Data
Reply
  • 4940
    Offline posted

    Hi Kaushik,

    Attached you'll find an example project that wires up JSON data to the IGChartView. The requirements for using the JSON API's is iOS 5+. In addition, you will need to add the IGChart.framework to the project. I have removed it from this example, so you can reference your copy.

    To summarize what is necessary to connect JSON data to the IGChartView, you take the returned JSON dictionary and get the array of data records by key lookup. By iterating through this array, we create a business class object that represents the data record and add it to a mutable array.  It's this array that will be referenced when using a data source helper.

    If you have any questions about the source code, let me know.

    ChartWithJSON.zip
Children