blessed-components - v1.20.0
    Preparing search index...

    Function renderSparkline

    • Renders a deterministic terminal sparkline.

      This pure renderer does not import Blessed. Use the blessed-components/sparkline subpath to keep the Blessed adapter outside the module graph.

      When downsampling is required, the series is divided into ordered buckets and each bucket keeps its maximum value. This preserves narrow peaks. A constant series uses the middle glyph to avoid division by zero.

      Output shape:

      [optional label and value]
      [graph][optional summary]
      

      With no metadata, only the graph line is returned.

      Parameters

      Returns string

      Plain text without ANSI sequences or Blessed tags.

      RangeError Thrown when width is not a positive integer.

      RangeError Thrown when fewer than two non-empty characters are provided.

      RangeError Thrown when any sample or domain bound is not finite.

      RangeError Thrown when an explicit domain does not have max > min.

      import { renderSparkline } from 'blessed-components/sparkline';

      renderSparkline({
      values: [1, 2, 3, 4, 5, 6, 7, 8],
      width: 8,
      });
      // "▁▂▃▄▅▆▇█"
      renderSparkline({
      label: 'Downloads',
      value: '25.2M',
      values: [1, 3, 2, 8],
      width: 4,
      summary: 'peak: 8M',
      });
      // "Downloads 25.2M\n▁▃▂█ peak: 8M"