Skip to content

Instantly share code, notes, and snippets.

@ameenkhan07
Last active July 2, 2016 17:45
Show Gist options
  • Save ameenkhan07/a298ac85def3de298511e33b83eaba4b to your computer and use it in GitHub Desktop.
Save ameenkhan07/a298ac85def3de298511e33b83eaba4b to your computer and use it in GitHub Desktop.
ChaiChui
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://raw.githubusercontent.com/novus/nvd3/master/build/nv.d3.css" rel="stylesheet" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js" charset="utf-8"></script>
<script src="https://raw.githubusercontent.com/novus/nvd3/master/build/nv.d3.js"></script>
<style>
text {
font: 12px sans-serif;
}
svg {
display: block;
}
html, body, #chart1, svg {
margin: 0px;
padding: 0px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="chart1">
<svg></svg>
</div>
<script>
historicalBarChart = [
{
key: "Cumulative Return",
values: [
{
"label" : "A" ,
"value" : 29.765957771107
} ,
{
"label" : "B" ,
"value" : 0
} ,
{
"label" : "C" ,
"value" : 32.807804682612
} ,
{
"label" : "D" ,
"value" : 196.45946739256
} ,
{
"label" : "E" ,
"value" : 0.19434030906893
} ,
{
"label" : "F" ,
"value" : 98.079782601442
} ,
{
"label" : "G" ,
"value" : 13.925743130903
} ,
{
"label" : "H" ,
"value" : 5.1387322875705
}
]
}
];
nv.addGraph(function() {
var chart = nv.models.discreteBarChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.staggerLabels(true)
//.staggerLabels(historicalBarChart[0].values.length > 8)
.showValues(true)
.duration(250)
;
d3.select('#chart1 svg')
.datum(historicalBarChart)
.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