YUI Library Examples: Charts Control (experimental): Chart and DataTable Example

Charts Control (experimental): Chart and DataTable Example

A YUI Charts Control and a DataTable Control may share a DataSource to display the same data.

Please note: The YUI Charts Control requires Flash Player 9.0.45 or higher. The latest version of Flash Player is available at the Adobe Flash Player Download Center.

Widgets, Inc. Financial Summary 2003-2006
Unable to load Flash content. The YUI Charts Control requires Flash Player 9.0.45 or higher. You can download the latest version of Flash Player from the Adobe Flash Player Download Center.

Create a DataSource

The provider of data for the BarChart and the DataTable in this example is a standard JavaScript Array. Each Object in the Array contains multiple values that can be used for series in the BarChart or headers in the DataTable.

The Array is passed to a new DataSource instance, and fields are defined to specify which items will be used from the original source.

Define a Series Definition

A series definition allows the chart to display more than one series, and one can use it customize the appearance and behavior of each series individually.

In the series definition above, each series uses the xField property to select a different key from the DataSource. The displayName property will provide a visual reference to the name of each series in the mouse-over data tip.

Notice that the third series defines a type property. By customizing this value, we're able to build a combination chart that combines bars and lines to display data.

Create the Chart

The DataSource instance is passed as a required argument of the BarChart's constructor. The series definition is pass in an optional initialization attribute named series.

Define Column Headers and Create DataTable

Similar to the Chart control's series definition, the DataTable control defines column headers. A formatter is set for each column that will display currency.

Both the column headers and the DataSource instance are passed to the DataTable's constructor.

-

YUI Logger Output:

Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.

Reload with logging
and debugging disabled.

More Charts Control (experimental) Resources:

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings