2012-06-08 21:45:21 +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-08 21:45:21 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 12px sans-serif;
|
|
|
|
}
|
|
|
|
|
2012-06-09 19:44:12 +00:00
|
|
|
svg {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
#chart1 svg{
|
2012-06-08 21:45:21 +00:00
|
|
|
height: 500px;
|
|
|
|
min-width: 100px;
|
|
|
|
min-height: 100px;
|
|
|
|
/*
|
2012-06-09 19:44:12 +00:00
|
|
|
margin: 10px;
|
2012-06-08 21:45:21 +00:00
|
|
|
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>
|
|
|
|
|
|
|
|
<div id="chart1">
|
2012-06-09 19:44:12 +00:00
|
|
|
<svg></svg>
|
2012-06-08 21:45:21 +00:00
|
|
|
</div>
|
|
|
|
|
2013-04-06 15:46:51 +00:00
|
|
|
<script src="../lib/d3.v3.js"></script>
|
2012-06-08 21:45:21 +00:00
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<!-- including all the components so I don't have to minify every time I test in development -->
|
|
|
|
<script src="../src/tooltip.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-06-08 21:45:21 +00:00
|
|
|
<script src="../src/models/axis.js"></script>
|
|
|
|
<script src="../src/models/discreteBar.js"></script>
|
2012-06-09 19:44:12 +00:00
|
|
|
<script src="../src/models/discreteBarChart.js"></script>
|
2012-06-08 21:45:21 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
historicalBarChart = [
|
|
|
|
{
|
|
|
|
key: "Cumulative Return",
|
|
|
|
values: [
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "A" ,
|
2012-11-14 19:45:10 +00:00
|
|
|
"value" : 29.765957771107
|
2012-06-08 21:45:21 +00:00
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "B" ,
|
2012-06-08 21:45:21 +00:00
|
|
|
"value" : 0
|
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "C" ,
|
2012-06-08 21:45:21 +00:00
|
|
|
"value" : 32.807804682612
|
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "D" ,
|
2012-06-08 21:45:21 +00:00
|
|
|
"value" : 196.45946739256
|
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "E" ,
|
2012-06-08 21:45:21 +00:00
|
|
|
"value" : 0.19434030906893
|
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "F" ,
|
2012-11-14 19:45:10 +00:00
|
|
|
"value" : 98.079782601442
|
2012-06-08 21:45:21 +00:00
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "G" ,
|
2012-11-14 19:45:10 +00:00
|
|
|
"value" : 13.925743130903
|
2012-06-08 21:45:21 +00:00
|
|
|
} ,
|
|
|
|
{
|
2012-10-24 20:22:26 +00:00
|
|
|
"label" : "H" ,
|
2012-11-14 19:45:10 +00:00
|
|
|
"value" : 5.1387322875705
|
2012-06-08 21:45:21 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-09 19:57:36 +00:00
|
|
|
nv.addGraph(function() {
|
|
|
|
var chart = nv.models.discreteBarChart()
|
|
|
|
.x(function(d) { return d.label })
|
|
|
|
.y(function(d) { return d.value })
|
2012-07-14 19:46:14 +00:00
|
|
|
.staggerLabels(true)
|
2012-06-09 19:57:36 +00:00
|
|
|
//.staggerLabels(historicalBarChart[0].values.length > 8)
|
2012-06-12 05:50:41 +00:00
|
|
|
.tooltips(false)
|
|
|
|
.showValues(true)
|
2012-06-09 19:57:36 +00:00
|
|
|
|
|
|
|
d3.select('#chart1 svg')
|
|
|
|
.datum(historicalBarChart)
|
|
|
|
.transition().duration(500)
|
|
|
|
.call(chart);
|
|
|
|
|
2012-07-14 19:46:14 +00:00
|
|
|
nv.utils.windowResize(chart.update);
|
2012-06-09 19:57:36 +00:00
|
|
|
|
|
|
|
return chart;
|
|
|
|
});
|
2012-06-08 21:45:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
</script>
|