2012-05-09 19:08:25 +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-05-09 19:08:25 +00:00
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 12px sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<svg id="test1"></svg>
|
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
<svg id="test2"></svg>
|
|
|
|
|
2013-04-16 22:54:46 +00:00
|
|
|
<script src="../lib/d3.v3.js"></script>
|
2012-05-09 19:08:25 +00:00
|
|
|
<script src="../nv.d3.js"></script>
|
2012-06-28 21:18:26 +00:00
|
|
|
<script src="../src/models/pie.js"></script>
|
2012-05-09 19:08:25 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
var testdata = [
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "One",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 5
|
|
|
|
},
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "Two",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 2
|
|
|
|
},
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "Three",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 9
|
|
|
|
},
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "Four",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 7
|
|
|
|
},
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "Five",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 4
|
|
|
|
},
|
|
|
|
{
|
2012-06-28 23:06:07 +00:00
|
|
|
key: "Six",
|
2012-05-09 19:08:25 +00:00
|
|
|
y: 3
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2012-05-14 17:14:12 +00:00
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
nv.addGraph(function() {
|
|
|
|
var width = nv.utils.windowSize().width - 40,
|
|
|
|
height = nv.utils.windowSize().height / 2 - 40;
|
|
|
|
|
|
|
|
var chart = nv.models.pie()
|
2012-09-10 21:55:32 +00:00
|
|
|
.values(function(d) { return d })
|
2012-06-29 19:28:08 +00:00
|
|
|
.width(width)
|
|
|
|
.height(height);
|
2012-05-14 17:14:12 +00:00
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
d3.select("#test1")
|
2012-09-10 21:55:32 +00:00
|
|
|
.datum([testdata])
|
2012-06-29 19:28:08 +00:00
|
|
|
.transition().duration(1200)
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(chart);
|
2012-05-14 17:14:12 +00:00
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
return chart;
|
|
|
|
});
|
2012-06-28 23:06:07 +00:00
|
|
|
|
|
|
|
nv.addGraph(function() {
|
2012-05-09 19:08:25 +00:00
|
|
|
var width = nv.utils.windowSize().width - 40,
|
2012-06-29 19:28:08 +00:00
|
|
|
height = nv.utils.windowSize().height / 2 - 40;
|
2012-05-09 19:08:25 +00:00
|
|
|
|
|
|
|
var chart = nv.models.pie()
|
2012-09-10 21:55:32 +00:00
|
|
|
.values(function(d) { return d })
|
2012-05-09 19:08:25 +00:00
|
|
|
.width(width)
|
2012-05-10 22:13:31 +00:00
|
|
|
.height(height)
|
2012-06-29 19:28:08 +00:00
|
|
|
.donut(true);
|
2012-05-10 16:10:15 +00:00
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
d3.select("#test2")
|
2012-09-10 21:55:32 +00:00
|
|
|
.datum([testdata])
|
2012-06-29 19:28:08 +00:00
|
|
|
.transition().duration(1200)
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(chart);
|
2012-05-10 16:10:15 +00:00
|
|
|
|
2012-05-09 19:08:25 +00:00
|
|
|
return chart;
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|