User:Jason.nlw: Difference between revisions

From Semantic Name Authority Repository Cymru
Jump to navigation Jump to search
No edit summary
(Replaced content with " {{#babel:en|cy}} Sort display order of statements")
Tag: Replaced
 
(19 intermediate revisions by the same user not shown)
Line 2: Line 2:
{{#babel:en|cy}}
{{#babel:en|cy}}


<graph>


{
[[MediaWiki:Wikibase-SortedProperties|Sort display order of statements]]
  "version": 2,
  "width": 600,
  "height": 600,
  "padding": 5,
  "signals": [
    { "name": "rotation", "init": 0,
      "streams": [{
        "type": "click",
        "expr": "rotation + 6.14/180"
      }]
    }
  ],
  "data": [
    {
      "name": "tree",
      "url": ,
      "format": {"type": "treejson"},
      "transform": [
        { "type": "hierarchy", "sort": "name", "size": [6.28, 300], "orient": "radial", "output": {"x": "angle1", "y": "radius"} },
        { "type": "formula", "field": "angle",  "expr": "(datum.angle1 + rotation) % (2*PI)" },
        { "type": "formula", "field": "sign",    "expr": "datum.angle > 3.14 ? 1 : -1" },
        { "type": "formula", "field": "degrees", "expr": "!datum.radius ? 0 : (datum.angle + datum.sign*1.57) * 180/PI" },
        { "type": "formula", "field": "yy",      "expr": "300 + datum.radius * cos(datum.angle)" },
        { "type": "formula", "field": "xx",      "expr": "300 + datum.radius * -sin(datum.angle)" },
        { "type": "formula", "field": "align",  "expr": "!datum.radius ? 'center' : datum.sign < 0 ? 'left' : 'right'" }
      ]
    }
  ],
  "marks": [
    {
      "type": "path",
      "from": {
        "data": "tree",
        "transform": [
          {"type": "filter", "test": "datum.parent"},
          {
            "type": "linkpath",
            "sourceX": "parent.xx", "sourceY": "parent.yy",
            "targetX": "xx", "targetY": "yy",
            "shape": "line"
          }
        ]
      },
      "properties": {
        "update": {
          "path": {"field": "layout_path"},
          "stroke": {"value": "#ddd"}
        }
      }
    },
    {
      "type": "text",
      "from": {"data": "tree"},
      "properties": {
        "update": {
          "x": {"field": "xx"},
          "y": {"field": "yy"},
          "font": {"value": "Helvetica Neue"},
          "fontSize": {"value": 10},
          "align": {"field": "align"},
          "baseline": {"value": "middle"},
          "fill": {"value": "#000"},
          "text": {"field": "name"},
          "angle": {"field": "degrees"}
        }
      }
    }
  ]
}
</graph>
<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>

Latest revision as of 17:44, 25 July 2024