From Dark and Darker Wiki

No edit summary
No edit summary
Line 1: Line 1:
<includeonly>
<includeonly>
<div>
<div>
   <canvas id="myChart"></canvas>
   <canvas id="<!--{$id|escape:'html'}-->"></canvas>
</div>
</div>


Line 7: Line 7:


<script>
<script>
   const ctx = document.getElementById('myChart');
    
 
  var data = JSON.parse('<!--{$data|escape:'quotes'}-->')
   new Chart(ctx, {
  var label = '<!--{$label|escape:'quotes'}-->';
     type: 'bar',
  var borderColor = '<!--{$borderColor|escape:'quotes'}-->';
  var backgroundColor = '<!--{$backgroundColor|escape:'quotes'}-->';
 
  if (colorData == "") {
    colorData = "black";
  }
  if (backgroundColorData == "") {
    backgroundColorData = "transparent";
  }
 
  var max = statsData[0]["x"];
  var min = max;
  for (let i = 0; i < statsData.length; i++) {
    if (statsData[i]["x"] > max) {
      max = statsData[i]["x"];
    }
    if (statsData[i]["x"] < min) {
      min = statsData[i]["x"];
    }
  }
 
  var range = [...Array(max - min + 1).keys()].map((x) => x + min);
 
   new Chart(document.getElementById('<!--{$id|escape:'html'}-->'), {
     type: "line",
    axisX: {
      gridColor: "orange",
    },
     data: {
     data: {
       labels: JSON.parse('<!--{$labels|escape:'quotes'}-->'),
       labels: range,
       datasets: [{
       datasets: [
        label: '# of Votes',
        {
        data: JSON.parse('<!--{$data|escape:'quotes'}-->'),
          data: data,
         borderWidth: 1
          label: label,
       }]
          borderColor: borderColor,
          backgroundColor: backgroundColor,
          fill: false,
         },
       ],
     },
     },
    options: {
      scales: {
        y: {
          beginAtZero: true
        }
      }
    }
   });
   });
 
 
 
 
</script>
</script>
</includeonly>
</includeonly>

Revision as of 05:34, 7 January 2023