Adding the Bullet Graph to a View
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic explains, with a code example how to create a basic instance of the IGBulletGraphView™ control and display it on a view.

Required background

The following table lists the prerequisite topic required to understanding this topic.

Topic

Purpose

Adding the Chart Framework File

This topic explains how to add the Chart framework file to a project.


In this topic


Displaying an IGBulletGraphView – Code Example

Description

This code example illustrates how to create a linear gauge in the default horizontal orientation with the properties of the targetValue set to 75 and the value set to 82 and adds it to a view.

Preview

Code

To start, initialize a frame to serve as the bullet graph’s dimensions and position.

In Objective-C:

CGRect bulletGraphRect = self.view.bounds;
bulletGraphRect.size.height = 250;
bulletGraphRect.origin.y = (self.view.bounds.size.height / 2) - 125;

In C#:

RectangleF bulletGraphRect = this.View.Bounds;
bulletGraphRect.Height = 250;
bulletGraphRect.Y = (this.View.Bounds.Height / 2) - 125;

Next, create an instance of the bullet graph that uses the same dimensions as the frame.

In Objective-C:

IGBulletGraphView *bulletGraph = [[IGBulletGraphView alloc] initWithFrame:bulletGraphRect];

In C#:

IGBulletGraphView bulletGraph = new IGBulletGraphView ();
bulletGraph.Frame = bulletGraphRect;

Next, set the auto-resizing mask to allow the bullet graph to float in the center of the current device orientation without requiring a size adjustment.

In Objective-C:

bulletGraph.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;

In C#:

bulletGraph.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin;

Set the targetValue property of the bullet graph to 75.

In Objective-C:

bulletGraph.targetValue = 75;

In C#:

bulletGraph.TargetValue = 75;

Set the value property of the bullet graph to 82.

In Objective-C:

bulletGraph.value = 82;

In C#:

bulletGraph.Value = 82;

Finally, add the bullet graph to the view.

In Objective-C:

 [self.view addSubview:bulletGraph];

In C#:

this.View.Add(bulletGraph);

Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

This topic provides a conceptual overview of the IGBulletGraphView control and its key features.