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

0👍

Just scale the values and then divide by the scaling factor before you show the respective tooltip

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)];
    }
});

Fiddle – http://jsfiddle.net/cq1q5wuf/

Leave a comment