Value configuration

How

Values are customized by replacing the value with a dictionary containing the value as ‘value’:

chart = pygal.Line()
chart.add([1, {'value': 2, 'label': 'two'}, 3])
chart.add([3, 2, 1])

Labels

You can add per value metadata like labels, by specifying a dictionary instead of a value:

chart = pygal.Bar()
chart.add('First', [{'value': 2, 'label': 'This is the first'}])
chart.add('Second', [{'value': 4, 'label': 'This is the second'}])
chart.add('Third', 7)
chart.add('Fourth', [{'value': 5}])
chart.add('Fifth', [{'value': 3, 'label': 'This is the fifth'}])
chart.render()

Style

You can force the color of a value by specifying a color key:

chart = pygal.Bar()
chart.add('Serie', [
 {'value': 2}, 3, 4,
 {'value': 10, 'color': 'red'},
 {'value': 11, 'color': 'rgba(255, 45, 20, .6)'}, 4, 2
])
chart.render()

The color key set the fill and the stroke style. You can also set the css style manually:

chart = pygal.Bar()
chart.add('Serie', [
 {'value': 2}, 3, 4,
 {'value': 10, 'style': 'fill: red; stroke: black; stroke-width: 4'},
 {'value': 11, 'style': 'fill: rgba(255, 45, 20, .6); stroke: black; stroke-dasharray: 15, 10, 5, 10, 15'},
 4, 2
])
chart.render()

Node attributes

It is possible to pass svg attribute to the node representing value.

chart = pygal.Line()
chart.add('Serie', [
  {'value': 1, 'node': {'r': 2}},
  {'value': 2, 'node': {'r': 4}},
  {'value': 3, 'node': {'r': 6}},
  {'value': 4, 'node': {'r': 8}}
])
chart.render()