2012-06-15 20:16:08 +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-06-15 20:16:08 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 12px sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
#chart1 {
|
|
|
|
height: 500px;
|
|
|
|
margin: 10px;
|
|
|
|
min-width: 100px;
|
|
|
|
min-height: 100px;
|
|
|
|
/*
|
|
|
|
Minimum height and width is a good idea to prevent negative SVG dimensions...
|
|
|
|
For example width should be =< margin.left + margin.right + 1,
|
|
|
|
of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
2013-08-14 16:00:15 +00:00
|
|
|
<div id="chart1" class='with-3d-shadow with-transitions'>
|
2012-06-15 20:16:08 +00:00
|
|
|
<svg></svg>
|
|
|
|
</div>
|
|
|
|
|
2013-04-16 22:54:46 +00:00
|
|
|
<script src="../lib/d3.v3.js"></script>
|
2012-06-15 20:16:08 +00:00
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/tooltip.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-06-15 20:16:08 +00:00
|
|
|
<script src="../src/models/legend.js"></script>
|
|
|
|
<script src="../src/models/axis.js"></script>
|
|
|
|
<script src="../src/models/multiBar.js"></script>
|
|
|
|
<script src="../src/models/multiBarChart.js"></script>
|
|
|
|
<script src="stream_layers.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
var test_data = stream_layers(3,10+Math.random()*100,.1).map(function(data, i) {
|
2012-07-16 21:03:24 +00:00
|
|
|
//var test_data = stream_layers(3,1,.1).map(function(data, i) { //for testing single data point
|
2012-06-15 20:16:08 +00:00
|
|
|
return {
|
|
|
|
key: 'Stream' + i,
|
|
|
|
values: data
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2013-02-06 15:27:04 +00:00
|
|
|
console.log('td',test_data);
|
|
|
|
|
|
|
|
var negative_test_data = new d3.range(0,3).map(function(d,i) { return {
|
|
|
|
key: 'Stream' + i,
|
2013-05-22 18:54:31 +00:00
|
|
|
values: new d3.range(0,11).map( function(f,j) {
|
2013-02-06 15:27:04 +00:00
|
|
|
return {
|
|
|
|
y: 10 + Math.random()*100 * (Math.floor(Math.random()*100)%2 ? 1 : -1),
|
|
|
|
x: j
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
});
|
2012-06-15 20:16:08 +00:00
|
|
|
|
2012-12-28 05:05:37 +00:00
|
|
|
var chart;
|
2012-06-15 20:16:08 +00:00
|
|
|
nv.addGraph(function() {
|
2013-02-28 22:34:02 +00:00
|
|
|
chart = nv.models.multiBarChart()
|
2013-08-12 16:38:38 +00:00
|
|
|
.barColor(d3.scale.category20().range())
|
2013-08-19 02:42:59 +00:00
|
|
|
.margin({bottom: 100})
|
2013-08-12 16:38:38 +00:00
|
|
|
.transitionDuration(300)
|
2013-08-24 15:06:25 +00:00
|
|
|
.delay(0)
|
2013-08-19 02:42:59 +00:00
|
|
|
.rotateLabels(45)
|
2013-08-20 20:28:59 +00:00
|
|
|
.groupSpacing(0.1)
|
2013-08-12 16:38:38 +00:00
|
|
|
;
|
2012-06-15 20:16:08 +00:00
|
|
|
|
2013-04-08 16:39:33 +00:00
|
|
|
chart.multibar
|
|
|
|
.hideable(true);
|
|
|
|
|
2013-05-22 18:54:31 +00:00
|
|
|
chart.reduceXTicks(false).staggerLabels(true);
|
|
|
|
|
2012-06-15 20:16:08 +00:00
|
|
|
chart.xAxis
|
2013-08-19 02:42:59 +00:00
|
|
|
.axisLabel("Current Index")
|
|
|
|
.showMaxMin(true)
|
|
|
|
.tickFormat(d3.format(',.6f'));
|
2012-06-15 20:16:08 +00:00
|
|
|
|
|
|
|
chart.yAxis
|
|
|
|
.tickFormat(d3.format(',.1f'));
|
|
|
|
|
|
|
|
d3.select('#chart1 svg')
|
2013-02-06 15:27:04 +00:00
|
|
|
.datum(negative_test_data)
|
2013-08-12 16:38:38 +00:00
|
|
|
.call(chart);
|
2012-06-15 20:16:08 +00:00
|
|
|
|
|
|
|
nv.utils.windowResize(chart.update);
|
|
|
|
|
2012-12-28 05:05:37 +00:00
|
|
|
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
|
|
|
|
|
2012-06-15 20:16:08 +00:00
|
|
|
return chart;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|