Shorten outer labels on Radar graph using Chart.js - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

Shorten outer labels on Radar graph using Chart.js

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>chart.js 2.1</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.1.0/Chart.bundle.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/* w w w .  j  a v a 2s .  c o m*/
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
    labels: ["Really", "ReallyR", "Really Sleeping", "Really Designing", "Really Coding", "Really Cycling", "Really Running"],
    datasets: [
        {
            label: "My First dataset",
            backgroundColor: "rgba(179,181,198,0.2)",
            borderColor: "rgba(179,181,198,1)",
            pointBackgroundColor: "rgba(179,181,198,1)",
            pointBorderColor: "#fff",
            pointHoverBackgroundColor: "#fff",
            pointHoverBorderColor: "rgba(179,181,198,1)",
            data: [65, 59, 90, 81, 56, 55, 40]
        },
        {
            label: "My Second dataset",
            backgroundColor: "rgba(255,99,132,0.2)",
            borderColor: "rgba(255,99,132,1)",
            pointBackgroundColor: "rgba(255,99,132,1)",
            pointBorderColor: "#fff",
            pointHoverBackgroundColor: "#fff",
            pointHoverBorderColor: "rgba(255,99,132,1)",
            data: [28, 48, 40, 19, 96, 27, 100]
        }
    ]
};
var myRadarChart = new Chart(ctx, {
    type: 'radar',
    data: data,
    options: {
       scale: {
        pointLabels: {
          callback: function(pointLabel) {
            if (pointLabel.length > 6)
               return pointLabel.substring(0, 5) + '...';
            else
               return pointLabel
          }
        }
      }
    }
});
new Chart(ctx, config);
    }

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

Related Tutorials