66 lines
1.1 KiB
HTML
66 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
|
|
<style>
|
|
|
|
text {
|
|
font: 10px sans-serif;
|
|
}
|
|
|
|
#chart1 {
|
|
width: 500px;
|
|
height: 50px;
|
|
}
|
|
|
|
</style>
|
|
<body>
|
|
|
|
<h2>SparklinePlus:</h2>
|
|
<p><svg id="chart1" class="sparkline"></svg></p>
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
<script src="../nv.d3.js"></script>
|
|
<script src="../src/utils.js"></script>
|
|
<script src="../src/models/sparkline.js"></script>
|
|
<script src="../src/models/sparklinePlus.js"></script>
|
|
<script>
|
|
|
|
nv.addGraph(function() {
|
|
var data = sine();
|
|
var chart = nv.models.sparklinePlus()
|
|
|
|
chart
|
|
.x(function(d,i) { return i })
|
|
.xTickFormat(function(d) {
|
|
return d3.time.format('%x')(new Date(data[d].x))
|
|
})
|
|
|
|
d3.select("#chart1")
|
|
.datum(data)
|
|
.transition().duration(250)
|
|
.call(chart);
|
|
|
|
nv.utils.windowResize(chart.update);
|
|
|
|
return chart;
|
|
});
|
|
|
|
|
|
var now =+new Date();
|
|
|
|
function sine() {
|
|
var sin = [];
|
|
|
|
|
|
nv.log(now);
|
|
|
|
for (var i = 0; i < 100; i++) {
|
|
sin.push({x: now + i * 1000 * 60 * 60 * 24, y: Math.sin(i/10)});
|
|
}
|
|
|
|
return sin;
|
|
}
|
|
|
|
|
|
</script>
|