2012-05-29 06:30:15 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
2012-07-13 19:25:19 +00:00
|
|
|
<link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
|
2012-05-29 06:30:15 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 12px sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="test1">
|
|
|
|
<svg></svg>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/tooltip.js"></script>
|
|
|
|
<script src="../src/models/legend.js"></script>
|
|
|
|
<script src="../src/models/axis.js"></script>
|
|
|
|
<script src="../src/models/multiBar.js"></script>
|
|
|
|
<script src="stream_layers.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
//var test_data = stream_layers(3,128,.1).map(function(data, i) {
|
2012-05-29 22:13:55 +00:00
|
|
|
var test_data = stream_layers(3,128,.1).map(function(data, i) {
|
2012-05-29 21:25:00 +00:00
|
|
|
return {
|
2012-05-29 06:30:15 +00:00
|
|
|
key: 'Stream' + i,
|
|
|
|
values: data
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
nv.addGraph({
|
|
|
|
generate: function() {
|
|
|
|
var width = nv.utils.windowSize().width - 40,
|
2012-05-29 22:13:55 +00:00
|
|
|
height = nv.utils.windowSize().height - 40;
|
2012-05-29 06:30:15 +00:00
|
|
|
|
|
|
|
var chart = nv.models.multiBar()
|
|
|
|
.width(width)
|
|
|
|
.height(height)
|
2012-05-29 07:57:22 +00:00
|
|
|
.stacked(true)
|
2012-05-29 06:30:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
var svg = d3.select('#test1 svg')
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.datum(test_data);
|
|
|
|
|
|
|
|
svg.transition().duration(500).call(chart);
|
|
|
|
|
|
|
|
return chart;
|
|
|
|
},
|
|
|
|
callback: function(graph) {
|
|
|
|
|
|
|
|
|
|
|
|
window.onresize = function() {
|
|
|
|
var width = nv.utils.windowSize().width - 40,
|
|
|
|
height = nv.utils.windowSize().height - 40,
|
|
|
|
margin = graph.margin();
|
|
|
|
|
|
|
|
|
|
|
|
if (width < margin.left + margin.right + 20)
|
|
|
|
width = margin.left + margin.right + 20;
|
|
|
|
|
|
|
|
if (height < margin.top + margin.bottom + 20)
|
|
|
|
height = margin.top + margin.bottom + 20;
|
|
|
|
|
|
|
|
|
|
|
|
graph
|
|
|
|
.width(width)
|
|
|
|
.height(height);
|
|
|
|
|
|
|
|
d3.select('#test1 svg')
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(graph);
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|