Skip to content

Instantly share code, notes, and snippets.

@foxxtrot
Created December 13, 2010 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxxtrot/739556 to your computer and use it in GitHub Desktop.
Save foxxtrot/739556 to your computer and use it in GitHub Desktop.
Testing YUI3 Charts for a Blog Post, multiple Charts on one document.
<!DOCTYPE html>
<meta charset="utf-8">
<title>Charts Test</title>
<style type="text/css">
body { width: 755px; }
.chartContainer { clear: both; }
.yui3-cartesianchart { float: left; }
.chartLegend { float: right; width: 225px; border-style: groove; padding: 3px;}
.chartLegend ul { list-style-type: none; padding: 0;}
.chartLegend li { padding-left: 8px; }
</style>
<div class="chartContainer">
<h3>Time to Compress</h3>
<div id="timeChart"></div>
<div class="chartLegend">
<h3>Legend</h3>
<ul>
<li style="border-left: 1em solid #66007f;">UglifyJS</li>
<li style="border-left: 1em solid #a86f41;">YUICompressor - Command Line Mode</li>
<li style="border-left: 1em solid #295454;">YUICompressor - Server Mode</li>
<li style="border-left: 1em solid #426ab3;">Google Closure Compiler</li>
</ul>
</div>
</div>
<div class="chartContainer" style="margin-top: 20em;">
<h3>File Size Comparisons</h3>
<div id="sizeChart"></div>
<div class="chartLegend">
<h3>Legend</h3>
<ul>
<li style="border-left: 1em solid #66007f;">UglifyJS</li>
<li style="border-left: 1em solid #a86f41;">YUICompressor - Command Line Mode</li>
<li style="border-left: 1em solid #295454;">YUICompressor - Server Mode</li>
<li style="border-left: 1em solid #426ab3;">Google Closure Compiler</li>
</ul>
</div>
</div>
<script src="http://yui.yahooapis.com/3.3.0pr1/build/yui/yui-min.js"></script>
<script src="./charts.js"></script>
<script type="text/javascript">
YUI({filter: 'RAW'}).use('node', 'charts', function(Y) {
var means = [
{
category: "jQuery 1.4.3",
"UglifyJS": 1.78314,
"YUICompressor - Server Mode": 5.33394,
"YUICompressor - Command Line": 2.43295,
"Closure Compiler": 6.24726
},
{
category: "MooTools Core 1.3",
"UglifyJS": 1.61559,
"YUICompressor - Server Mode": 0.16999,
"YUICompressor - Command Line": 2.40805,
"Closure Compiler": 5.80976
},
{
category: "SimpleYUI 3.3.0pr1",
"UglifyJS": 2.54286,
"YUICompressor - Server Mode": 0.28002,
"YUICompressor - Command Line": 2.59650,
"Closure Compiler": 6.55533
}
], meansChart = new Y.Chart({ type:"column", dataProvider: means, height: 300, width: 500,
axes: {
times: {
keys: ["UglifyJS", "YUICompressor - Server Mode", "YUICompressor - Command Line", "Closure Compiler"],
position: "left",
type: "numeric",
roundingUnit: 1
},
libs: {
keys: ["category"],
position: "bottom",
type: "category"
}
},
// Defining Axes and Series collection SOLELY so I can ensure my legend renders correctly. Will later right a plugin to generate the legend.
seriesCollection: [
{
type: "column",
xAxis: "libs",
yAxis: "times",
xKey: "category",
yKey: "UglifyJS",
styles: {
marker: {
fill: { color: "#66007f" }
}
}
},
{
type: "column",
xAxis: "libs",
yAxis: "times",
xKey: "category",
yKey: "YUICompressor - Command Line",
styles: {
marker: {
fill: { color: "#a86f41" }
}
}
},
{
type: "column",
xAxis: "libs",
yAxis: "times",
xKey: "category",
yKey: "YUICompressor - Server Mode",
styles: {
marker: {
fill: { color: "#295454" }
}
}
},
{
type: "column",
xAxis: "libs",
yAxis: "times",
xKey: "category",
yKey: "Closure Compiler",
styles: {
marker: {
fill: { color: "#426ab3" }
}
}
}
],
render:"#timeChart"}),
sizes = [
{
category: "jQuery 1.4.3",
"Unminified": 180459,
"Unminified - gzipped": 51033,
"Closure Compiler": 77379,
"Closure Compiler - gzipped": 26456,
"UglifyJS": 77634,
"UglifyJS - gzipped": 26142,
"YUICompressor": 107757,
"YUICompressor - gzipped": 30558
},
{
category: "MooTools Core 1.3",
"Unminified": 140971,
"Unminified - gzipped": 37058,
"Closure Compiler": 81284,
"Closure Compiler - gzipped": 25859,
"UglifyJS": 83325,
"UglifyJS - gzipped": 25728,
"YUICompressor": 106701,
"YUICompressor - gzipped": 29241
},
{
category: "SimpleYUI 3.3.0pr1",
"Unminified": 475248,
"Unminified - gzipped": 110697,
"Closure Compiler": 102412,
"Closure Compiler - gzipped": 34959,
"UglifyJS": 101527,
"UglifyJS - gzipped": 34929,
"YUICompressor": 138638,
"YUICompressor - gzipped": 41880
}
], sizeChart = new Y.Chart({ type:"column", dataProvider: sizes, height: 300, width: 500, render:"#sizeChart"});
window.chart = meansChart;
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment