mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-01-15 15:40:53 +01:00
84 lines
No EOL
2.1 KiB
HTML
84 lines
No EOL
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<link href="../build/nv.d3.css" rel="stylesheet" type="text/css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js" charset="utf-8"></script>
|
|
<script src="../build/nv.d3.js"></script>
|
|
|
|
<style>
|
|
text {
|
|
font: 12px sans-serif;
|
|
}
|
|
svg {
|
|
display: block;
|
|
}
|
|
html, body, #test1, svg {
|
|
margin: 0px;
|
|
padding: 0px;
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class='with-3d-shadow with-transitions'>
|
|
|
|
<div id="test1" class="chartWrap">
|
|
<svg></svg>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
var chart;
|
|
nv.addGraph(function() {
|
|
chart = nv.models.scatterChart()
|
|
.showDistX(true)
|
|
.showDistY(true)
|
|
.duration(300)
|
|
.color(d3.scale.category10().range());
|
|
|
|
chart.dispatch.on('renderEnd', function(){
|
|
console.log('render complete');
|
|
});
|
|
|
|
chart.xAxis.tickFormat(d3.format('.02f'));
|
|
chart.yAxis.tickFormat(d3.format('.02f'));
|
|
|
|
d3.select('#test1 svg')
|
|
.datum(nv.log(randomData(4,40)))
|
|
.call(chart);
|
|
|
|
nv.utils.windowResize(chart.update);
|
|
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
|
|
return chart;
|
|
});
|
|
|
|
|
|
function randomData(groups, points) { //# groups,# points per group
|
|
var data = [],
|
|
shapes = ['circle'],
|
|
random = d3.random.normal();
|
|
|
|
for (i = 0; i < groups; i++) {
|
|
data.push({
|
|
key: 'Group ' + i,
|
|
values: [],
|
|
slope: Math.random() - .01,
|
|
intercept: Math.random() - .5
|
|
});
|
|
|
|
for (j = 0; j < points; j++) {
|
|
data[i].values.push({
|
|
x: random(),
|
|
y: random(),
|
|
size: Math.random(),
|
|
shape: shapes[j % shapes.length]
|
|
});
|
|
}
|
|
}
|
|
return data;
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |