2012-06-15 23:48:03 +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-06-15 23:48:03 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
svg {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
div {
|
|
|
|
border: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2012-06-22 18:56:15 +00:00
|
|
|
/*
|
2012-06-15 23:48:03 +00:00
|
|
|
#offsetDiv {
|
2012-06-20 06:38:19 +00:00
|
|
|
margin-left: 100px;
|
|
|
|
margin-top: 100px;
|
2012-06-15 23:48:03 +00:00
|
|
|
}
|
2012-06-22 18:56:15 +00:00
|
|
|
*/
|
2012-06-15 23:48:03 +00:00
|
|
|
|
2012-06-26 05:54:59 +00:00
|
|
|
|
2012-06-15 23:48:03 +00:00
|
|
|
#test1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2012-06-22 18:58:23 +00:00
|
|
|
#test1 svg {
|
|
|
|
height: 500px;
|
|
|
|
}
|
2012-06-15 23:48:03 +00:00
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="offsetDiv">
|
2013-08-14 16:00:15 +00:00
|
|
|
<div id="test1" class='with-3d-shadow with-transitions'>
|
2012-06-15 23:48:03 +00:00
|
|
|
<svg></svg>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2013-04-16 22:54:46 +00:00
|
|
|
<script src="../lib/d3.v3.js"></script>
|
2012-11-29 21:54:07 +00:00
|
|
|
<!--<script src="../lib/fisheye.js"></script>-->
|
2012-06-15 23:48:03 +00:00
|
|
|
<script src="../nv.d3.js"></script>
|
|
|
|
<script src="../src/tooltip.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-06-15 23:48:03 +00:00
|
|
|
<script src="../src/models/legend.js"></script>
|
|
|
|
<script src="../src/models/axis.js"></script>
|
2012-06-22 23:52:07 +00:00
|
|
|
<script src="../src/models/distribution.js"></script>
|
2012-06-15 23:48:03 +00:00
|
|
|
<script src="../src/models/scatter.js"></script>
|
|
|
|
<script src="../src/models/scatterChart.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Format A
|
2012-12-28 05:05:37 +00:00
|
|
|
var chart;
|
2012-06-15 23:48:03 +00:00
|
|
|
nv.addGraph(function() {
|
2012-12-28 05:05:37 +00:00
|
|
|
chart = nv.models.scatterChart()
|
2012-06-15 23:48:03 +00:00
|
|
|
.showDistX(true)
|
|
|
|
.showDistY(true)
|
2012-11-29 21:54:07 +00:00
|
|
|
.useVoronoi(true)
|
2013-08-12 17:40:43 +00:00
|
|
|
.color(d3.scale.category10().range())
|
|
|
|
.transitionDuration(300)
|
|
|
|
;
|
2012-06-15 23:48:03 +00:00
|
|
|
|
2013-07-05 02:18:02 +00:00
|
|
|
chart.xAxis.tickFormat(d3.format('.02f'));
|
|
|
|
chart.yAxis.tickFormat(d3.format('.02f'));
|
|
|
|
chart.tooltipContent(function(key) {
|
|
|
|
return '<h2>' + key + '</h2>';
|
|
|
|
});
|
2012-06-15 23:48:03 +00:00
|
|
|
|
|
|
|
d3.select('#test1 svg')
|
2012-06-18 06:17:49 +00:00
|
|
|
.datum(randomData(4,40))
|
2012-06-15 23:48:03 +00:00
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
nv.utils.windowResize(chart.update);
|
|
|
|
|
2013-05-17 20:48:52 +00:00
|
|
|
chart.dispatch.on('stateChange', function(e) { ('New State:', JSON.stringify(e)); });
|
2012-12-28 05:05:37 +00:00
|
|
|
|
2012-06-15 23:48:03 +00:00
|
|
|
return chart;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2012-06-18 06:17:49 +00:00
|
|
|
function randomData(groups, points) { //# groups,# points per group
|
2012-06-15 23:48:03 +00:00
|
|
|
var data = [],
|
2012-06-18 06:20:16 +00:00
|
|
|
shapes = ['circle', 'cross', 'triangle-up', 'triangle-down', 'diamond', 'square'],
|
2012-06-15 23:48:03 +00:00
|
|
|
random = d3.random.normal();
|
|
|
|
|
2012-06-18 06:17:49 +00:00
|
|
|
for (i = 0; i < groups; i++) {
|
2012-06-15 23:48:03 +00:00
|
|
|
data.push({
|
|
|
|
key: 'Group ' + i,
|
|
|
|
values: []
|
|
|
|
});
|
|
|
|
|
2012-06-18 06:17:49 +00:00
|
|
|
for (j = 0; j < points; j++) {
|
|
|
|
data[i].values.push({
|
|
|
|
x: random(),
|
|
|
|
y: random(),
|
|
|
|
size: Math.random(),
|
2012-06-18 14:34:23 +00:00
|
|
|
shape: shapes[j % 6]
|
2012-06-18 06:17:49 +00:00
|
|
|
});
|
2012-06-15 23:48:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|