Extension:Graph/Vega 2.0

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

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

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