0

Sorry for my english. I'm brazilian. I need remove legends of bar grafic on chartJS 2.8.0.

This is my code:

        <div style="height:250px; width:520px;">
            <canvas id="myChartBar"></canvas>
        </div>
        <script type="text/javascript">
            var ctx = document.getElementById('myChartBar');
            var myChart = new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['<?php echo implode("','", $resultadoSaldo["label"]) ?>'],
                    datasets: [{
                        label: '# of Votes',
                        data: [<?php echo implode(',', $resultadoSaldo['value'])?>],
                        backgroundColor: ['<?php echo implode("','", $resultadoSaldo["color"]) ?>'],
                        borderColor: ['<?php echo implode("','", $resultadoSaldo["color"]) ?>'],
                        borderWidth: 3
                    }]
                },
                options: {
                    responsive: true,
                    legend: {
                        display: false
                    },
                    scales: {
                        yAxes: [{
                            ticks: {
                                beginAtZero: true
                            }
                        }]
                    }
                }
            });
        </script> 

I think the code would work: legend: { display: false },

But so is my grafh:

enter image description here

I need remove this:

enter image description here

Andreas
  • 21,535
  • 7
  • 47
  • 56

1 Answers1

0

Those labels aren't the legend, they are the X Axis labels. Try this:

options: {
    scales: {
        xAxes: [{
            ticks: {
                display: false
            }
        }]
    }
}
whatscool
  • 317
  • 2
  • 18