Axis Crossing
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic uses code examples to demonstrate how to create an axis crossing on the IGChartView™ control.

In this topic


Introduction

Introduction to the axis crossing

Use the IGCategoryXAxis object’s crossingAxis and crossingValue properties in IGChartView to change where the x-axis crosses the y-axis. Set the crossingValue to the value at which you want the x-axis to intersect the y-axis. The following can be applied to the IGNumericYAxis object’s crossingAxis and crossingValue properties to change where the y-axis crosses the x-axis.

The following image is an example of the axis crossing appearance with values set for IGCategoryXAxis and IGNumericYAxis.


Adding an Axis Crossing to the IGChartView – Code Example

Description

The code below uses an area series chart type containing, randomly generated data and sets the axis crossing of the x-axis to 50 and the y-axis to 5. 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, 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"];
    xAxis.crossingAxis = yAxis;
    xAxis.strokeThickness = 5.0f;
    xAxis.crossingValue = 50;
    yAxis.crossingAxis = xAxis;
    yAxis.strokeThickness = 5.0f;
    yAxis.crossingValue = 5;
    [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#:

List<NSObject> data = new List<NSObject>();
Random r = new Random();
for(int i = 0;i <25; i++)
{
double val = r.Next() % 100;
data.Add(new NSNumber(val));
}

IGCategoryDateSeriesDataSourceHelper source = new IGCategoryDateSeriesDataSourceHelper();
source.Values = data.ToArray();



IGChartView chart = new IGChartView(this.View.Frame);
chart.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;

this.View.AddSubview(chart);


IGCategoryXAxis xAxis = new IGCategoryXAxis("xAxis");
IGNumericYAxis yAxis = new IGNumericYAxis("yAxis");
chart.AddAxis(xAxis);
chart.AddAxis(yAxis);

 

xAxis.CrossingAxis = yAxis;
   xAxis.StrokeThickness = 5.0f;
   xAxis.CrossingValue = 50;

   yAxis.CrossingAxis = xAxis;
   yAxis.StrokeThickness = 5.0f;
   yAxis.CrossingValue = 5;



IGAreaSeries series= new IGAreaSeries ("series");
series.XAxis = xAxis;
series.YAxis = yAxis;
series.DataSource = source;

chart.AddSeries(columnSeries);



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.