Skip to content
Advertisement

How to pass a dictionary to ChartJS?

I’m trying to pass a dictionary from my Flask file to my ChartJS but the data doesn’t load on my chart. I think there’s a problem on passing my data. Here is the format of my dictionary. Basically, it’s a time series dataframe I converted as dict.

JavaScript

Here is my flask file:

JavaScript

Here is my HTML file

JavaScript

Advertisement

Answer

I solved it, what I did was to converted my result to list intead of dataframe and created a list of tuples, then passed it on my jinja file.

Here’s my python file:

JavaScript

And my controller:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement