Help:Tree

Various visualization of the tree-shaped data.

Methods to draw tree view from tree-shaped data structure in Wikidata.

Basic

edit

By putting the code {{Tree|property=184|items=Q7251|recursion=10}} using the template {{Tree}}, the following tree graph automatically appears. The code means "Tracking items through doctoral advisor (P184), starting from Alan Turing (Q7251), until 10 items depth." The black dots "•" appears in the tree means the end of branch. The template {{Tree}} internally using Lua module Module:Tree which is the program written in Lua language.

Customize

edit

By customizing Lua code, you can draw the tree with additional features. For example, by putting code {{ #invoke:Haplogroup | main | firstItemId = Q351265 | maxdepth = 7}} (using the customized Lua code Module:Haplogroup), the following tree appears. The tree automatically shows links to Wikipedia, Commons, and external website, by retrieving data stored in each Wikidata item pages.

Lua error in Module:Haplogroup at line 122: bad argument #1 to 'pairs' (table expected, got nil).

{{Wikidata/FamilyTree}} generates family trees of various styles by tracking father (P22), mother (P25), and child (P40). As an example, by putting the code {{Wikidata/FamilyTree|title={{Q|Q9682}}|entityId=Q9682}}, following tree appears.

Extension

edit

Mediawiki extension "Graph" can draw tree-like structures. For demos, see mw:Extension:Graph/Demo#Trees. As of September, 2019, Graph extension is not stable compared with Lua functions. But the extension can draw beautiful interactive graphs. There are templates which uses Graph extension functionalities to draw graphs, like {{Force-directed graph}}, {{Forward graph}}, or {{Reverse graph}}. For example, the code {{Forward graph|Q7251|P184|width=200|height=200|depth=2}} generate the following graph automatically.

External websites

edit

SPARQL

edit
 
Tree Try Out

JSON format

edit
  1. Go https://query.wikidata.org ->
  2. Create query and run ->
  3. Click "</> code" button at middle-right ->
  4. Copy URL ->
  5. Paste URL somewhere (for example Notepad) ->
  6. Adding at the last of the URL &format=json
  7. Example
List view[1]
Radial view[2]
Wikidata generic tree screenshot

Tool to generate trees from Wikidata structures, such as subclasses, administrative divisions, and taxons. Examples: 1 2 3 4

 
Wikidata Graph Builder screenshot

Tool to visualize Wikidata items in a graph form using D3.js. Examples: 1 2 3 4

See also

edit