[Chartjs]-Generating a Chart.js chart with python data

2👍

What you are looking for is the json module. You can simply arrange your data in the correct form in python and write to a JSON that Chart.js can understand.

import json

data = {'label' : labels, 'datasets' : dataset}
with open('data.json', 'w') as f:
    json.dump(data, f)

This question is about how to get your JSON into Chart.js.

Leave a comment