Ao clicar na legenda de um gráfico de coluna os valores não somem.
05/09/2018 13:08
0
Tenho um gráfico de colunas,seria normal clicar na legenda e a coluna sumir e os número também, só que quando clico na legenda a coluna some mas os valores não.

Segue o código que uso para fazer isso.

function ChartQuantMes() {

    StatusMesGT.length = 0;
    StatusMesG.length = 0;
    CarregarQuantMes();

    var chttT = document.getElementById("myChartQuantMes");
    var ctx100 = chttT.getContext("2d");

    window.myChartQuantMes = new Chart(ctx100, {
        type: 'bar',
        data: {
            labels: ['JAN', 'FEV', 'MAR', 'ABR', 'MAI', 'JUN', 'JUL', 'AGO', 'SET', 'OUT', 'NOV', 'DEZ'],
            datasets: [
                {
                    label: 'Etiqueta',
                    data: StatusMesG,
                    backgroundColor: '#1E90FF',
                    
                },
                {
                    label: 'Cartão',
                    data: StatusMesGT,
                    backgroundColor: '#ADD8E6',
                    
                }],
        },

        options: {

            plugins: {
                datalabels: {
                    anchor: function (context) {
                        var value = context.dataset.data[context.dataIndex];
                        return value > 1 ? 'end' : 'end';
                    },
                    align: function (context) {
                        if (context.dataset.label == "Etiqueta") {
                            var value = context.dataset.data[context.dataIndex];
                            return value > 1 ? 'end' : 'end';
                        } else {
                            var value = context.dataset.data[context.dataIndex];
                            return value > 1 ? 'end' : 'end';
                        }
                    },
                    color: function (context) {
                        var value = context.dataset.data[context.dataIndex];
                        return value.v < 50 ? context.dataset.backgroundColor : 'black';
                    },
                    font: function (context) {
                        var width = context.dataset.data;
                        return { size: 18 };
                    },

                },
            },
            responsive: true,
            title: {
                display: true,
                text: "Quantidade Mensal de Etiquetas / Cartão - Depto " + $('#Depto').val(),
                lineHeight: '5',
                fontSize: 20,
            },

            responsive: true,

            legend: {
                display: true,
                position: 'bottom'
            },

            scaleShowHorizintalLines: false,

            scales: {
                xAxes: [{
                    stacked: false,

                    display: true,
                }],

                yAxes: [{
                    stacked: false,
                    ticks: {
                        beginAtZero: false,
                        bounds: false,
                        display: false,
                        mirror: true,
                        max: MatrizC1 + 10,
                    },

                    gridLines: {
                        display: false,
                    },

                }]
            },

        }

    });

}?
Tags: javascript


Ainda não faz parte da comunidade???

Para se registrar, clique aqui.