Chart.js? In particular, the radar chart and negative numbers

I am new to JavaScript using radar chart from chart.js but every time I put a negative number in the chart data I always get a warped image.

the code is here:

var radarChartData = {
        labels: [
                  "Soccer",
                  "Basketball",
                  "Swimming",
                  "Volleyball",
                  "Computer games",
                  "Tennis",  
                ],
        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: [-3,7,6,6,4,6]
            },

        ]
    };


    window.onload = function(){
        window.myRadar = new Chart(document.getElementById("canvas").getContext("2d")).Radar(radarChartData,                          
        { 
            responsive: true
        });
    }

      

+3


source to share


1 answer


1 /, to change the real value to an integer, you can use:

var intvalue = Math.floor( floatvalue );
var intvalue = Math.ceil( floatvalue ); 
var intvalue = Math.round( floatvalue );

      



2 / for warped image: try Math.abs(val);

0


source







All Articles