Generating charts from Python lists and dictionaries in Django with Chartkick application.
We start with the usuwall pypi installation:
W settingsach Django dodajemy:
Now we have to add some JS files in our templates. We have to pick which chart backend we want to use - Google Charts or Highcharts (you can change that any time). For Google Charts add:For Highcharts:
You can check few examples on github. To get such result you will have to pass data to the template (as dictionary or as list) and use template tag provided by Chartkick. Here is an example:In a Django view the data and line_data must be passed to the template. Those variables could be something like this:
For a line chart by default the X axis is interpreted as date/time not as numbers. You can find line charts with multiple lines on the github example page, but thats almost all what Chartkick can offer. If you don't need very complex charts this application may be handy.