PhiaUi.Components.Data.MarkLine (phia_ui v0.1.17)

Copy Markdown View Source

Statistical reference line component for charts.

Renders dashed horizontal or vertical lines at statistical positions (average, median, min, max) or custom values. Auto-computes position from data using ChartPipeline.stats/1.

Inspired by eCharts markLine.

Examples

<.mark_line
  data={[100, 200, 150, 300, 250]}
  type={:average}
  y_pos={120.5}
  width={340}
  label="Avg"
/>

<.mark_line
  type={:custom}
  value={200}
  y_pos={80.0}
  width={340}
  label="Target"
  color="oklch(0.60 0.25 0)"
/>

Summary

Functions

mark_line(assigns)

Attributes

  • data (:list) - List of numeric values for auto-computing line position. Defaults to [].
  • type (:atom) - Type of reference line. Defaults to :average. Must be one of :average, :median, :min, :max, or :custom.
  • value (:any) - Custom value (used when type is :custom). Defaults to nil.
  • axis (:atom) - Which axis the line crosses. :y = horizontal line, :x = vertical line. Defaults to :y. Must be one of :x, or :y.
  • scale (:any) - Scale function to convert data value to pixel position. Defaults to nil.
  • x (:any) - X offset for horizontal lines (left edge of chart area). Defaults to 0.
  • y_pos (:any) - Pre-computed Y pixel position (overrides scale computation). Defaults to nil.
  • width (:any) - Line width in pixels. Defaults to 340.
  • height (:any) - Line height for vertical lines. Defaults to nil.
  • label (:any) - Label text displayed at line end. Defaults to nil.
  • show_value (:boolean) - Show the numeric value in the label. Defaults to true.
  • color (:string) - Line and label color. Defaults to "oklch(0.60 0.25 0)".
  • dash_array (:string) - SVG stroke-dasharray pattern. Defaults to "4 3".
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.