General Interface is an open source project hosted by the Dojo Foundation

Displaying Data in Charts

A chart consists of one or more series, usually specified during development, and one or more categories specified at runtime. It is also possible to dynamically generate series at runtime, using the General Interface APIs.

Charts display XML data that conforms to the CDF. With the exception of the jsxid attribute, which is useful for implementing chart events, no other specific attributes are required.

By default, the CDF record structure is assumed to be flat, so only top-level records are included in the chart. If the data includes nested records, you can use JavaScript code to display the nested records. For an example, see Implementing Chart Events.

Working with Series Data

A series is a set of related data points represented by the same attribute repeated in multiple rows of a CDF file. For example:

<data>
 <record date="2" open="5" hi="6" low="4.95" close="5.85"/>
 <record date="3" open="5.75" hi="6.25" low="5.60" close="6.00"/>
 <record date="4" open="6.00" hi="6.55" low="6.00" close="6.50"/>
 <record date="5" open="7.25" hi="7.50" low="6.80" close="6.90"/>
 <record date="6" open="6.95" hi="6.95" low="6.50" close="6.80"/>
 <record date="7"/>
 <record date="8"/>
 <record date="9" open="6.80" hi="7.15" low="6.75" close="6.95"/>
 <record date="10" open="6.90" hi="6.95" low="6.25" close="6.30"/>
 <record date="11" open="6.25" hi="6.50" low="5.75" close="6.35"/>
 <record date="12" open="6.35" hi="6.50" low="5.95" close="6.40"/>
 <record date="13" open="6.25" hi="6.30" low="5.95" close="6.00"/>
...
</data>

Each row includes a set of attributes whose values are individual data points. This sample CDF code could be used to generate four series in a chart, one for each of the open, hi, low and close attributes. The date attribute in this example could be used as a category label, since this attribute applies to every series in the row.

Working with Category Data

A row in the CDF file renders as a category in the associated chart. For example, only two categories are shown in the following chart data:

<data>
   <record height="173" weight="70" ignored="31"/>

   <record height="185" weight="78" ignored="33"/>
</data>

The relationship between categories and series is that a series defines an addressing scheme for extracting data from each category. The following JavaScript code creates a series that references the previous XML:

var series = new jsx3.chart.PointSeries("Height v Weight");
series.setXField("height");
series.setYField("weight");

A category can specify any number of XML attributes such as height and weight, which may or may not be displayed as data points in a specific chart. A category can also include an attribute, such as date, that acts as a label for the category. When the name of this attribute is specified for the Label Field property of a category axis, the attribute values are displayed as axis labels. You can label a Pie series in the same way by specifying a value for the Category Field property.

Categories are automatically indexed and display at runtime in the order they occur in the chart CDF file. When an attribute is used as a category label, the attribute value does not affect the index value.

Contents

Searching General Interface Docs

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.