我试图让 d3 遍历数据中的子数组并生成多个饼图。
这是完整的代码(来自https://gist.github.com/mbostock/1305111 和https://gist.github.com/enjalot/1203641):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>D3 Page Test</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<script type="text/javascript">
// Define the data as a two-dimensional array of numbers. If you had other
// data to associate with each number, replace each number with an object, e.g.,
// `{key: "value"}`.
var datad = [
{s:[ 20, 1, 1], l:[10,100]},
{s:[ 1, 20, 1], l:[ 20, 200]}, …Run Code Online (Sandbox Code Playgroud) d3.js ×1