This example demonstrates how to use YUI Charts Control to create a Stacked Bar 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.
When creating Bar and Column charts with multiple series, you have the ability to stack your series on top of one-another. In this example, we'll create stacked BarChart, which lets you show the absolute values of data points through their segments, as well as the total values of each series.
First, we'll create the DataSource to populate the chart. This DataSource contains four values, a year and three sets of sales figures.
We will have three series in our example, corresponding to the Internet sales, print sales, and TV sales.
Create a NumericAxis
and set its stackingEnabled
property to true
. Assign a labelFunction
to format the axis.
Instantiate a StackedBarChart
and set its xAxis
to the NumericAxis
you created.
The series bars will stack from left to right rather than aligning vertically.
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: Logging and debugging is currently turned off for this example.
Copyright © 2011 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings