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

81 Views Asked by At

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!

1

There are 1 best solutions below

0
Marcelo Paco On BEST ANSWER

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)