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_value to 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.

ParametersTypeDefaultDescription
tableAnyDeephaven table with the data.
timestampstrColumn name for the time axis.
valuestrColumn name for the y-axis.
base_valueOptional[float]NoneThe baseline price level. The fill color flips at this y-value. Defaults to 0.0.
top_line_colorOptional[Color]NoneLine color above the baseline.
top_fill_color1Optional[Color]NoneGradient stop 1 (closer to line) for the area above the baseline.
top_fill_color2Optional[Color]NoneGradient stop 2 (farther from line) above the baseline.
bottom_line_colorOptional[Color]NoneLine color below the baseline.
bottom_fill_color1Optional[Color]NoneGradient stop 1 below.
bottom_fill_color2Optional[Color]NoneGradient stop 2 below.
line_widthOptional[LineWidth]NoneStroke width 1–4 px.
line_styleOptional[LineStyle]NoneDash pattern.
line_typeOptional[LineType]NoneGeometry; see LineType.
line_visibleOptional[bool]NoneShow the line.
relative_gradientOptional[bool]NoneGradient measured relative to series values rather than chart bounds.
point_markers_visibleOptional[bool]NoneShow point markers.
point_markers_radiusOptional[float]NonePoint marker radius.
crosshair_markerOptional[CrosshairMarker]NoneStyling for the crosshair marker dot; build with crosshair_marker().
last_price_animationOptional[LastPriceAnimationMode]NoneLast-price dot animation.
last_value_visibleOptional[bool]NoneShow the last-value badge.
titleOptional[str]NoneTitle.
visibleOptional[bool]NoneSeries visibility.
price_scale_idOptional[str]NonePrice-scale ID.
price_formatOptional[PriceFormat]NonePer-series price format.
last_price_lineOptional[LastPriceLine]NoneStyling for the auto last-price horizontal rule; build with last_price_line().
base_lineOptional[BaseLine]NoneStyling for the secondary baseline (TVL's built-in zero/index rule — not the same as base_value); build with base_line().
price_scaleOptional[PriceScale]NoneOptions for the price scale this series binds to; build with price_scale().
top_line_color_columnOptional[str]NonePer-row top line color column.
top_fill_color1_columnOptional[str]NonePer-row top gradient stop 1 column.
top_fill_color2_columnOptional[str]NonePer-row top gradient stop 2 column.
bottom_line_color_columnOptional[str]NonePer-row bottom line color column.
bottom_fill_color1_columnOptional[str]NonePer-row bottom gradient stop 1 column.
bottom_fill_color2_columnOptional[str]NonePer-row bottom gradient stop 2 column.
paneOptional[int]NonePane index.
markersOptional[list[Marker]]NoneStatic markers.
price_linesOptional[list[PriceLine]]NoneHorizontal price lines.
marker_specOptional[MarkerSpec]NoneTable-driven marker spec.
continuousboolTrueTrue (default) = time-proportional chart axis; False opts the whole chart back to the plain ordinal layout. See line_series().
byOptional[str]NoneColumn 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_pressOptional[PressEventCallable]NoneServer-side callback invoked when the user presses (clicks) on the chart. Receives a TvlPressEvent dict, or no argument.
on_double_pressOptional[PressEventCallable]NoneServer-side callback invoked when the user double-presses on the chart.