Graph Test
From wikiluntti
Graph
<graph> {
"width": 600,
"height": 150,
"background": "#ffffff",
"data": [
{
"name": "tree",
"values": [
{"A": "Luukalat","B": "Viuhkaeväiset","C": "Cladistia" },
{"A": "Luukalat","B": "Viuhkaeväiset","C": "Rustokiillesuomuiset" },
{"A": "Luukalat","B": "Viuhkaeväiset","C": "Luukiillesuomuiset" },
{"A": "Luukalat","B": "Viuhkaeväiset","C": "Teleosteomorpa" },
{"A": "Luukalat","B": "Varsieväiset","C": "Latimeriat" },
{"A": "Luukalat","B": "Varsieväiset","C": "Keuhkokalat"},
{"A": "Luukalat","B": "Varsieväiset","C": "Nelijalkaiset"},
{"A": "Rustokalat","B": "Hait","C": ""},
{"A": "Rustokalat","B": "Rauskut","C": ""},
{"A": "Rustokalat","B": "Sillikuningaskalat","C": ""},
{"A": "Leuattomat selkärankaiset","B": "Ympyräsuiset","C": "Nahkiaiset"},
{"A": "Leuattomat selkärankaiset","B": "Alkukalat","C": "Pteraspidomorphi"},
{"A": "Leuattomat selkärankaiset","B": "Alkukalat","C": "Thelodonti"},
{"A": "Leuattomat selkärankaiset","B": "Alkukalat","C": "Cephalaspidomorphi"}
],
"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, 'Selkärankaiset', 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>
Line Chart
Tutorial: https://en.wikipedia.org/wiki/Template:Graph:Chart
<graph> Template:Graph:Chart </graph>
Line graphs
https://www.mediawiki.org/wiki/Extension:Graph/Demo
<graph> {
"version": 2,
"width": 550,
"height": 400,
"data": [
{
"name": "tree",
"url": "wikiraw:///Extension:Graph/data/flare-json",
"format": {"type": "treejson"},
"transform": [
{"type": "hierarchy", "field": "size", "size": [400, 500]}
]
}
],
"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": "diagonalX"
}
]
},
"properties": {
"enter": {
"path": {"field": "layout_path"},
"stroke": {"value": "#ddd"}
}
}
},
{
"type": "text",
"from": {"data": "tree"},
"properties": {
"enter": {
"x": {"field": "layout_y", "offset": -10},
"y": {"field": "layout_x"},
"font": {"value": "Helvetica Neue"},
"fontSize": {"value": 10},
"align": {"value": "left"},
"baseline": {"value": "middle"},
"fill": {"value": "#000"},
"text": {"field": "name"}
}
}
}
]
} </graph>