Bar Chart
BarChartStrategy represents categorical data with rectangular bars whose heights are
proportional to the aggregated values. Bars may be vertical or horizontal.
Constructor
from orama.strategies.bar import BarChartStrategy
from orama.variables import Aggregation
from orama.enums import SortOrder
strategy = BarChartStrategy(
fields_metadata=fields_metadata,
category_variables=["region"], # list[str] — one or more categorical fields
aggregation=Aggregation(
name="count",
function="count",
field=None, # None for count-only aggregations
),
sort_by_value=SortOrder.DESCENDING, # SortOrder.NONE | ASCENDING | DESCENDING
horizontal=False, # bool — render bars horizontally
min_value=None, # float | None — axis lower bound
max_value=None, # float | None — axis upper bound
mean_category_name="", # str — add a mean bar with this label, or ""
mean_annotation=False, # bool — draw a mean line annotation
color_rules=None, # list[ColorRule] | None
title=None, # str | None — figure title
subtitle=None, # str | None — figure subtitle
caption=None, # str | None — figure caption (for <figcaption>)
description=None, # str | None — interpretive text (not in figure)
storytelling_context=None, # str | None — narrative goal / target audience
category_label=None, # str | None — X/Y axis label for the category
value_label=None, # str | None — X/Y axis label for the value
)
get_query_params() returns a single "main" key. When mean_category_name or
mean_annotation is set, a __total_count__ aggregation is added automatically.
Supported colors
Selectors: ColorSelectorStrategy, ColorSelectByCategoryName,
ColorSelectValuesBelow, ColorSelectValuesAbove, ColorSelectMaxValue,
ColorSelectMinValue, ColorSelectValuesBelowMean, ColorSelectValuesAboveMean.
Assigners: ColorAssignerByCategory, ColorAssignerByValue.