Chart.js displays the label - Javascript Chart.js

Javascript examples for Chart.js:Chart Label

Description

Chart.js displays the label

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Chart.js change font family</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){// w w  w  .j  av  a2 s .c  o m
var canvas = document.getElementById('myChart');
var myBarChart = new Chart(canvas, {
  type: 'bar',
  data: {
    labels: ["Label 1", "Label 2", "Label 3"],
    datasets: [{
      label: "My Dataset",
      data: [15, 7, 12],
    }]
  },
  options: {
    scales: {
      xAxes: [{
        ticks: {
          fontFamily: 'Times New Roman'
        }
      }]
    },
    legend: {
      labels: {
        fontFamily: 'Times New Roman'
      }
    },
    title: {
      text: 'something',
      display: true,
      fontFamily: 'Times New Roman'
    },
  }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="myChart" width="100"></canvas>  
   </body>
</html>

Related Tutorials