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.
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.
We will start by creating a custom class to contain all the necessary elements required to render a chart.
Our class contains a reference to a dataTip function, data, chart, styles and some custom text to be used in our data tips.
We will now add all the methods necessary for formatting axis labels and data tips. It is important to note that the dataTip and axis label methods make use of other class level methods, so the ability to add socpe to these methods will prove useful.
Next, we will add methods that return an axis and a series definition. We will also add a method that draws our chart. Each of these methods will create references to text formatting functions to pass to our YUI Chart instance. Our vertical axis method sets the axis label function, our series definition sets a data tip function for our car payment series and our chart method sets the data tip function for all other series.
Normally, when setting a formatting function for the chart, a function is passed either directly or as a string reference. When you want to include scope, however, you instead pass an object with two properties, func
, a reference to the function, and scope
, a reference to the scope. dataTipFunction:{func:myDataTipFunction, scope:this}
Finally, we'll instantiate our class and draw the chart.
Note: Logging and debugging is currently turned off for this example.
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.
Copyright © 2013 Yahoo! Inc. All rights reserved.