Page MenuHomePhabricator

Spike: expose {{#chart:}} invocation parameters (args) to Lua transforms
Closed, ResolvedPublic

Description

There are a lot of potential uses of data transforms that are opened up by allowing invocation-time arguments to be passed down to the Lua code.

Spike implementation tests this:

  • take arg:<key>=<value> pairs from the invocation and combine them with the args in the .chart JSON's transform.args map
    • simplest thing that can possibly work, plus a prefix to avoid config space collision
  • pass the combined arguments down to JCContentLoader which passes them into the local or remote script

Example:

<!-- Plot all population estimates for London ordered by point in time -->
{{#chart:Wikidata population by year|width=400|arg:entity=Q84|arg:sort=desc}}

where the underlying transform Lua code passes the "entity" and "sort" arguments down into wikibase functions. This wouldn't require creating a new .chart for each city or country any longer.

Recommending we separate the args from chart args to keep things clean.

  • we could prefix things to avoid namespace collisions
    • arg:<key>=<val> (current patch)
      • {{#chart:Wikidata population by year|width=400|arg:entity=Q84|arg:sort=desc}}
    • arg=<key>=<val>
      • {{#chart:Wikidata population by year|width=400|arg=entity=Q84|arg=sort=desc}}
  • or separate them
    • |args=
      • {{#chart:Wikidata population by year|width=400|args=entity=Q84|sort=desc}}
    • |args:
      • {{#chart:Wikidata population by year|width=400|args:entity=Q84|sort=desc}}
    • |args|
      • {{#chart:Wikidata population by year|width=400|args|entity=Q84|sort=desc}}

Event Timeline

bvibber triaged this task as High priority.May 29 2025, 7:32 PM
bvibber moved this task from Incoming to Doing on the Charts (Current Sprint) board.
bvibber updated the task description. (Show Details)

Change #1152157 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/Chart@master] Pass unrecognized chart options on to Lua transform

https://gerrit.wikimedia.org/r/1152157

I'm putting this to the Code Review column for Roan to look at on his return, at which point he may kick it back to me for further development. :)

Change #1152157 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Specify Lua transform arguments on {{#chart:}} invocations

https://gerrit.wikimedia.org/r/1152157

Change #1156454 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Specify Lua transform arguments on {{#chart:}} invocations

https://gerrit.wikimedia.org/r/1156454

Change #1156455 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.5] Specify Lua transform arguments on {{#chart:}} invocations

https://gerrit.wikimedia.org/r/1156455

Change #1156454 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Specify Lua transform arguments on {{#chart:}} invocations

https://gerrit.wikimedia.org/r/1156454

Change #1156455 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.5] Specify Lua transform arguments on {{#chart:}} invocations

https://gerrit.wikimedia.org/r/1156455

Mentioned in SAL (#wikimedia-operations) [2025-06-12T22:13:30Z] <bvibber@deploy1003> Started scap sync-world: Backport for [[gerrit:1156454|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]], [[gerrit:1156455|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]]

Mentioned in SAL (#wikimedia-operations) [2025-06-12T22:59:49Z] <bvibber@deploy1003> bvibber: Backport for [[gerrit:1156454|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]], [[gerrit:1156455|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-06-12T23:14:48Z] <bvibber@deploy1003> Finished scap sync-world: Backport for [[gerrit:1156454|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]], [[gerrit:1156455|Specify Lua transform arguments on {{Charts:}} invocations (T395610)]] (duration: 61m 18s)

bvibber moved this task from Code Review to Ready for Signoff on the Charts (Current Sprint) board.

Roan merged this, and I've backported and deployed it for further testing on beta and test servers in the next few days.

This is now available for testing on commonswiki, test2wiki, and mediawikiwiki.

Dropping a few sample/test pages on https://commons.wikimedia.org/wiki/Category:Charts_extension_documentation including the Lua module with the TabUtils 'select' function and a test chart using it

Tomastvivlaren renamed this task from Spike: expose {{#chart:}} invocation parameters to Lua transforms to Spike: expose {{#chart:}} invocation parameters (args) to Lua transforms.Jun 18 2025, 6:56 AM