GeomBar

Bar geometry with counting or binning: one rectangle per distinct x value (stat count, discrete x) or per bin (stat bin, continuous x). Do not map aes.y — the stat computes it. Prefer GeomCol when bar heights are already in the data.

Defaults

geom
bar
default stat
count
default position
stack
params type
BarParams

Svelte component

import { GGPlot, GeomBar } from "@ggsvelte/svelte";

<GGPlot data={rows} aes={{ x: "x" }}>
  <GeomBar />
</GGPlot>

JSON layer

{
  "geom": "bar",
  "stat": "count"
}

Params

alpha

number

Bar opacity. Must be between 0 and 1 (inclusive). Default 1.

width

number

Bar width as a fraction of the band step (count-stat bars only; binned bars span their bin). Must be greater than 0 and at most 1. Default 0.9.

bins

number

STAT BIN ONLY: number of bins (an integer of at least 1). Default 30 — an advisory reminds you to pick a real value. Overridden by binwidth.

binwidth

number

STAT BIN ONLY: bin width in data units (must be greater than 0). Takes precedence over bins. Usually the better knob: pick a width meaningful for the data.

boundary

number

STAT BIN ONLY: align a bin EDGE with this x value (e.g. 0 puts bin edges at multiples of the width). Mutually exclusive with center.

center

number

STAT BIN ONLY: align a bin CENTER with this x value. Mutually exclusive with boundary.

closed

"right" | "left"

STAT BIN ONLY: which edge of each bin is inclusive: "right" (default, matches) or "left".

fillPaint

GradientPaint

Within-mark gradient fill paint (not a data scale). Requires a solid fallback.

glow

GlowSpec

Bounded within-mark glow treatment (not theme decoration).

Allowed stats

Allowed positions

Examples

← All geoms · Getting started