Bar chart
In addition to all of the standard parameters the following apply to bar charts.
Parameters
- data
List[dict], DataFrame, Series Contains inline data to use for the chart. In Markdown, the value must be a JSON string representing a list of dictionaries, as shown in the example below. Each dictionary must contain a
labelelement, with the label for the respective bar, and avalueelement, representing the height of the bar (which will be scaled appropriately).In Python,
datamay be any of:- A Python list of dictionaries, as above
- A Pandas, FireDucks, Polars or pyarrow DataFrame with a
labelandvaluecolumn. - A Series whose index supplies the labels and entries supply the value.
- horizontal
Boolean If true, the bars are drawn horizontally instead of vertically. Defaults to False.
- moving_average
Boolean If true, a moving average curve is added to the graph. Default is False.
- x_label_angle
Number (degrees) Specifies the number of degrees clockwise that the X axis labels should be turned. This is to handle long labels. The default value is 0 (no rotation).
Examples
Bar charts are drawn using the barchart tag, like this:
<barchart
data='[
{ "label": "Apples", "value": 10 },
{ "label": "Bananas", "value": 20 },
{ "label": "Cherries", "value": 15 },
{ "label": "Grapes", "value": 25 }
]'
width="500"
height="350"
colors='["DarkOrange"]'
>
</barchart>which is rendered like this:
The data is provided as a JSON string containing a list of dictionaries, each of which has a label and value entry. The label value is used for a label for the bar, and is also the content of the tooltip that pops up when you hover over the bar.