Bullet chart — progress toward target with colored range bands — pure SVG, zero JS.
Renders qualitative background ranges, a bar for the actual value, and a line marker for the target. Bars animate in on entrance.
Examples
<.bullet_chart
value={72}
target={85}
ranges={[%{to: 50, color: "oklch(0.80 0.05 0)"}, %{to: 75, color: "oklch(0.88 0.03 0)"}, %{to: 100, color: "oklch(0.94 0.02 0)"}]}
label="Revenue"
/>
<.bullet_chart value={340} target={400} ranges={[%{to: 200}, %{to: 350}, %{to: 500}]} />
Summary
Functions
Attributes
value(:any) (required) - Actual value to display (integer or float).target(:any) (required) - Target value (shown as a line marker).max(:any) - Maximum scale value. Defaults tomax(target * 1.2, value). Defaults tonil.ranges(:list) - Background quality ranges:[%{to: number, color: string}]. Each range covers from the previous:toto this:to.Defaults to
[].label(:string) - Label shown to the left. Defaults tonil.animate(:boolean) - Defaults totrue.animation_duration(:integer) - Defaults to700.id(:string) - Unique ID for the chart (auto-generated if not provided). Defaults tonil.title(:string) - Chart title rendered above the visualization. Defaults tonil.description(:string) - Chart description for context (rendered below title). Defaults tonil.class(:string) - Defaults tonil.Global attributes are accepted.