<!-- coverage-seen-elsewhere:
  markers -> markers.md
  price_lines -> price-lines.md
  marker_spec -> markers.md
  on_press -> events.md
  on_double_press -> events.md
  auto_bin -> autobin.md
  bin_width -> autobin.md
  bin_count -> autobin.md
  crosshair_mode -> styling.md
  time_visible -> time-scale.md
  watermark_text -> watermark.md
  visible -> titles.md
  last_value_visible -> titles.md
  price_scale_id -> price-scale.md
  price_format -> price-formats.md
  last_price_line -> price-lines.md
  base_line -> price-scale.md
  price_scale -> price-scale.md
  color_column -> histogram.md
  pane -> multi-pane.md
  by -> multi-series.md
-->

# Bar (OHLC) Chart

A bar chart renders each OHLC interval as a vertical range bar with a short tick on the left for the open and a short tick on the right for the close. Use it when you want the readability of OHLC data but prefer a thinner, less ink-heavy rendering than candlesticks. It works well for very dense intraday charts, and when you plan to layer markers on top.

Like candlesticks, bars are color-coded by direction: an up bar has the close above the open, a down bar has the close below the open. Because the body is just two ticks instead of a filled rectangle, you can fit many more bars in the same horizontal space.

## What are OHLC bar charts useful for?

- **Dense intraday charts**: Bars take less horizontal pixel space than candles, so a 1-minute chart over a full session stays readable.
- **Overlays and annotations**: A thinner price track leaves room for markers, price lines, and secondary series without visual conflict.
- **Western technical analysis**: Many classical Western (vs. Japanese) chart conventions assume OHLC bars and read them more naturally than candles.
- **Volatility scans**: Long vertical bars with ticks close together flag wide-range, indecisive periods.

## Examples

### A basic bar chart

`tvl.bar` consumes the same OHLC table layout as `tvl.candlestick`. The `tvl.data.ohlc()` helper already has the canonical column names so the call is a one-liner.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(data)
```

Each row in `data` becomes one vertical bar with an open tick on the left and a close tick on the right. When `up_color` / `down_color` are not provided, the chart pulls them from the active Deephaven theme palette so the same code reads correctly in both light and dark themes.

### Map non-default OHLC column names

When your table uses different column names (say `Ts`/`O`/`H`/`L`/`C` from a custom upstream join), pass them as kwargs. The chart only reads the columns you point at.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc().rename_columns(["Ts=Timestamp", "O=Open", "H=High", "L=Low", "C=Close"])

bar = tvl.bar(
    data,
    timestamp="Ts",
    open="O",
    high="H",
    low="L",
    close="C",
)
```

### Customize up and down colors

`up_color` and `down_color` set the bar color for up and down intervals. The bar (range line plus open/close ticks) inherits a single color per bar, unlike candlesticks where bodies and borders can diverge.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(
    data,
    up_color="seafoam-800",
    down_color="magenta-600",
)
```

Both `up_color` and `down_color` accept a Deephaven theme color (e.g. `"seafoam-800"`, `"accent-300"`), a hex code (`"#26a69a"`), a named CSS color (`"crimson"`), or an `rgb()`/`rgba()` string for transparency. Theme colors adapt automatically when the user switches themes; hardcoded values do not. Leave them unset to inherit the active theme’s palette.

### Name the series

`title` names the series. It labels the price-scale badge tracking the latest bar, and is what the [tooltip](tooltip.md) and [legend](legend.md) call this series. Use it whenever the chart will be embedded next to other content where the column names are not self-explanatory.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(data, title="ES futures, 1m bars")
```

The price-scale badge now reads “ES futures, 1m bars”, and so does any tooltip or legend row for this series.

### Server-side autobinning

Hand the chart a large OHLC table and TVL automatically aggregates it server-side into a viewport-friendly number of buckets. Override the bucket count or width via `bin_count` / `bin_width`, or set `auto_bin=False` to bypass it entirely for small tables.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(data, auto_bin=True, bin_width="P7D")
```

See [autobin](autobin.md) for the full autobin surface: ISO-8601 duration grammar, when each `auto_bin` value is the right pick, and how the path interacts with the downsampler.

### Time-proportional layout with `continuous`

By default (`continuous=True`) bars are laid out proportionally in time. Unlike the [histogram](histogram.md#continuous-bars), the open/close ticks are **not** drawn end-to-end — each bar keeps the classic proportions, and the ticks of adjacent bars never touch — but sections of data separated by a time hole (a market close, a halted feed, missing rows) are separated by a proportional open gap. On data with no holes, `continuous=True` and `continuous=False` look the same. Set `continuous=False` to restore the plain ordinal layout, which collapses any time hole to a single bar-width step.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(data, continuous=False)
```

### Thin bars and hidden open ticks

Two bar-specific styling options trim the visual weight of each bar. `thin_bars=True` renders each bar with a narrower body, which is useful on very dense intraday charts; `open_visible=False` hides the short left “open” tick so each bar shows only the range line plus the right “close” tick, a cleaner look when the open price is not the focus.

```python order=bar,data
import deephaven.plot.tradingview_lightweight as tvl
data = tvl.data.ohlc()

bar = tvl.bar(
    data,
    thin_bars=True,
    open_visible=False,
)
```

The bars are now thinner and the left-side open tick is gone.

## API Reference

Bar series render each bucket as a vertical line with small
open/close ticks; contrast with candlestick_series() which
fills the body.  Same auto-bin behavior as candlestick.

**Returns:** `TvlChart` A chart wrapping a single bar series.

<ParamTable param={{"module_name": "deephaven.plot.tradingview_lightweight.", "name": "bar", "parameters": [{"name": "table", "type": "Any", "description": "Deephaven table containing OHLC data."}, {"name": "timestamp", "type": "str", "description": "Column name for the time axis.", "default": "'Timestamp'"}, {"name": "open", "type": "str", "description": "Column name for the opening price.", "default": "'Open'"}, {"name": "high", "type": "str", "description": "Column name for the bar high.", "default": "'High'"}, {"name": "low", "type": "str", "description": "Column name for the bar low.", "default": "'Low'"}, {"name": "close", "type": "str", "description": "Column name for the closing price.", "default": "'Close'"}, {"name": "up_color", "type": "Optional[Color]", "description": "Bar color for up-bars.", "default": "None"}, {"name": "down_color", "type": "Optional[Color]", "description": "Bar color for down-bars.", "default": "None"}, {"name": "open_visible", "type": "Optional[bool]", "description": "Show the open tick (default True).", "default": "None"}, {"name": "thin_bars", "type": "Optional[bool]", "description": "Use thin bar style.", "default": "None"}, {"name": "title", "type": "Optional[str]", "description": "Series name. Labels the price-scale badge, the tracking tooltip, and any legend row, and identifies the series in press events. Without one the badge shows only the number; the tooltip, legend, and events fall back to the generated series_<n> id. A by= series is titled with its partition key.", "default": "None"}, {"name": "visible", "type": "Optional[bool]", "description": "Series visibility.", "default": "None"}, {"name": "last_value_visible", "type": "Optional[bool]", "description": "Show the last-value badge.", "default": "None"}, {"name": "price_scale_id", "type": "Optional[str]", "description": "Price-scale ID.", "default": "None"}, {"name": "price_format", "type": "Optional[PriceFormat]", "description": "Per-series price format.", "default": "None"}, {"name": "last_price_line", "type": "Optional[LastPriceLine]", "description": "Styling for the auto last-price horizontal rule; build with last_price_line().", "default": "None"}, {"name": "base_line", "type": "Optional[BaseLine]", "description": "Styling for the zero/index base line; build with base_line().", "default": "None"}, {"name": "price_scale", "type": "Optional[PriceScale]", "description": "Options for the price scale this series binds to; build with price_scale().", "default": "None"}, {"name": "color_column", "type": "Optional[str]", "description": "Column name supplying per-row bar color.", "default": "None"}, {"name": "pane", "type": "Optional[int]", "description": "Pane index.", "default": "None"}, {"name": "markers", "type": "Optional[list[Marker]]", "description": "Static markers.", "default": "None"}, {"name": "price_lines", "type": "Optional[list[PriceLine]]", "description": "Horizontal price lines.", "default": "None"}, {"name": "marker_spec", "type": "Optional[MarkerSpec]", "description": "Table-driven marker spec.", "default": "None"}, {"name": "auto_bin", "type": "Optional[bool]", "description": "Auto-bin tri-state.  See candlestick_series() for full semantics.", "default": "None"}, {"name": "bin_width", "type": "Optional[str]", "description": "ISO 8601 duration override.", "default": "None"}, {"name": "bin_count", "type": "Optional[int]", "description": "Target number of bins.", "default": "None"}, {"name": "continuous", "type": "bool", "description": "True (default) renders bars spanning their full time bin (end-to-end); False uses the built-in fixed pixel-width renderer.", "default": "True"}, {"name": "by", "type": "Optional[str]", "description": "Column name to partition the table by. When set, one runtime series is created per unique value; new partition keys discovered at runtime (ticking tables) add new series automatically.", "default": "None"}, {"name": "on_press", "type": "Optional[PressEventCallable]", "description": "Server-side callback invoked when the user presses (clicks) on the chart. Receives a TvlPressEvent dict, or no argument.", "default": "None"}, {"name": "on_double_press", "type": "Optional[PressEventCallable]", "description": "Server-side callback invoked when the user double-presses on the chart.", "default": "None"}]}} />
