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.
The YUI Charts Control provides built-in support for iterative polling for data over XHR using an XHR DataSource instance. In the example below, iterative polling causes the chart to refresh every several seconds and animate its display to represent the new 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.
First, we will add our chart's container div and buttons for starting and stopping polling.
If a DataSource loads its data from an external source through XHR, a Chart may continually poll the DataSource to determine if new data is available. Nothing special needs to be done to the DataSource. The Chart handles all the details.
Create a column chart that uses our DataSource.
The polling
attribute of the Chart control accepts a numeric value representing the number of milliseconds between requests for new data. We will add methods for starting and stopping polling.
In this case, the Chart control will ask the DataSource to reload its data every two seconds. When new data is available, the chart will redraw or animate to display the new information.
Finally, we'll set our polling methods as event handlers for their respective buttons.
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.