It is a small library that can load charts from highcharts on server side. After loading chart you can save it to file or embed it into your html page in base64 format.
from highcharts_loader import ChartLoader, Options
options = Options(from_file='options.json')
chart = ChartLoader(options)
# save to file
chart.save_to_file('result.png')
options.json example:
{
"chart": {
"type": "bar"
},
"title": {
"text": "Which channels are driving engagement?"
},
"xAxis": {
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
"series": [{
"data": [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
}
Result:
You can find more option params on highcharts official documentation page
pip install git+git://github.com/lionasp/highcharts-loader/@master
- Python (3.5, 3.6, 3.7)
For unlimited usage you should to run own server rather than relying on the public export.highcharts.com server which is rate limited. You can use solution from this repo
How to use:
-
Run export server with docker
- Without docker-compose (run next command in terminal for expose the service on port 8080):
docker run -d --name highcharts -p 8080:8080 onsdigital/highcharts-export-node
- With docker-compose (paste next command to docker-compose.yml file):
highcharts: image: onsdigital/highcharts-export-docker ports: - "8080"
-
Send url param to ChartLoader instance
chart = ChartLoader(options, url='http://localhost:8080')
- Add tests