﻿ Axis Scales and Intervals
 Axis Scales and Intervals Send Feedback

Glossary Item Box

## Topic Overview

#### Purpose

This topic explains, with code examples, how to use axis scales and intervals on the IGChartView™ control.

#### In this topic

This topic contains the following sections:

## Introduction

#### Introduction to axis scales and intervals

In the IGChartView control, the axis range is the difference in numeric values from the beginning of the axis to the end or from the smallest to largest values in the data. The range minimum and maximum values represent the lowest and highest value of the axis, respectively.

In order to maximize the chart plot area the IGChartView control’s default settings, calculate the minimum and maximum values for the axis range based on the lowest and highest data points. However, the automatic calculation of an axis' minimum and maximum values may not be appropriate for your set of data points. For example, if your data has a minimum value of 850, you may want to set the minimum value of the axis using its minimum property to 800, thus rendering a graph where the lowest data point is spaced 50 units above the axis minimum. The same can be applied to the axis maximum value and the highest value of data points using axis’s maximum property.

In addition to specifying the scale, along a numeric axis, you can set the interval property at with gridlines and labels will appear on that axis within the set scale. The interval property can also be used when the chart is using the default automatic scale.

The following image compares an IGChartView, with its scale set for minimum and maximum on the IGNumericYAxis (top), an IGChartView (bottom) with its scale set automatically when the minimum or maximum properties are not set.

## Configuring the Axis Scale and Interval on the IGChartView – Code Example

#### Description

The code below uses an area series chart type containing, randomly generated data and sets the y-axis scale to the range of -10 to 110 with an interval of 10. After the series has been added to the IGChartView instance, the current UIView then adds the IGChartView as a subview.

#### Requirements

This code example requires the inclusion of the IGChartView framework. Additional information about how to add this framework can be found in the Adding the IGChartView to a UIView topic.

#### Code

In Objective-C:

```    NSMutableArray *data = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++)
{
double value = arc4random() % 100;
[data addObject:[[NSNumber alloc] initWithDouble:value]];
}

IGCategorySeriesDataSourceHelper *source = [[IGCategorySeriesDataSourceHelper alloc] init];
source.values = data;

IGChartView *infraChart = [[IGChartView alloc] initWithFrame:self.view.frame];
[infraChart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[infraChart setTheme:IGChartThemeIGTheme];

IGCategoryXAxis *xAxis = [[IGCategoryXAxis alloc] initWithKey:@"xAxis"];
IGNumericYAxis *yAxis = [[IGNumericYAxis alloc] initWithKey:@"yAxis"];
yAxis.minimum = -10;
yAxis.maximum = 110;
yAxis.interval = 10;
[infraChart addAxis:xAxis];
[infraChart addAxis:yAxis];

IGAreaSeries *areaSeries = [[IGAreaSeries alloc] initWithKey:@"areaSeries"];
areaSeries.xAxis = xAxis;
areaSeries.yAxis = yAxis;
areaSeries.dataSource = source;

[infraChart addSeries:areaSeries];
[self.view addSubview:infraChart];
```

In C#

```   In Objective-C:    NSMutableArray *data = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++)
{
double value = arc4random() % 100;
[data addObject:[[NSNumber alloc] initWithDouble:value]];
}

IGCategorySeriesDataSourceHelper *source = [[IGCategorySeriesDataSourceHelper alloc] init];
source.values = data;

IGChartView *infraChart = [[IGChartView alloc] initWithFrame:self.view.frame];
[infraChart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[infraChart setTheme:IGChartThemeIGTheme];

IGCategoryXAxis *xAxis = [[IGCategoryXAxis alloc] initWithKey:@"xAxis"];
IGNumericYAxis *yAxis = [[IGNumericYAxis alloc] initWithKey:@"yAxis"];
yAxis.minimum = -10;
yAxis.maximum = 110;
yAxis.interval = 10;
[infraChart addAxis:xAxis];
[infraChart addAxis:yAxis];

IGAreaSeries *areaSeries = [[IGAreaSeries alloc] initWithKey:@"areaSeries"];
areaSeries.xAxis = xAxis;
areaSeries.yAxis = yAxis;
areaSeries.dataSource = source;

[infraChart addSeries:areaSeries];
[self.view addSubview:infraChart];
```

## Related Content

#### Topics

The following topics provide additional information related to this topic.

Topic

Purpose

This topic serves as a gateway to the features and functionality of the IGChartView control.