You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvd3/examples/pie.html

114 lines
1.6 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<link href="../src/d3.css" rel="stylesheet" type="text/css">
<style>
body {
overflow-y:scroll;
}
text {
font: 12px sans-serif;
}
</style>
<body>
<svg id="test1"></svg>
<script src="../lib/d3.v2.js"></script>
<script src="../nv.d3.js"></script>
<script src="../src/models/pie.js"></script>
<script>
var testdata = [
{
key: "One",
y: 5
},
{
key: "Two",
y: 2
},
{
key: "Three",
y: 9
},
{
key: "Four",
y: 7
},
{
key: "Five",
y: 4
},
{
key: "Six",
y: 3
}
];
var testdata2 = [
{
key: "One",
y: 10
},
{
key: "Two",
y: 5
},
{
key: "Three",
y: 3
},
{
key: "Four",
y: 7
},
{
key: "Five",
y: 2
}
];
var td = 0;
var a = Math.random();
if (a > .5) td = 1;
nv.addGraph(function() {
var width = nv.utils.windowSize().width - 40,
height = nv.utils.windowSize().height - 40;
var chart = nv.models.pie()
.width(width)
.height(height)
;
if (td === 0) {
d3.select("#test1")
.datum(testdata)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);
} else {
d3.select("#test1")
.datum(testdata2)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);
}
return chart;
});
</script>