Widget:Chartjs pie: Difference between revisions

From Visual Data Wiki
Jump to navigation Jump to search
No edit summary
Tags: Reverted 2017 source edit
No edit summary
Tags: Reverted 2017 source edit
Line 37: Line 37:
     let dataSeries = makeItemsArray('<!--{$data_series|default:''}-->');
     let dataSeries = makeItemsArray('<!--{$data_series|default:''}-->');
     let title = '<!--{$title|default:''}-->';
     let title = '<!--{$title|default:''}-->';
    let legend = '<!--{$legend|default:'yes'}-->';


     dataIdentifier = dataIdentifier.trim();
     dataIdentifier = dataIdentifier.trim();
     title = title.trim();
     title = title.trim();


    if (legend === 'no') {
     function drawPieChart(ctx, labels, dataIdentifier, colors, dataSeries, title) {
        legend = false;
    } else {
        legend = true;
    }
 
     function drawPieChart(ctx, labels, dataIdentifier, colors, dataSeries, legend, title) {
       //console.log('ctx: ' + ctx);
       //console.log('ctx: ' + ctx);
       //console.log('labels: ' + labels);
       //console.log('labels: ' + labels);
Line 55: Line 48:
       //console.log('dataSeries: ' + dataSeries);
       //console.log('dataSeries: ' + dataSeries);
       //console.log('title: ' + title);
       //console.log('title: ' + title);
      console.log('legend: ' + legend);
       new Chart(ctx, {
       new Chart(ctx, {
         type: 'pie',
         type: 'pie',
Line 67: Line 59:
         },
         },
         options: {
         options: {
           legend: { display: true },
           legend: { display: legend },
           title: {
           title: {
             display: true,
             display: true,
Line 76: Line 68:
     }
     }


     window.drawPieChart = drawPieChart(ctx, labels, dataIdentifier, colors, dataSeries, legend, title);
     window.drawPieChart = drawPieChart(ctx, labels, dataIdentifier, colors, dataSeries, title);


   });
   });

Revision as of 10:17, 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.