Circle Packing:包变换需要哪种形状的数据?
Circle Packing: Which shape of data is needed for the pack transform?
我尝试创建一个圆形包装图。我的数据已经是树形了。这是我试过的:
{
"width": 932,
"height": 932,
"data": {
"name": "tree",
"values": {
"name": "root",
"children" : [
{"name" : "leaf1", "value" : 100},
{"name" : "branch",
"children" : [
{"name" : "leaf2", "value" : 200},
{"name" : "leaf3", "value" : 300}
]}
]
},
"transform": [
{
"type": "pack",
"field": "value",
"size": [{"signal": "width"}, {"signal": "height"}]
}
]
},
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "tree", "field": "value"},
"range": {"data": "tree", "field": "value"}
}
]
}
导致错误[Error] w transform requires a backing tree data source.
任何指针都非常感谢。
对应Vega文档,Pack Transform
processes a collection of special tree node objects generated by an
upstream nest or stratify transform.
因此,我检查了 Vega 存储库中的 stratify-test,这是生成的数据:
{
data: {
id: "a",
},
height: 2,
depth: 0,
parent: null,
id: "a",
children: [
{
data: {
id: "b",
pid: "a",
},
height: 0,
depth: 1,
parent: [Circular],
id: "b",
},
{
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
{
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: [Circular],
id: "d",
},
],
},
],
lookup: {
a: [Circular],
b: {
data: {
id: "b",
pid: "a",
},
height: 0,
depth: 1,
parent: [Circular],
id: "b",
},
c: {
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
{
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: [Circular],
id: "d",
},
],
},
d: {
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: {
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
[Circular],
],
},
id: "d",
},
},
}
我尝试创建一个圆形包装图。我的数据已经是树形了。这是我试过的:
{
"width": 932,
"height": 932,
"data": {
"name": "tree",
"values": {
"name": "root",
"children" : [
{"name" : "leaf1", "value" : 100},
{"name" : "branch",
"children" : [
{"name" : "leaf2", "value" : 200},
{"name" : "leaf3", "value" : 300}
]}
]
},
"transform": [
{
"type": "pack",
"field": "value",
"size": [{"signal": "width"}, {"signal": "height"}]
}
]
},
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "tree", "field": "value"},
"range": {"data": "tree", "field": "value"}
}
]
}
导致错误[Error] w transform requires a backing tree data source.
任何指针都非常感谢。
对应Vega文档,Pack Transform
processes a collection of special tree node objects generated by an upstream nest or stratify transform.
因此,我检查了 Vega 存储库中的 stratify-test,这是生成的数据:
{
data: {
id: "a",
},
height: 2,
depth: 0,
parent: null,
id: "a",
children: [
{
data: {
id: "b",
pid: "a",
},
height: 0,
depth: 1,
parent: [Circular],
id: "b",
},
{
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
{
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: [Circular],
id: "d",
},
],
},
],
lookup: {
a: [Circular],
b: {
data: {
id: "b",
pid: "a",
},
height: 0,
depth: 1,
parent: [Circular],
id: "b",
},
c: {
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
{
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: [Circular],
id: "d",
},
],
},
d: {
data: {
id: "d",
pid: "c",
},
height: 0,
depth: 2,
parent: {
data: {
id: "c",
pid: "a",
},
height: 1,
depth: 1,
parent: [Circular],
id: "c",
children: [
[Circular],
],
},
id: "d",
},
},
}