Indicators¶
Indicators display a single KPI scalar — optionally with a comparison delta and a
graphical fill element. They are parallel to figure strategies: a strategy class
accepts fields_metadata, aggregations, and rendering options; build() returns an
IndicatorView containing rendered HTML.
from orama.indicators.text import TextIndicatorStrategy
from orama.variables import Aggregation
strategy = TextIndicatorStrategy(
fields_metadata=fields_metadata,
current_aggregation=Aggregation(name="revenue", function="sum", field="amount"),
comparison_aggregation=Aggregation(name="prev_revenue", function="sum", field="amount"),
delta_is_relative=True,
title="Revenue",
)
view = strategy.build(dfs={"current": df_current, "comparison": df_prev}, tr=tr, theme=theme)
# view.html — rendered HTML string
get_query_params() returns the aggregation query parameters. The "current" key is
always present; "comparison" is only present when comparison_aggregation is set.



New to indicators?
Step 7 of the tutorial builds one from scratch.
Common parameters¶
All four indicator strategies share these base parameters:
IndicatorStrategy(
fields_metadata=fields_metadata, # dict[str, FieldMetadata]
current_aggregation=Aggregation(...), # primary KPI
comparison_aggregation=None, # Aggregation | None — enables delta
delta_is_relative=False, # bool — show delta as % of comparison
delta_position=DeltaPosition.BOTTOM, # DeltaPosition or "top" / "bottom" / "right"
current_font_size=None, # float | None — px; None → theme indicator_value
delta_font_size=None, # float | None — px; None → theme indicator_delta
title=None, # str | None
subtitle=None, # str | None
caption=None, # str | None
description=None, # str | None
storytelling_context=None, # str | None
current_color_rules=None, # list[ColorRule] | None
delta_color_rules=None, # list[ColorRule] | None
pre_build_callback=None, # Callable[[dict], None] | None
post_build_callback=None, # Callable[[dict], None] | None
indicator_id=None, # str | None — stable id for the SVG masks; random if omitted
)
Deterministic HTML
Circle and arc indicators draw with SVG masks whose ids must be unique on the page, so every render gets a random
one. Pass indicator_id="revenue-kpi" when you need identical output between runs (tests, caches, snapshots).
Use a different id for each indicator on the same page.
Unit auto-detection¶
If the aggregation field's FieldMetadata carries a "unit" key in its extra dict,
the unit string is automatically picked up and rendered as a separate
<span class="unit"> element next to the value:
from fields_metadata import FieldMetadata
fields_metadata = {
"amount": FieldMetadata(name="Amount", extra={"unit": "EUR"}),
}
The unit appears after both the current value and, when present, the delta value.
Text Indicator¶
TextIndicatorStrategy renders only styled text — no graphical element.
from orama.indicators.text import TextIndicatorStrategy
strategy = TextIndicatorStrategy(
fields_metadata=fields_metadata,
current_aggregation=Aggregation(name="score", function="avg", field="score"),
comparison_aggregation=Aggregation(name="prev_score", function="avg", field="score"),
delta_is_relative=False,
delta_position="bottom", # "top" | "bottom" | "right"
title="Average Score",
)
No additional parameters beyond the common base.
Bar Indicator¶
BarIndicatorStrategy renders a rectangular progress bar alongside the text block.
from orama.indicators.bar import BarIndicatorStrategy
from orama.indicators.enums import BarPosition, BarRepresents, GraphicalFillMode
strategy = BarIndicatorStrategy(
fields_metadata=fields_metadata,
current_aggregation=Aggregation(name="progress", function="sum", field="completed"),
domain_min=0.0, # float — bar left/bottom boundary
domain_max=100.0, # float — bar right/top boundary
bar_position=BarPosition.BELOW, # BELOW | LEFT | RIGHT
bar_represents=BarRepresents.CURRENT_VALUE, # CURRENT_VALUE | DELTA
graphical_fill_mode=GraphicalFillMode.GRADIENT, # GRADIENT | FLAT
bar_color="indicator_domain_track_color", # theme color name or "#hex" for the track
linecap="round", # "round" | "butt"
graphical_color_rules=None, # list[ColorRule] | None
current_font_size=48.0,
delta_font_size=24.0,
title="Completion",
)
bar_position controls layout:
| Value | Layout |
|---|---|
BarPosition.BELOW |
Horizontal bar below the text block |
BarPosition.LEFT |
Vertical bar on the left, text on the right |
BarPosition.RIGHT |
Text on the left, vertical bar on the right |
When bar_represents=BarRepresents.DELTA the fill grows from the bar midpoint outward
and a centre-tick marker is drawn; comparison_aggregation must be provided.
Circle Indicator¶
CircleIndicatorStrategy renders a full-circle arc that fills clockwise from the top.
from orama.indicators.circle import CircleIndicatorStrategy
from orama.indicators.enums import CircleTextPosition, GraphicalFillMode
strategy = CircleIndicatorStrategy(
fields_metadata=fields_metadata,
current_aggregation=Aggregation(name="utilisation", function="avg", field="cpu"),
domain_min=0.0,
domain_max=100.0,
text_position=CircleTextPosition.CENTER, # CENTER | SIDE
inside_delta_position="bottom", # "top" | "bottom" — only for CENTER
graphical_fill_mode=GraphicalFillMode.GRADIENT,
bar_color="indicator_domain_track_color",
linecap="round",
graphical_color_rules=None,
current_font_size=48.0,
delta_font_size=24.0,
title="CPU Utilisation",
)
text_position=CircleTextPosition.CENTER overlays the text inside the circle ring.
CircleTextPosition.SIDE places the circle to the left and text to the right.
Arc Indicator¶
ArcIndicatorStrategy renders an open arc (270° or 180°) that fills from one end.
from orama.indicators.arc import ArcIndicatorStrategy
from orama.indicators.enums import ArcDegrees, ArcTextPosition, ArcRepresents, GraphicalFillMode
strategy = ArcIndicatorStrategy(
fields_metadata=fields_metadata,
current_aggregation=Aggregation(name="nps", function="avg", field="score"),
domain_min=0.0,
domain_max=100.0,
arc_degrees=ArcDegrees.DEG_270, # DEG_270 | DEG_180
text_position=ArcTextPosition.CENTER, # CENTER | SIDE
arc_represents=ArcRepresents.CURRENT_VALUE, # CURRENT_VALUE | DELTA
inside_delta_position="bottom", # "top" | "bottom" — only for CENTER
graphical_fill_mode=GraphicalFillMode.GRADIENT,
bar_color="indicator_domain_track_color",
linecap="round",
graphical_color_rules=None,
current_font_size=48.0,
delta_font_size=24.0,
title="NPS",
)
ArcDegrees.DEG_270 leaves a gap at the bottom (gauge style).
ArcDegrees.DEG_180 is a horizontal semicircle.
When arc_represents=ArcRepresents.DELTA a centre-tick marks the midpoint.
Styling with CSS custom properties¶
Everything visual is exposed as a --orama-indicator-* custom property. Each one falls back to the value computed at
build time from your theme, so you set only what you want to change, from a stylesheet, a theme switch or a media
query, without rebuilding the indicator.


| Variable | Applies to | Controls |
|---|---|---|
--orama-indicator-value-color |
all | Color of the current value (overrides color rules) |
--orama-indicator-delta-color |
all with a comparison | Color of the delta (overrides color rules) |
--orama-indicator-value-font-size |
all | Size of the current value |
--orama-indicator-delta-font-size |
all | Size of the delta |
--orama-indicator-title-color / -subtitle-color |
all | Title and subtitle colors |
--orama-indicator-title-font-size / -subtitle-font-size |
all | Title and subtitle sizes |
--orama-indicator-gap |
bar, circle, arc | Space between the graphic and the text |
--orama-indicator-thickness |
bar, circle, arc | Thickness of the bar or ring |
--orama-indicator-radius |
circle, arc | Radius of the ring |
--orama-indicator-track-color |
bar, circle, arc | The unfilled track |
--orama-indicator-fill-color |
bar, circle, arc | The filled part, when it is a flat color |
--orama-background |
all | Background of the indicator's <figure> |
Gradient fills
--orama-indicator-fill-color only replaces a flat fill. When the fill is a gradient (the default with
ColorAssignerByValue rules and graphical_fill_mode=GRADIENT), its stops come from the rules. Set
graphical_fill_mode=GraphicalFillMode.FLAT if you want the variable to apply.
The ring is sized to its text
With text_position="center", the radius is chosen so that the whole text block (the value, its unit and the
delta) fits inside the ring, however long it is: 7 EUR gets a small ring and 33.17M EUR a bigger one. The
size is computed when the indicator is built, from the font sizes and an estimate of the text width.
CSS can change things after that. If you override --orama-indicator-radius or a font size with the text
inside the ring, check that the value still fits.
Variables from your theme¶
Theme.to_css_variables() produces the --orama-* color variables for your theme, plus the theme-driven indicator
hooks (--orama-indicator-track-color, -title-color, -subtitle-color). Scope them per color scheme and the same
HTML follows a light/dark switch with no rebuild:
css = f"""
:root, [data-theme="light"] {{ {light_theme.to_css_variables()} }}
[data-theme="dark"] {{ {dark_theme.to_css_variables()} }}
"""
Why not value and delta colors too?
They come from your color rules (red for a drop, green for a rise). A global variable would override those, so
they are left to you: set --orama-indicator-value-color where you want a uniform color.
Styling with classes¶
Classes address elements the variables do not cover:
/* Example: make units smaller and de-emphasised */
.orama-indicator .unit {
font-size: 0.65em;
opacity: 0.6;
}
/* Example: capitalise all titles */
.orama-indicator .title {
text-transform: uppercase;
letter-spacing: 0.05em;
}
Class reference¶
| Class | Element | Present when |
|---|---|---|
orama-indicator |
<figure> outer container |
Always |
title |
<p> |
title is set |
subtitle |
<p> |
subtitle is set |
values |
<div> value/delta layout container |
Always |
delta-bottom |
modifier on .values |
delta_position="bottom" (default) |
delta-top |
modifier on .values |
delta_position="top" |
delta-right |
modifier on .values |
delta_position="right" |
current |
<span> wrapping the value |
Always |
delta |
<span> wrapping the delta |
Comparison value is provided |
current-value |
<span> inside .current |
Always |
delta-value |
<span> inside .delta |
Comparison value is provided |
unit |
<span> inside .current-value / .delta-value |
Unit is detected from field metadata |
arc-indicator |
<div> |
ArcIndicatorStrategy |
arc-indicator-text-inside |
<div> |
text_position=CENTER |
arc-indicator-text-side |
<div> |
text_position=SIDE |
bar-indicator |
<div> |
BarIndicatorStrategy |
bar-indicator-text-above |
<div> |
bar_position=BELOW (text above horizontal bar) |
bar-indicator-text-right |
<div> |
bar_position=LEFT (bar on left, text on right) |
bar-indicator-text-left |
<div> |
bar_position=RIGHT (text on left, bar on right) |
circle-indicator |
<div> |
CircleIndicatorStrategy |
circle-indicator-text-inside |
<div> |
text_position=CENTER |
circle-indicator-text-side |
<div> |
text_position=SIDE |
Theme fonts¶
Two indicator-specific font slots are registered automatically on every Theme:
| Slot | Kind | Default derivation |
|---|---|---|
indicator_value |
computed | Based on _indicator_base_size |
indicator_delta |
computed | Smaller than indicator_value |
Override the base size by passing _indicator_base_size in the fonts dict:
from orama.theme import Font, Theme
theme = Theme(
colors={...},
fonts={
"_indicator_base_size": Font('"Open Sans", sans-serif', 52.0, 700, False),
},
)
Retrieve a font with theme.get_font("indicator_value").
Color rules¶
All indicator strategies accept current_color_rules and delta_color_rules to
colour the text values. Graphical strategies additionally accept
graphical_color_rules for the fill element.
Supported selectors: ColorSelectorStrategy, ColorSelectValuesBelow,
ColorSelectValuesAbove.
Supported assigners: ColorAssignerByValue.
The last matching rule wins. When graphical_fill_mode=GraphicalFillMode.GRADIENT
and at least one graphical rule uses ColorAssignerByValue, the fill is rendered as
a continuous color gradient across the domain.