CFXCustomGridLine Class Reference

Inherits from
Conforms to
Framework
Availability
Available in iOS 5.0 and later.
Companion guide
Declared in
ChartFX.h

Overview

CustomGridLines are one of the most useful objects when it comes to highlighting information in the chart area. You may want to create a Line to highlight limits or specific points of interest in the chart. For example, in a scientific application, you may want to use the CustomGridLine class to highlight an alarm limit, or in a financial application, you may want to use the CustomGridLine to highlight a target price or date.

CustomGridLines are lines that you can draw anywhere in the chart area and they associate themselves with a particular value in the CFXAxis that they're assigned to, as illustrated in the following figure:

You can create as many CustomGridLine objects as you need, and you can also configure labels, line width, styles, colors, etc.

If you want to highlight a range of values instead of a specific value, please refer to the CFXAxisSection class.

In order to use this functionality you must include jchartfx.advanced.js in your project.

Properties

alignment

Gets or sets the Alignment for the Label in a CustomGridLine.

@property(nonatomic) CFXStringAlignment alignment
Discussion

The Alignment will position the CustomGridLine Label in the desired location.

This property will also take effect, if set to Far or Near, when the outsideText property is set to true.

Declared In
ChartFX.h

extraStyle

Allows you to set additional visual attributes in a custom grid line.

@property(nonatomic) CFXCustomGridLineStyles extraStyle
Availability
  • Available in iOS 5.0 and later.
Declared In
ChartFX.h

lineAlignment

Gets or sets the alignment for the Text line relative to the CustomeGridLine.

@property(nonatomic) CFXStringAlignment lineAlignment
Discussion

The LineAlignment will position the Text label line in the desired location.

This property will also take effect when the outsideText property is set to true.

Declared In
ChartFX.h

outsideText

Gets or set the OutsideText which controls the positioning of the CustomGridLine label outside the chart area.

@property(nonatomic) BOOL outsideText
Discussion

When this property is set to True, the text associated with the CustomGridLine is placed outside the charting area.

alignment and lineAlignment settings will still apply when this proprty is set to true.

Declared In
ChartFX.h

showLine

Gets or set the ShowLine, which shows or hides the CustomGridLine line.

@property(nonatomic) BOOL showLine
Discussion

When you hide a CustomGridLine line using this property, any text associated with the line will remain in the chart. Use the showText property to show or hide the CustomGridLine text.

Declared In
ChartFX.h

showText

Gets or set the Showtext, which shows or hides the CustomGridLine text.

@property(nonatomic) BOOL showText
Discussion

When you hide a CustomGridLine test using this property, any Line associated will remain in the chart. Use the showLine property to show or hide the CustomGridLine line.

Declared In
ChartFX.h

text

Gets or sets the Text for a label in a CustomGridLine.

@property(nonatomic) NSString *text
Discussion

When a CustomGridLine is associated with any of the Y axes, the default text alignment is Near (Left). On the other hand, if the label is associated with the X axis the default text alignment is Near (bottom). You can modify the text alignment with the alignment property.

To change the font for the text label in a CustomGridLine, use the font property.

To change the text color, use the textColor property.

By default, a CustomGridLine with Text will appear in the legend. It can be removed from the legend using the ItemAttributes property of the LegendBox object.

Declared In
ChartFX.h

value

Gets or sets the Value for a CustomGridLine.

@property(nonatomic) double value
Discussion

The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:

- If the CustomGridLine is associated with a numerical axis, the value of the constant is a double according to the scale values set for that particular axis. Please note that a CustomGridLine may be associated to the X axis in an XY Plot where the X axis is a numerical axis with specific scale values.

- If the CustomGridLine is associated with a categorical axis (X axis in charts other than XY Plots), the value is an integer specifying the point index you want to associate the CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.

Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX for iOS will not recalculate the scale and you must set the min or max accordingly so the custom line can be seen.

For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the max property of the axis that the custom line is attached to in order to see it on the chart.

Declared In
ChartFX.h

Constants

CFXCustomGridLineStyles

Defines the style of the line for a CustomGridLine

typedef enum {
   CFXNone,
   CFXHideText,
   CFXHide,
   CFXBackOnly,
   CFXColorText,
   CFXHideLine,
   CFXOutsideText,
   CFXShowValue
} CFXCustomGridLineStyles;
Constants
CFXNone
No styling
CFXHideText
Hides the text for the CustomGridLine
CFXHide
Hides the CustomGridLine
CFXBackOnly
Disables interactivity for the CustomGridLine
CFXColorText
Applies the line color to the text
CFXHideLine
Hides the line only
CFXOutsideText
Places the line's text outside the chart area
CFXShowValue
Show the line's associated value
Declared In
chartfx.h

CFXStringAlignment

The StringAlignment type specifies how a string is aligned in reference to the bounding rectangle. A bounding rectangle is used to define the area in which the text displays.

typedef enum {

} CFXStringAlignment;
Constants
CFX
Specifies that alignment is towards the origin of the bounding rectangle. May be used for alignment of characters along the line or for alignment of lines within the rectangle. For a right to left bounding rectangle, the origin is at the upper right.
CFX
Specifies that alignment is centered between origin and extent (width) of the formatting rectangle.
CFX
Specifies that alignment is to the far extent (right side) of the formatting rectangle.
Declared In
chartfx.h