Help:Tree
Methods to draw tree view from tree-shaped data structure in Wikidata.
Lua edit
Template:Tree edit
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).
Template:Wikidata/FamilyTree edit
{{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.
Graphs are temporarily unavailable due to technical issues.
External websites edit
SPARQL edit
- Wikidata:SPARQL_query_service/queries/examples#Tree
- b:en:SPARQL/Views#Tree
- Landlocked countries bordering coastal countries
JSON format edit
- Go https://query.wikidata.org ->
- Create query and run ->
- Click "
</> code
" button at middle-right -> - Copy URL ->
- Paste URL somewhere (for example Notepad) ->
- Adding at the last of the URL
&format=json
- Example
Wikidata generic tree edit
Tool to generate trees from Wikidata structures, such as subclasses, administrative divisions, and taxons. Examples: 1 2 3 4
Wikidata Graph Builder edit
Tool to visualize Wikidata items in a graph form using D3.js. Examples: 1 2 3 4
See also edit
|