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>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<svg id="test1"></svg>
|
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
2012-06-20 06:00:25 +00:00
|
|
|
<script src="../lib/fisheye.js"></script>
|
2012-03-20 23:43:21 +00:00
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/models/legend.js"></script>
|
|
|
|
<script src="../src/models/scatter.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
|
//Format A
|
|
|
|
nv.addGraph({
|
|
|
|
generate: function() {
|
2012-05-07 12:53:51 +00:00
|
|
|
var width = nv.utils.windowSize().width - 40,
|
|
|
|
height = nv.utils.windowSize().height - 40;
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2012-05-07 12:53:51 +00:00
|
|
|
var chart = nv.models.scatter()
|
2012-03-20 23:43:21 +00:00
|
|
|
.width(width)
|
|
|
|
.height(height)
|
|
|
|
.margin({top: 20, right: 20, bottom: 20, left: 20})
|
2012-06-20 06:00:25 +00:00
|
|
|
.size(function(d) { return d.z })
|
|
|
|
//.interactive(false)
|
2012-03-20 23:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
d3.select('#test1')
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.datum(randomData())
|
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
return chart;
|
|
|
|
},
|
|
|
|
callback: function(graph) {
|
2012-05-07 12:53:51 +00:00
|
|
|
window.onresize = function() {
|
|
|
|
var width = nv.utils.windowSize().width - 40,
|
|
|
|
height = nv.utils.windowSize().height - 40,
|
|
|
|
margin = graph.margin();
|
2012-03-20 23:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (width < margin.left + margin.right + 20)
|
|
|
|
width = margin.left + margin.right + 20;
|
|
|
|
|
|
|
|
if (height < margin.top + margin.bottom + 20)
|
|
|
|
height = margin.top + margin.bottom + 20;
|
|
|
|
|
|
|
|
|
|
|
|
graph
|
|
|
|
.width(width)
|
|
|
|
.height(height);
|
|
|
|
|
|
|
|
d3.select('#test1')
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(graph);
|
|
|
|
|
2012-05-07 12:53:51 +00:00
|
|
|
};
|
2012-03-20 23:43:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function randomData() {
|
|
|
|
var data = [];
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
data.push({
|
|
|
|
key: 'Group ' + i,
|
|
|
|
values: []
|
|
|
|
});
|
|
|
|
|
|
|
|
for (j = 0; j < 100; j++) {
|
2012-06-20 06:00:25 +00:00
|
|
|
data[i].values.push({x: Math.random(), y: Math.random(), z: Math.random()});
|
2012-03-20 23:43:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|