[Chartjs]-Change Legend Box Outline Chart.js 2

17👍

To remove the stroke from legend, you need to set borderWidth property to 0 for your dataset, like so …

datasets: [{
   borderWidth: 0,
   ...
}]

ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ ⧩

var ctx = c.getContext('2d');
var chart = new Chart(ctx, {
   type: 'line',
   data: {
      labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
      datasets: [{
         label: 'Statistics',
         data: [3, 1, 2, 5, 4],
         backgroundColor: 'rgba(0, 119, 204, 0.1)',
         borderColor: 'rgba(0, 119, 204, 0.8)',
         borderWidth: 0 //<-- set this
      }]
   },
   options: {
      scales: {
         yAxes: [{
            ticks: {
               beginAtZero: true
            }
         }]
      }
   }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="c"></canvas>

Leave a comment