Jump to content

Extension:Graph/Vega 2.0

From mediawiki.org

It is rarely a good idea to have a custom graph in an article. It is far better to use a common template like GraphChart, which will generate the graph for you.

Migration

[edit]

Vega 1.0 and 2.0 are not compatible, but usually do not require too many modifications to upgrade. Yet, multiple versions cannot peacefully coexist within the same browser session (at least not easily). This means that in the edit preview, if there are any 2.0 graphs on the page, you might not see the 1.0 graphs. At the same time, both graph versions will show when reading a page, because the rendering is done on the server.

To identify graph version, please add a "version" value at the top. Without it, the site default will be used. For now, it is 1, but once all graphs are marked with the version, we will switch it to 2.

<graph>
{
    "version": 2,
    ...
}
</graph>

Frequently Seen Migration Steps

[edit]

The GraphChart template based on Lua module was recently migrated with all these steps:

  • Add "version": 2 at the top of the graph
  • Remove the "data." prefix: replace all "data.variable" with "variable".
  • Replace "zip" transformation with "lookup", "stats" with "aggregate"
  • Fix field names generated by transformations, e.g. y → layout_start, y2 → layout_end, path → layout_path, sum → sum_variable
  • See complete list of changes