Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
Unable to set multiple color for google bar char

I have the following code where I am able to load the graph from the database, but I am trying to apply multiple colors which is not working

function drawStatuChart() {
show('loading3', true);
var data = JSON.stringify({
    'GraphId': 5,
    'startDt': $("#from-date").val(),
    'endDt': $("#to-date").val()
});
$.ajax({
    type: "POST",
    url: url,
    data: data,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (r) {
        var data = new google.visualization.DataTable();
        var cols = r.splice(0, 1);
        cols[0].forEach(function (col, index) {
            if (index === 0) {
                data.addColumn('string', col);
            } else {
                data.addColumn('number', col);
            }
        });
        if (r.length > 0) {
            data.addRows(r);
        } else {
            data.addRow(['', null]);
        }
        show('loading3', false);
        var view = new google.visualization.DataView(data);
        view.setColumns([0, 1,
            {
                calc: "stringify",
                sourceColumn: 1,
                type: "string",
                role: "annotation",
            }
        ]);

        var options = {
            width: '350',
            height: '300',
            'overflow': 'hidden',
             bar: { groupWidth: "65%" },
            legend: { position: "none" },
            colors: ['#f8aa00', '#00778d'],
            fontName: 'Montserrat',
            chartArea: {
                left: "17%",
                top: "2%",
                height: "250",
                width: "250"
            }
        };

        var chart = new google.visualization.BarChart($("#status")[0]);
        chart.draw(view, options);
    },
    failure: function (r) {
        alert(r.d);
    },
    error: function (r) {
        alert(r.d);
    }
});

}

I get the following data from db, but some how I am not able to apply different colors

enter image description here

Showing only one color

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda