2012-05-26 17:26:47 +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-05-26 17:26:47 +00:00
|
|
|
<style>
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 10px sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
#chart1 {
|
2012-08-21 23:44:50 +00:00
|
|
|
width: 500px;
|
2012-05-28 02:11:43 +00:00
|
|
|
height: 50px;
|
2012-05-26 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2>SparklinePlus: <svg id="chart1" class="sparkline"></svg></h2>
|
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
|
|
<script src="../nv.d3.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-05-26 17:26:47 +00:00
|
|
|
<script src="../src/models/sparkline.js"></script>
|
|
|
|
<script src="../src/models/sparklinePlus.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
nv.addGraph({
|
|
|
|
generate: function() {
|
|
|
|
var chart = nv.models.sparklinePlus()
|
2012-08-21 23:44:50 +00:00
|
|
|
//.width(400)
|
|
|
|
//.height(50)
|
2012-05-26 17:26:47 +00:00
|
|
|
|
|
|
|
d3.select("#chart1")
|
2012-08-22 21:24:30 +00:00
|
|
|
//.datum([]) //for testing "noData"
|
|
|
|
.datum(sine())
|
|
|
|
.transition().duration(250)
|
|
|
|
.call(chart);
|
2012-05-26 17:26:47 +00:00
|
|
|
|
|
|
|
return chart;
|
|
|
|
},
|
|
|
|
callback: function(graph) {
|
|
|
|
//log("Sparkline rendered");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sine() {
|
|
|
|
var sin = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < 100; i++) {
|
2012-05-27 23:52:28 +00:00
|
|
|
sin.push({x: i + 100, y: Math.sin(i/10)});
|
2012-05-26 17:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|