Graph Test: Difference between revisions
From wikiluntti
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
<graph> | <graph> | ||
{ | { | ||
" | "width": 600, | ||
" | "height": 150, | ||
" | "background": "#ffffff", | ||
"data": [ | "data": [ | ||
{ | { | ||
"name": "tree", | "name": "tree", | ||
" | "values": [ | ||
{"A": "Mammal","B": "Carnivore","C": "Panther" }, | |||
{"A": "Mammal","B": "Carnivore","C": "Lion" }, | |||
{"A": "Mammal","B": "Herbivore","C": "Cow" }, | |||
{"A": "Mammal","B": "Herbivore","C": "Goat" }, | |||
{"A": "Mammal","B": "Omnivore","C": "Human"}, | |||
{"A": "Mammal","B": "Omnivore","C": "Bat"}, | |||
{"A": "Fish","B": "Carnivore","C": "Shark"}, | |||
{"A": "Fish","B": "Carnivore","C": "Electric Eel"}, | |||
{"A": "Fish","B": "Omnivore","C": "Piranha "}, | |||
{"A": "Fish","B": "Omnivore","C": "catfish "} | |||
], | |||
"transform": [ | "transform": [ | ||
{"type": "hierarchy", " | { | ||
"type": "treeify", | |||
"groupby": ["A","B"] | |||
}, | |||
{ | |||
"type": "hierarchy", | |||
"mode": "cluster", | |||
"nodesize": [20,100] | |||
}, | |||
{ | |||
"type": "formula", | |||
"field": "align", | |||
"expr": "'right'" | |||
}, | |||
{ | |||
"type": "formula", | |||
"field": "offset", | |||
"expr": "-10" | |||
} | |||
] | ] | ||
} | } | ||
| Line 33: | Line 61: | ||
"data": "tree", | "data": "tree", | ||
"transform": [ | "transform": [ | ||
{ | {"type": "filter","test": "datum.parent"}, | ||
{ | { | ||
"type": "linkpath", | "type": "linkpath", | ||
| Line 42: | Line 68: | ||
"targetX": "layout_y", | "targetX": "layout_y", | ||
"targetY": "layout_x", | "targetY": "layout_x", | ||
"shape": " | "shape": "cornerX" | ||
} | } | ||
] | ] | ||
| Line 49: | Line 75: | ||
"enter": { | "enter": { | ||
"path": {"field": "layout_path"}, | "path": {"field": "layout_path"}, | ||
"stroke": {"value": "# | "strokeWidth": {"value": 2}, | ||
"stroke": {"value": "#000000"} | |||
} | } | ||
} | } | ||
| Line 55: | Line 82: | ||
{ | { | ||
"type": "text", | "type": "text", | ||
"from": {"data": "tree"}, | "from": { | ||
"data": "tree", | |||
"transform": [ | |||
{ | |||
"type": "formula", | |||
"field": "ff_node_label", | |||
"expr": "if(datum.layout_depth == 0, 'Animals', if(datum.layout_depth == 1, datum.A, if(datum.layout_depth == 2, datum.B, if(datum.layout_depth == 3, datum.C, ''))))" | |||
} | |||
] | |||
}, | |||
"properties": { | "properties": { | ||
"enter": { | "enter": { | ||
"x": {"field": "layout_y", "offset" | "x": {"field": "layout_y"}, | ||
"dx": {"field": "offset"}, | |||
"y": {"field": "layout_x"}, | "y": {"field": "layout_x"}, | ||
"font": {"value": " | "dy": {"value": -8}, | ||
"fontSize": {"value": | "font": {"value": "Arial"}, | ||
"align": {" | "fontSize": {"value": 16}, | ||
"align": {"field": "align"}, | |||
"baseline": {"value": "middle"}, | "baseline": {"value": "middle"}, | ||
"fill": {"value": "# | "fill": {"value": "#0000ff"}, | ||
"text": {"field": " | "text": {"field": "ff_node_label"} | ||
} | } | ||
} | } | ||
| Line 71: | Line 109: | ||
] | ] | ||
} | } | ||
</graph> | </graph> | ||
Revision as of 20:43, 13 June 2021
<graph> {
"width": 600,
"height": 150,
"background": "#ffffff",
"data": [
{
"name": "tree",
"values": [
{"A": "Mammal","B": "Carnivore","C": "Panther" },
{"A": "Mammal","B": "Carnivore","C": "Lion" },
{"A": "Mammal","B": "Herbivore","C": "Cow" },
{"A": "Mammal","B": "Herbivore","C": "Goat" },
{"A": "Mammal","B": "Omnivore","C": "Human"},
{"A": "Mammal","B": "Omnivore","C": "Bat"},
{"A": "Fish","B": "Carnivore","C": "Shark"},
{"A": "Fish","B": "Carnivore","C": "Electric Eel"},
{"A": "Fish","B": "Omnivore","C": "Piranha "},
{"A": "Fish","B": "Omnivore","C": "catfish "}
],
"transform": [
{
"type": "treeify",
"groupby": ["A","B"]
},
{
"type": "hierarchy",
"mode": "cluster",
"nodesize": [20,100]
},
{
"type": "formula",
"field": "align",
"expr": "'right'"
},
{
"type": "formula",
"field": "offset",
"expr": "-10"
}
]
}
],
"marks": [
{
"type": "path",
"from": {
"data": "tree",
"transform": [
{"type": "filter","test": "datum.parent"},
{
"type": "linkpath",
"sourceX": "parent.layout_y",
"sourceY": "parent.layout_x",
"targetX": "layout_y",
"targetY": "layout_x",
"shape": "cornerX"
}
]
},
"properties": {
"enter": {
"path": {"field": "layout_path"},
"strokeWidth": {"value": 2},
"stroke": {"value": "#000000"}
}
}
},
{
"type": "text",
"from": {
"data": "tree",
"transform": [
{
"type": "formula",
"field": "ff_node_label",
"expr": "if(datum.layout_depth == 0, 'Animals', if(datum.layout_depth == 1, datum.A, if(datum.layout_depth == 2, datum.B, if(datum.layout_depth == 3, datum.C, ))))"
}
]
},
"properties": {
"enter": {
"x": {"field": "layout_y"},
"dx": {"field": "offset"},
"y": {"field": "layout_x"},
"dy": {"value": -8},
"font": {"value": "Arial"},
"fontSize": {"value": 16},
"align": {"field": "align"},
"baseline": {"value": "middle"},
"fill": {"value": "#0000ff"},
"text": {"field": "ff_node_label"}
}
}
}
]
}
</graph>