Template:Mobility: Difference between revisions
No edit summary Tag: Reverted  | 
				No edit summary Tag: Reverted  | 
				||
| Line 1: | Line 1: | ||
<noinclude>  | <noinclude>  | ||
This template dynamically generates a   | This template dynamically generates a Mobility chart using data from DataSrc:T241.  | ||
Usage:   | Usage: Simply insert {{Mobility}} on a page.  | ||
[[Category:Mobility]]  | [[Category:Mobility]]  | ||
</noinclude>  | </noinclude>  | ||
<includeonly>  | <includeonly>  | ||
<!-- Step 1: Define an inline row formatter   | <!-- Step 1: Define an inline JSON row formatter -->  | ||
{{#vardefine: MobilityRowInline |  | {{#vardefine: MobilityRowInline |  | ||
<noinclude>Defines the JSON output for each row</noinclude>  | |||
<includeonly>{  | |||
   "mobility": "{{{type_of_mobility}}}",  |    "mobility": "{{{type_of_mobility}}}",  | ||
   "status": "{{{status_of_mobility_participant}}}",  |    "status": "{{{status_of_mobility_participant}}}",  | ||
   "participants": {{{participants|0}}}  |    "participants": {{{participants|0}}}  | ||
}</includeonly>  | |||
}}  | }}  | ||
<!-- Step 2: Query all rows from DataSrc:T241 and   | <!-- Step 2: Query all rows from DataSrc:T241 and store the raw JSON array -->  | ||
{{#vardefine:rawData|  | {{#vardefine:rawData|  | ||
   {{#ask:  |    {{#ask:  | ||
| Line 27: | Line 30: | ||
}}  | }}  | ||
<!-- Step 3: Render the chart using ECharts -->  | <!-- Step 3: Render the Mobility bar chart using ECharts -->  | ||
{{#echarts:  | {{#echarts:  | ||
| width=800px  | | width=800px  | ||
| Line 93: | Line 96: | ||
     ],  |      ],  | ||
     xAxis: {  |      xAxis: {  | ||
       type: 'category'  |        type: 'category',  | ||
      // Categories (the mobility types) are read from the dataset's "mobility" field.  | |||
     },  |      },  | ||
     yAxis: {  |      yAxis: {  | ||
Revision as of 10:49, 20 March 2025
This template dynamically generates a Mobility chart using data from DataSrc:T241. Usage: Simply insert
on a page.
}}
</includeonly>