145
Chapter 4: Displaying Data and Labels
Adobe® Flex® provides some techniques for displaying data and labels in your charts.
To p ic s
Working with axes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
About the CategoryAxis class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
About the NumericAxis class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Adding axis titles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Defining axis labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Using data labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Using DataTip objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Using per-item fills . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Using the minField property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Stacking charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Using Legend controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Working with axes
Each chart, except for a pie chart, has horizontal and vertical axes. There are two axis types: category and numeric.
A category axis typically defines strings that represent groupings of items in the chart; for example, types of expenses
(such as rent, utilities, and insurance) or names of employees. A numeric axis typically defines continuous data such
as the amount of an expense or the productivity gains of the employee. These data define the height of a column, for
example. Numeric axes include the LinearAxis, LogAxis, and DateTimeAxis.
You work with the axes objects to define their appearance, but also to define what data is displayed in the chart.
The following sections describe the CategoryAxis and NumericAxis classes.
About the CategoryAxis class
The CategoryAxis class maps discrete categorical data (such as states, product names, or department names) to an
axis and spaces them evenly along it. This axis accepts any data type that can be represented by a String.
The dataProvider property of the CategoryAxis object defines the data provider that contains the text for the
labels. In most cases, this can be the same data provider as the chart’s data provider. A CategoryAxis object used in
a chart inherits its
dataProvider property from the containing chart, so you are not required to explicitly set the
dataProvider property on a CategoryAxis object.
The
dataProvider property of a CategoryAxis object can contain an Array of labels or an Array of objects. If the
data provider contains objects, you use the
categoryField property to point to the field in the data provider that
contains the labels for the axis, as the following example shows:
<?xml version="1.0"?>
<!-- charts/BasicColumn.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

Get ADOBE® FLEX® 3: ADVANCED DATA VISUALIZATION DEVELOPER GUIDE now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.