Widget:Chartjs pie: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: 2017 source edit |
No edit summary Tags: Reverted 2017 source edit |
||
Line 10: | Line 10: | ||
</noinclude> | </noinclude> | ||
<includeonly> | <includeonly> | ||
<!--{counter name=" | <!--{counter name="counterDonut" assign="countDonut"}--> | ||
<!--{math equation='rand(0,1000)' assign="randomValue"}--> | <!--{math equation='rand(0,1000)' assign="randomValue"}--> | ||
<!--{assign var=time value=time()}--> | <!--{assign var=time value=time()}--> | ||
<!--{$ID = "donut-$ | <!--{$ID = "donut-$countDonut-$time-$randomValue"}--> | ||
<div> | <div> | ||
Line 24: | Line 24: | ||
const ctx = document.getElementById('<!--{$ID|escape:'html'}-->'); | const ctx = document.getElementById('<!--{$ID|escape:'html'}-->'); | ||
function makeItemArray( | function makeItemArray(items) { | ||
var itemList = items.split(","); | |||
for (var i = 0; i< | for (var i = 0; i< itemList.length; i++) { | ||
itemList[i] = itemList[i].trim(); | |||
} | } | ||
return | return itemList; | ||
} | } | ||
var labels = makeItemArray('<!--{$data_labels|default:''}-->'); | |||
var colors = makeItemArray('<!--{$colors|default:''}-->'); | |||
new Chart(ctx, { | |||
type: 'pie', | type: 'pie', | ||
data: { | data: { | ||
labels: labels, | labels: labels, | ||
datasets: [{ | datasets: [{ | ||
label: | label: "<!--{$data_identifier|default:''}-->", | ||
backgroundColor: colors, | backgroundColor: colors, | ||
data: [ | data: [<!--{$data_series|default:''}-->] | ||
}] | }] | ||
}, | }, | ||
Line 60: | Line 48: | ||
title: { | title: { | ||
display: true, | display: true, | ||
text: title | text: '<!--{$title|default:''}-->' | ||
} | } | ||
} | } | ||
}); | |||
}); | }); |
Revision as of 08:33, 19 March 2024
This widget allows you to add ... widget to your wiki page.
Created by [idea-sketch.com idea-sketch.com]
Using this widget[edit source]
For information on how to use this widget, see ...
Copy to your site[edit source]
To use this widget on your site, just install MediaWiki Widgets extension and copy the full source code of this page to your wiki as page Widget:Chartjs pie.