Extension:Graph/cs

Rozšířeníení Graph umožňuje značce popisující vizualizace dat, jako jsou sloupcové grafy, koláčové grafy, časové osy a histogramy (demo) ve formátu JSON, který vykresluje Vega-základy grafu.



Základní informace
Rozšíření grafu umožňuje přidání výkonných grafů na Wiki založených na vega. Grafy mohou být interaktivní.

Nejjednodušší způsob, jak přidat graf, je použít připravenou šablonu, jako je. Tyto šablony skrývají všechny složitosti Vega. Výkonní uživatelé mohou používat k vývoji grafů pískoviště Graph Sandbox. Sandbox Graph umožňuje kromě JSON syntaxi šablon wiki. The extension integrates with VisualEditor, providing a simple tool/wizard which generates basic graphs, by entering values directly to the editor.



Užitečné odkazy

 * Dokumentace Vega 2 - obnovené stránky dokumentace Vega 2.
 * – Obecná doporučení, jak používat grafy ve Wiki.
 * – pokyny, jak od začátku vytvořit komplexní interaktivní graf, krok za krokem
 * - pro mnoho ukázek a triků k použití.
 * TechTalk Video – technická přednáška WMF pojednávající o rozšíření Graph, včetně skvělé ukázky editoru Lyra (také nainstalovaného v laboratořích).
 * Také by vás mohly zajímat některé z budoucích schopností Vega (Keynote od Jeffreyho Heera).
 * Vega pro vývojáře – nejlepší místo ze všech zdrojů Vega
 * Úvodní video do interaktivní Vega
 * Úvodní video do interaktivní Vega

Instalace


Další nastavení konfigurace
Pokud chcete replikovat produkční prostředí, jako je en.wiki, budete muset provést následující kroky:

Role (pouze pokud jste se rozhodli použít Vagrant)


 * Povolit roli grafů
 * Povolit roli autora
 * Povolit roli obrázkové mapy

Šablony a moduly Lua


 * Lokálně zkopírujte Module:Graph
 * Lokálně zkopírujte Module:Graph/doc
 * Lokálně zkopírujte Template:Nowrap
 * Copy Template:Nowrap/styles.csslocally
 * Lokálně zkopírujte Module:Chart
 * Lokálně zkopírujte Module:Chart/Default_colors
 * Lokálně zkopírujte File:Circle_frame.svg



Příklady grafů
Viz - pro mnoho ukázek a triků k použití.



Uživatelsky definované záložní řešení
When using client side rendering, it is possible to use Wikimedia Commons to provide a static fallback image to  users. This is a temporary solution until a new service is put in place to provide server side rendering.

The user must first upload the static graph to Wikimedia Commons.

Fallback images have two variables  and.

relates to a Wikimedia Commons filename.

is the fallback images width in pixels.

These variables are pass through the graph in the following way:

Where lua modules are used such as Module:Graph then these variables can be provided via the tag function. If were adapted, it would look like this:

It would then be utilised in a template in the following manner:

If a fallbackWidth isn't provided but an image is defined then the extension will derive the width from the provided graph width. The reason for this is there is frequently a difference in the rendered image width and the actual image width.

External data
HTTP(S) protocol cannot be used to get data for the graph. Instead, use one of the custom wiki protocols like,  , and others.

Graph extension uses the  setting to control how these protocols are resolved: Note that because queries rely on the structure of wikibase items, they may suddenly stop working if the underlying data is edited and changes, as it may yield incomplete, empty or invalid data that can't be used to create a graph. In these cases the graph will end up empty (see T168601).

Known bugs & limitations

 * tag/graph - Graph extension bugs
 * Fails to implement ISO 8601 timescales so only Gregorian calendars can be used in timelines

Internals
When parsing, the Graph extension expands all template parameters/expressions, and stores the complete graph definitions in the ParserOutput, using graph hashes for IDs.

The graph extension adds HTML to the page where graphs should go, a with a graph-id as the attribute. Sample:

The Graph extension adds an  ResourceLoader JavaScript module to the page that includes the Vega library, and puts the JSON of graph definitions into a JavaScript   variable named. Once the client has loaded this module, the Vega JavaScript library populates each with an HTML canvas and draws the graph in it, replacing the static image.

Security features
can be configured to disallow referencing untrusted data sources (e.g. Wikimedia only allows data from the Wikimedia sites).

License
Vega library is distributed under a modified BSD license acceptable under for us to use.

This appears to be a copy of the BSD license, with some minor (acceptable) modifications. It's not a problem for us to use it, although ideally they would not make changes like this to the license. It's better if people do not make these changes to their license, to avoid confusion (like this) about whether the license is safe for open-source use.

wgGraphAllowedDomains
See the section on external data.

Other variables

 * 2015 - wgGraphUrlBlacklist has been removed in 787d64a11.
 * 2016 - wgGraphDataDomains has been removed in e0813f85a. Use wgGraphAllowedDomains instead.
 * 2015 - wgGraphUserServiceAlways has been removed in b735f63ff4b.
 * 2019 - wgGraphIsTrusted has been removed in cf80f43e15.
 * 2020 - $wgGraphImgServiceUrl was deprecated.

Enabling Graph namespace
To store graph definitions as standalone pages in their own namespace, configure.

VisualEditor module
Since summer 2015, the Graph extension also comes with a module (ext.graph.VisualEditor) which enables graph editing within VisualEditor.

This module was a result of a Google Summer of Code 2015 project. See T89287 for more details.

This module allows users to see graphs within VisualEditor, as opposed to alien extension nodes. Furthermore, users can open up a dialog to edit a graph's type, data and padding. The UI also offers a way to edit a graph's raw JSON specification within VE without having to switch to the classic wikitext editor, in case more advanced users want to tweak settings not supported by the UI.

This first step serves as a stepping stone for many possibilities with graph editing within VisualEditor, and there are a lot of ways in which the module can be improved and expanded.

Troubleshooting broken graphs
Errors with graphs will be logged in the developer console.

Error: Bad constructor arguments (T277906)
To fix: Replace filepath:Earthmap1000x500compac.jpg with filepath:Earthmap1000x500.jpg

Example.

TypeError: undefined is not an object (evaluating 'datum.firstYear.value')
To fix: Make sure you have not set default as null

Example.