Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

pygal: How to show the data labels in the saved png

If I include label as in the code snippet below, it shows the data labels when rendered as svg and mouse-hover. However, how do I make the labels show up in a saved png?

import pygal

chart = pygal.XY()
chart.add('line A', [{'value': (10, 2), 'label': 'A0'}, {'value': (15, 20), 'label': 'A1'}])

chart.render_to_file('chart.svg')  # this shows the labels on mouse hover
chart.render_to_png('chart.png')  # how do I make this to show the data labels?

Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the print_lables=True option when initializing your pygal graph for the labels to be displayed in the png:

chart = pygal.XY(print_labels=True)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading