Frage

I cannot figure out where to put the options in Chart.js on my bar graph. (I am not a programmer.)

Here is the code that I have:

<canvas id="canvasOne" height="450" width="450"></canvas>

<script>                    
    var barChartData = {
        labels: ["test "],
        datasets: [
        {
            fillColor: "#153b63",
            data: [61]
        },
        {
            fillColor: "#e99555",
            data: [25]
        }]                          
    }

    var myLine = new Chart(document.getElementById("canvasOne").getContext("2d")).Bar(barChartData);

</script>

All I want to do is hide the labels. The option to do this exists, and it's called scaleShowLabels: false, but I have no idea where to put it in the code. The documentation does not show this either.

War es hilfreich?

Lösung

You need to pass it as an option:

options = {
  scaleShowLabels : false
};

var barChartData = {
  labels : ["test "],
  datasets : [
  {
   fillColor : "#153b63",
   data : [61]
 },
 {
   fillColor : "#e99555",
   data : [25]
 }
 ]                           
};                
var myLine = new Chart(document.getElementById("canvasOne").getContext("2d")).Bar(barChartData, options);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top