YUI recommends YUI3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

This documentation is no longer maintained.

YUI Library Examples: Charts Control: Styling Lines, Borders and Fills

Charts Control: Styling Lines, Borders and Fills

The YUI Charts Control offers customization through its style and series style objects. This example demonstrates one way to customize a Line Chart.

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.

January Daily Profits
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.

Data

Our data will include an array of objects, containing values for the date, expenses and revenue. We will create a function that calculates and adds a profits field to each of these items in the array, and will pass this to our datasource.

Series and Styles

Our series definition will include a series for expenses, revenue and profits. Each series will have a style block in which we will style the line, border and fill.

Since we are dealing with negative values, we want to have the ability to highlight them. The Cartesian Charts include a style called zeroGridline. If an axis contains positive and negative values, the zeroGridline style can be used to highlight the gridline that corresponds to zero on the axis. These properties will only take affect if the zero appears beyond the origin of an axis.

Chart

Next, we'll add methods for formatting our axis labels and datatip.

Create axes and set their label functions.

Finally, we'll add our chart, setting its series definition, styles, axes and datatip function.

For full details about styles and series styles, read the Charts Control User's Guide.

Copyright © 2013 Yahoo! Inc. All rights reserved.

Privacy Policy - Copyright Policy - Job Openings