I have a StackedBar chart created using pygal see below:
And I would like to add labels to each of the stacked bars a bit like those from the documentation for Bar charts (see below .. from the pygal documentation). The method of adding these labels described in the documentation for Bar charts does not seem to work for StackedBar charts.
What I'm trying to get is the numeric values printed on the graph bars.
Pass the print_values
argument when creating your StackedBar
object. For example, the following code creates the chart shown below:
import pygal
chart = pygal.StackedBar(print_values=True)
chart.add("Series A", [None, None, 40, 20, 10])
chart.add("Series B", [80, 60, 40, 40, 30])
chart.add("Series C", [20, 40, 20, 40, 60])
chart.render()
The different parameters that can be used when creating chart objects are listed in the chart configuration section of the docs.