CFXDataSourceSettings Class Reference

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

Overview

One of the greatest features in Chart FX for iOS is the ability to read or pass data from many sources, including text files, arrays, collections, XML files, etc. The DataSourceSettings class provides the mechanism for configuring your data source and control how Chart FX stores and plots the data.

Properties

dataSource

Gets or sets the source containing the values used to populate the chart.

@property(nonatomic) NSObject dataSource
Discussion

Chart FX supports three different types of data sources:

- You can pass a CFXChartDataSource protocol: you can pass any class that implements the CFXChartDataSource protocol. In many cases, it is the same class that creates the chart.

- You can pass a CoreData object: simply pass a NSFetchedResultsController instance.

- You can pass a collection of objects, such as an NSArray or NSSet.

Once the DataSource has been configured using this property, the chart is automatically bound to the data.

This property has a shortcut called dataSource property and defined in the CFXChart class.

Availability
  • Available in iOS 5.0 and later.
Declared In
ChartFX.h

fields

Returns a collection of CFXFieldMap objects. Those objects allow you to configure how Chart FX will use the data provided.

@property(nonatomic) FieldMapCollection fields
Parameters
n
A zero based index indicating the index of the inserted FieldMap object.
Discussion

Make sure you set the usage for all CFXFieldMaps before reading the data. For example if you have 4 field in your result set, you must make sure 4 assignments are made using this property.

Declared In
ChartFX.h

labelSeparator

Gets or sets a value defining the label separator character used when concatenating labels.

@property(nonatomic) NSString *labelSeparator
Discussion

Only string data types may be concatenated using the label separator.

If there is a space in the string to be used as a label, the configured label separator will not be appended in the label. Only when two strings are added together will the separator be used.

Declared In
ChartFX.h

style

Controls how Chart FX plots the fields in the resultset.

@property(nonatomic) CFXDataSourceStyles style
Discussion

This property is used in conjunction with the fields property to control how Chart FX takes the information from a DataProvider.

Please note that instead of the value associated with the point, you can assign a hidden constant which will cause the point to be hidden in the chart. Although a hidden point is physically in the data array, when you use this constant the marker will not appear in the chart, and if you have charts like a line or area chart, the line will break at that particular point:

chart1.data.y[2,3] = CFXChartHidden;

Chart FX for iOS includes two data style flags that will instruct the component to expect values and X Values or to expect both values and initial values in the data array. For example, lets say that your data looks like this and you want to plot an XY chart:

1 200 3 400

2 100 6 300

When you set the Style to ReadXValues, the data will be passed to the chart like:

chart1.data.x[0,0] = 1;

chart1.data.y[0,0] = 200;

chart1.data.x[1,0] = 3;

chart1.data.y[1,0] = 400;

chart1.data.x[0,1] = 2;

chart1.data.y[0,1] = 100;

chart1.data.x[1,1] = 6;

chart1.data.y[1,1] = 300;

The ReadYFromValues will do the same except it will set initial values using the yFrom property.

Chart FX for iOS willl take all string and date fields to construct a long string that will be used as a legend for each point in the chart. If you want to avoid this behavior, just turn OFF the appropriate constants in this property or control the fields that Chart FX for iOS will use from the Data Source with the DataType property.

Because it is a mask property, you must make sure you use these operators to turn on/off bits and avoid losing previous settings to the property.

For example, if you want to turn on NoMinMax, the right way of setting this property is:

chart1.dataSourceSettings.style = chart1.dataSourceSettings.style | CFXDataSourceStylesNoMinMax;

If you type the following code:

chart1.dataSourceSettings.style = CFXDataSourceStylesNoMinMax;

(WRONG!)

you will erase all other settings in the property causing an erratic behavior of the library and an incorrect setting of the individual methods which also control these flags.

Availability
  • Available in iOS 5.0 and later.
See Also
Declared In
ChartFX.h

Instance Methods

reloadData

Reloads the chart data from the current configured datasource.

- (void) reloadData
Declared In
ChartFX.h

Constants

CFXDataSourceStyles

Define the attributes for the data source columns.

typedef enum {
   CFXNone,
   CFXKeepScale,
   CFXTranspose,
   CFXUseBlobText,
   CFXKeepSeriesLegend,
   CFXKeepLabels,
   CFXReadXValues,
   CFXReadYFromValues,
   CFXDatesAsLabels,
   CFXRewindBeforeReading,
   CFXDefault
} CFXDataSourceStyles;
Constants
CFXNone
Use Chart FX default field assignments.
CFXKeepScale
Instructs Chart FX to retain the axis scaling.
CFXTranspose
See Remarks.
CFXUseBlobText
Use as text from a "binary large object".
CFXKeepSeriesLegend
Instructs Chart FX to retain configured series label strings.
CFXKeepLabels
Instructs Chart FX to retain configured label strings.
CFXReadXValues
Instructs Chart FX that the data read will include both values and x values.
CFXReadYFromValues
Instructs Chart FX that the data read will include Y values.
CFXDatesAsLabels
Instructs Chart FX to use date values as labels.
CFXRewindBeforeReading
Instructs Chart FX to reset DataSource position before reading data.
CFXDefault
Default.
Declared In
chartfx.h