Set max value for each label with Chart.js - Javascript Chart.js

Javascript examples for Chart.js:Chart Data

Description

Set max value for each label with Chart.js

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>line chart with ChartJS</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://rawgit.com/nnnick/Chart.js/v1.0.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*  w  w w. j  av  a 2 s  .  c  o  m*/
    var scaling = [10, 10, 10, 1, 1, 1, 1];
    var data = {
        labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
        datasets: [
            {
                label: "My First dataset",
                fillColor: "rgba(220,220,220,0.2)",
                strokeColor: "rgba(220,220,220,1)",
                pointColor: "rgba(220,220,220,1)",
                pointStrokeColor: "#fff",
                pointHighlightFill: "#fff",
                pointHighlightStroke: "rgba(220,220,220,1)",
                data: [5, 5, 9, 81, 56, 55, 40].map(function (e, i) {
                    return e * scaling[i];
                })
            }
        ]
    };
    var ctx = document.getElementById("myChart").getContext("2d");
    var myRadarChart = new Chart(ctx).Radar(data, {
        tooltipTemplate: function (valueObject) {
            return valueObject.value / scaling[data.labels.indexOf(valueObject.label)];
        }
    });
    }

      </script> 
   </head> 
   <body> 
      <canvas id="myChart" height="300" width="800"></canvas>  
   </body>
</html>

Related Tutorials