5
<title>Example: Create Stacked Chart</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Create Stacked Chart</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><style scoped>
23
#custom-doc { width: 95%; min-width: 950px; }
24
#pagetitle {background-image: url(../../assets/bg_hd.gif);}
26
margin:10px 10px 10px 10px;
33
<p>This example shows how to create a column <code>Chart</code> with a stacked Numeric Axis.</p>
36
<div id="mychart"></div>
37
<script type="text/javascript">
39
YUI().use('charts', function (Y)
42
{category:"5/1/2010", miscellaneous:2000, expenses:3700, revenue:2200},
43
{category:"5/2/2010", miscellaneous:50, expenses:9100, revenue:100},
44
{category:"5/3/2010", miscellaneous:400, expenses:1100, revenue:1500},
45
{category:"5/4/2010", miscellaneous:200, expenses:1900, revenue:2800},
46
{category:"5/5/2010", miscellaneous:5000, expenses:5000, revenue:2650}
49
var mychart = new Y.Chart({dataProvider:myDataValues, render:"#mychart", type:"column", stacked:true});
55
<h3>This example shows how to create a Stacked Column Chart.</h3>
58
<p>A Stacked Chart is one in which its series are plotted cumulatively against a value axis. Stacked Charts are often used to compare the contribution of each series across categories.
59
In the previous example, we made a column chart. In this example, we're going use the <code>stacked</code> attribute to change it to a Stacked Column Chart.</p>
61
<pre class="code prettyprint">var myDataValues = [
62
{category:"5/1/2010", miscellaneous:2000, expenses:3700, revenue:2200},
63
{category:"5/2/2010", miscellaneous:50, expenses:9100, revenue:100},
64
{category:"5/3/2010", miscellaneous:400, expenses:1100, revenue:1500},
65
{category:"5/4/2010", miscellaneous:200, expenses:1900, revenue:2800},
66
{category:"5/5/2010", miscellaneous:5000, expenses:5000, revenue:2650}
69
var mychart = new Y.Chart({
70
dataProvider:myDataValues,
71
render:"#mychart",
72
type:"column",
76
<p>Technically, all charts plotted against x and y axes can be stacked. The following series types are most commonly and effectively displayed stacked:</p>
78
<li><code>combo</code></li>
79
<li><code>column</code></li>
80
<li><code>bar</code></li>
81
<li><code>area</code></li>
82
<li><code>areaspline</code></li>
83
<li><code>combospline</code></li>
89
<div class="yui3-u-1-4">
96
<h2 class="no-toc">Examples</h2>
100
<ul class="examples">
103
<li data-description="Shows how to use Charts to create a basic chart.">
104
<a href="charts-simple.html">Basic Charts Implementation</a>
109
<li data-description="Shows how to create a chart with multiple series.">
110
<a href="charts-multiseries.html">Chart with Multiple Series</a>
115
<li data-description="Shows how to create a column chart with multiple series.">
116
<a href="charts-column.html">Specify Chart Type</a>
121
<li data-description="Shows how to create a column chart with a stacked numeric axis.">
122
<a href="charts-stackedcolumn.html">Create Stacked Chart</a>
127
<li data-description="Shows how to create a chart with a time axis.">
128
<a href="charts-timeaxis.html">Create a Chart with a Time Axis</a>
133
<li data-description="Shows how to add gridlines to a chart.">
134
<a href="charts-gridlines.html">Add Gridlines to a Chart</a>
139
<li data-description="Shows how to create a chart with planar based events.">
140
<a href="charts-stackedarea.html">Create a Stacked Area Chart with Planar Based Events</a>
145
<li data-description="Shows how to use a chart's styles attribute to customize a chart.">
146
<a href="charts-globalstyles.html">Customize a Chart</a>
151
<li data-description="Shows how to customize the default tooltip of a chart.">
152
<a href="charts-customizedtooltip.html">Customize a Chart's Tooltip</a>
157
<li data-description="Shows how to explicitly define the axes and series for a chart.">
158
<a href="charts-objectstyles.html">Define a Chart's Axes and Series</a>
163
<li data-description="Shows how to use charts to create a pie chart.">
164
<a href="charts-pie.html">Pie Chart</a>
169
<li data-description="Shows how to create a chart with multiple value axes.">
170
<a href="charts-dualaxes.html">Dual Axes Chart</a>
175
<li data-description="Shows how to access a chart instance's value axis after the chart has rendered.">
176
<a href="charts-axisupdate.html">Update Chart Axis</a>
181
<li data-description="Shows how to access a chart instance's seriesCollection after the chart has rendered.">
182
<a href="charts-seriesupdate.html">Update Chart Series</a>
187
<li data-description="Shows how to add a legend to a chart.">
188
<a href="charts-legend.html">Create Chart with a Legend</a>
193
<li data-description="Shows how to render multiple data points in a singe marker.">
194
<a href="charts-groupmarkers.html">Group Marker Chart</a>
209
<script src="../assets/vendor/prettify/prettify-min.js"></script>
210
<script>prettyPrint();</script>