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.
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.
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.
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.
You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.
Note: You are viewing this example in debug mode with logging enabled. This can significantly slow performance.
Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings