2012-03-20 23:43:21 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<link href="../src/d3.css" rel="stylesheet" type="text/css">
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<svg id="test1"></svg>
|
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/models/legend.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
|
//Format A
|
|
|
|
nv.addGraph({
|
|
|
|
generate: function() {
|
|
|
|
var width = 500,
|
|
|
|
height = 20;
|
|
|
|
|
|
|
|
var chart = nv.models.legend()
|
|
|
|
.width(width)
|
|
|
|
.height(height);
|
|
|
|
|
2012-05-07 12:53:51 +00:00
|
|
|
chart.dispatch.on('legendClick', function(d,i) { console.log(d,i) });
|
2012-03-20 23:43:21 +00:00
|
|
|
|
|
|
|
//chart.xaxis.tickFormat(d3.format(".02f"))
|
|
|
|
|
|
|
|
d3.select('#test1')
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.datum(sinAndCos())
|
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
return chart;
|
|
|
|
},
|
|
|
|
callback: function(graph) {
|
|
|
|
var chart = graph,
|
|
|
|
height = chart.height();
|
|
|
|
|
|
|
|
d3.select('#test1')
|
|
|
|
.attr('height', height)
|
|
|
|
.call(chart)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sinAndCos() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
key: "Sine Wave"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "A Very Long Series Label"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "A Very Long Series Label"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "A Very Long Series Label"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Cosine Wave"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Another test label"
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|