This extension provides the #knowledgegraph
parser function to visualize the knowledge graph in Semantic MediaWiki with vis-network.js
Includes a KnowledgeGraph Designer through which interactively create/export graphs.
Requirements for KnowledgeGraph 1.x:
- PHP 7.4 or later
- MediaWiki 1.39 or later
- SemanticMediaWiki 4.x or later
Insert a parser function like
{{#knowledgegraph:
nodes=Page A, Page B
|properties=HasProperty1,HasProperty2
|depth=3
|graph-options=Mediawiki:KnowledgegraphGraphOptions
|property-options?HasProperty1=Mediawiki:KnowledgegraphNodeOptionsHasProperty1
|show-toolbar=false
|show-property-type=false
|width=100%
|height=400px
}}
This extension uses the vis-network
JavaScript library for rendering network diagrams. The version is managed via npm
and bundled into the extension using a post-install script.
After running npm install
, the following happens automatically:
-
Copying Files
Thecopy-files-from-to
tool copies the minifiedvis-network
files fromnode_modules
to theresources/visNetwork/
directory:vis-network.min.js
vis-network.min.js.map
-
Injecting Comment
A custom script (inject-nomin.js
) prepends the line/*@nomin*/
tovis-network.min.js
.
This comment prevents MediaWiki's ResourceLoader from re-minifying the file.
-
Open
package.json
and change the version under"vis-network"
(e.g.,"vis-network": "latest"
or a specific version like"9.1.9"
). -
Run:
npm install
https://github.com/OpenSemanticLab/mediawiki-extensions-InteractiveSemanticGraph