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

211
Visualizações
Django Pushing JSON formatted data to TimeLine Google Chart visual - converted date to New Date()

I've seen some posts about this but it's still unclear to me how to get this done. I have a Django application that queries a SQL database. I bring this data in and convert it from a pandas dataframe to a JSON format:

tempdata = json.dumps(d, cls=DjangoJSONEncoder)
        return render(request, 'notes/gantt.html', {'data': tempdata})

JSON looks like this:

[["id", "title", "created", "est_completion"], ["3", "Add new Security Group", "2022-04-25", "2022-05-05"]]

I tried to pass this into the google chart visual but I'm getting an error:

Invalid data table format: column #2 must be of type 'date,number,datetime'.

Its my understanding the date format is specific to google charts and needs to be set to new Date(2016, 11, 31)

My question is how can i do that? Is there a for loop I have to run? or is there an easier more straightforward way to do it?

        google.charts.load("current", {packages: ["timeline"]});
        google.charts.setOnLoadCallback(drawChart);
function drawChart() {
            var container = document.getElementById("timeline");
            var chart = new google.visualization.Timeline(container);
            var dataTable = google.visualization.arrayToDataTable({{ data|safe }});
            
            var options = {
                timeline: {showRowLabels: false},
                animation: {
                    startup: true,
                    duration: 1000,
                    easing: "in"
                },
                avoidOverlappingGridLines: true,
                backgroundColor: "#e8e7e7",
            };
            chart.draw(dataTable, options);

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