2012-03-20 23:43: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-03-20 23:43:21 +00:00
|
|
|
<style>
|
|
|
|
|
|
|
|
.sparkline path {
|
|
|
|
fill: none;
|
|
|
|
stroke: #444;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 10px sans-serif;
|
|
|
|
}
|
|
|
|
|
2012-05-26 17:26:47 +00:00
|
|
|
#chart1 {
|
|
|
|
width: 300px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
|
2012-03-20 23:43:21 +00:00
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
2012-05-26 17:26:47 +00:00
|
|
|
<h2>Sparkline: <svg id="chart1" class="sparkline"></svg></h2>
|
2012-03-20 23:43:21 +00:00
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/models/sparkline.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-03-20 23:43:21 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
//Format A
|
|
|
|
nv.addGraph({
|
|
|
|
generate: function() {
|
|
|
|
var chart = nv.models.sparkline()
|
2012-05-07 12:53:51 +00:00
|
|
|
.width(400)
|
2012-05-26 17:26:47 +00:00
|
|
|
.height(30)
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2012-05-26 17:26:47 +00:00
|
|
|
d3.select("#chart1")
|
2012-03-20 23:43:21 +00:00
|
|
|
.datum(sine())
|
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
return chart;
|
|
|
|
},
|
|
|
|
callback: function(graph) {
|
|
|
|
//log("Sparkline rendered");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sine() {
|
|
|
|
var sin = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < 100; i++) {
|
|
|
|
sin.push({x: i, y: Math.sin(i/10)});
|
|
|
|
}
|
|
|
|
|
|
|
|
return sin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|