Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
¿Alguien puede ayudarme a pasar listas de python a Chart.js?

Hola chicos, estoy trabajando en un proyecto que necesita un gráfico. Decidí usar el marco Flask y vi a mucha gente en línea usando Chart.js. Sin embargo, creo que puede haber un problema al pasar los valores de python al archivo html con javascript. Podría estar equivocado, pero creo que es un problema con la plantilla jinja o cómo la estoy usando.

¿Alguien puede ayudar? Gracias por adelantado

Parte del archivo de Python

 @app.route('/data') def data(): legend = 'Monthly Data' labels = ["January", "February", "March", "April", "May", "June", "July", "August"] values = [10, 9, 8, 7, 6, 4, 7, 8] return render_template('graph.html', values=values, labels=labels, legend=legend)

HTML

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"></script> </head> <body> <canvas id="lineChart" width="900" height="400"></canvas> <script> var ctx = document.getElementById("lineChart").getContext("2D"); var lineChart = new Chart(ctx, { type: "line", data: { labels: '{{ labels | safe }}', datasets : [ { label: "Data points", data: '{{values | safe }}', fill: false, borderColor: "rgb(75, 192, 192)", lineTension: 0.1 } ] }, options: { responsive: false } }); </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!