Created
June 29, 2012 15:29
-
-
Save tsyber1an/3018604 to your computer and use it in GitHub Desktop.
nvd3 tooltip tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link href="http://github.com/novus/nvd3/raw/master/src/d3.css" rel="stylesheet" type="text/css"/> | |
<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> | |
</head> | |
<body> | |
<div id="chart1"> | |
<svg></svg> | |
</div> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/lib/d3.v2.min.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/nv.d3.min.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/src/tooltip.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/src/models/legend.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/src/models/axis.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/src/models/multiBar.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/src/models/multiBarChart.js"></script> | |
<script src="http://github.com/Funfun/nvd3/raw/master/examples/stream_layers.js"></script> | |
<script> | |
$(function(){ | |
var test_data = stream_layers(3,10+Math.random()*100,.1).map(function(data, i) { | |
return { | |
key: 'Stream' + i, | |
values: data | |
}; | |
}); | |
console.log(test_data); | |
nv.addGraph(function() { | |
var chart = nv.models.multiBarChart(); | |
chart.xAxis | |
.tickFormat(d3.format(',f')); | |
chart.yAxis | |
.tickFormat(d3.format(',.1f')); | |
d3.select('#chart1') | |
.datum(test_data) | |
.transition().duration(500).call(chart); | |
nv.utils.windowResize(chart.update); | |
return chart; | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment