Baseline Chart
A baseline chart is an area chart split along a horizontal reference level: the portion above the baseline is filled with one color (typically green for “good”), the portion below with another (typically red for “bad”). Use it when the meaningful question is “are we above or below this number?”, such as performance vs. a benchmark, P&L vs. zero, or latency vs. an SLA.
The base_value parameter is the y-coordinate of the dividing line. By default it sits at 0, which is the right choice for P&L and other zero-centered quantities; set it explicitly when your baseline is a benchmark return, an SLA, or any non-zero reference.
What are baseline charts useful for?
- P&L and returns vs. zero: Above the line is profit; below is loss. The color split makes runs of positive/negative days impossible to miss.
- Performance vs. a benchmark: Set
base_valueto the benchmark’s return and the chart immediately shows excess/deficit performance. - SLA / threshold monitoring: Latency, error rate, or any quantity with a “good vs. bad” threshold reads cleanly as a baseline.
- Index-relative views: Anything reported as “vs. 100” or “vs. open” benefits from explicit above/below shading.
Examples
A basic baseline chart
Pass a table with a timestamp column and a value column. With no base_value the chart uses 0 as the baseline. The tvl.data.values() series oscillates around 100, so for a meaningful split we set base_value=100.
Sections of the curve above 100 are shaded with the top color; sections below 100 with the bottom color.
Customize above/below line colors
top_line_color and bottom_line_color set the outline color of the line itself when it’s above/below the baseline. Color kwargs accept a Deephaven theme color (e.g. "positive", "seafoam-500", "accent-300"), a hex code ("#1b5e20"), a named CSS color ("darkgreen"), or an rgb()/rgba() string for transparency. Theme colors adapt automatically when the user switches themes; hardcoded values do not.
The line uses the user’s theme “positive” color above the baseline and “negative” color below.
Set the baseline at zero for P&L
For a P&L series the natural baseline is 0. Gains above, losses below. Build a synthetic P&L by shifting the demo series and set base_value=0.
Positive portions of the curve are profit days; negative portions are loss days.
Line width
line_width is an integer pixel width from 1 to 4 (the LWC default is 3). Wide lines emphasize the trajectory; thin lines let the colored fill dominate.
The outline is now one pixel wide.
Customize the per-half gradient stops
Each half of the chart has its own two-stop vertical gradient. Above the baseline, top_fill_color1 is the stop nearer the line and top_fill_color2 is the stop nearer the top edge; below the baseline, bottom_fill_color1 is the stop nearer the line and bottom_fill_color2 is the stop nearer the bottom edge. Fade either pair toward "transparent" to let the chart background show through at the extremes.
The above-baseline half fades from a theme “positive” green at the line out to transparent at the top; the below-baseline half fades from a theme “negative” red at the line out to transparent at the bottom.
Relative gradient and per-point color columns
relative_gradient=True anchors the two-tone gradient to the series’ value range. Every per-half color can also be driven from a table column: top_line_color_column / bottom_line_color_column for the line above/below the baseline, and top_fill_color1_column / top_fill_color2_column / bottom_fill_color1_column / bottom_fill_color2_column for the gradient stops.
API Reference
A baseline series renders an area between the value line and a horizontal "base value", with different gradient fills above (top) and below (bottom) the baseline. Useful for visualizing diff-from-reference quantities (P&L vs 0, return vs index, etc.).
Returns: TvlChart A chart wrapping a single baseline series.
| Parameters | Type | Default | Description |
|---|---|---|---|
| table | Any | Deephaven table with the data. | |
| timestamp | str | Column name for the time axis. | |
| value | str | Column name for the y-axis. | |
| base_value | Optional[float] | None | The baseline price level. The fill color flips at this y-value. Defaults to 0.0. |
| top_line_color | Optional[Color] | None | Line color above the baseline. |
| top_fill_color1 | Optional[Color] | None | Gradient stop 1 (closer to line) for the area above the baseline. |
| top_fill_color2 | Optional[Color] | None | Gradient stop 2 (farther from line) above the baseline. |
| bottom_line_color | Optional[Color] | None | Line color below the baseline. |
| bottom_fill_color1 | Optional[Color] | None | Gradient stop 1 below. |
| bottom_fill_color2 | Optional[Color] | None | Gradient stop 2 below. |
| line_width | Optional[LineWidth] | None | Stroke width 1–4 px. |
| line_style | Optional[LineStyle] | None | Dash pattern. |
| line_type | Optional[LineType] | None | Geometry; see LineType. |
| line_visible | Optional[bool] | None | Show the line. |
| relative_gradient | Optional[bool] | None | Gradient measured relative to series values rather than chart bounds. |
| point_markers_visible | Optional[bool] | None | Show point markers. |
| point_markers_radius | Optional[float] | None | Point marker radius. |
| crosshair_marker | Optional[CrosshairMarker] | None | Styling for the crosshair marker dot; build with crosshair_marker(). |
| last_price_animation | Optional[LastPriceAnimationMode] | None | Last-price dot animation. |
| last_value_visible | Optional[bool] | None | Show the last-value badge. |
| title | Optional[str] | None | Title. |
| visible | Optional[bool] | None | Series visibility. |
| price_scale_id | Optional[str] | None | Price-scale ID. |
| price_format | Optional[PriceFormat] | None | Per-series price format. |
| last_price_line | Optional[LastPriceLine] | None | Styling for the auto last-price horizontal rule; build with last_price_line(). |
| base_line | Optional[BaseLine] | None | Styling for the secondary baseline (TVL's built-in zero/index rule — not the same as base_value); build with base_line(). |
| price_scale | Optional[PriceScale] | None | Options for the price scale this series binds to; build with price_scale(). |
| top_line_color_column | Optional[str] | None | Per-row top line color column. |
| top_fill_color1_column | Optional[str] | None | Per-row top gradient stop 1 column. |
| top_fill_color2_column | Optional[str] | None | Per-row top gradient stop 2 column. |
| bottom_line_color_column | Optional[str] | None | Per-row bottom line color column. |
| bottom_fill_color1_column | Optional[str] | None | Per-row bottom gradient stop 1 column. |
| bottom_fill_color2_column | Optional[str] | None | Per-row bottom gradient stop 2 column. |
| pane | Optional[int] | None | Pane index. |
| markers | Optional[list[Marker]] | None | Static markers. |
| price_lines | Optional[list[PriceLine]] | None | Horizontal price lines. |
| marker_spec | Optional[MarkerSpec] | None | Table-driven marker spec. |
| continuous | bool | True | True (default) = time-proportional chart axis; False opts the whole chart back to the plain ordinal layout. See line_series(). |
| by | Optional[str] | None | 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. |
| on_press | Optional[PressEventCallable] | None | Server-side callback invoked when the user presses (clicks) on the chart. Receives a TvlPressEvent dict, or no argument. |
| on_double_press | Optional[PressEventCallable] | None | Server-side callback invoked when the user double-presses on the chart. |