Skip to content

Scale action

Use this action with change({ id: 'Scale', context }).

Context

  • id?: Get | Update (Update is assumed if omitted)
  • scale: Linear (same as undefined) or Logarithmic
  • marginBars: number of right-margin bars on the time axis
  • minPadding: deprecated compatibility input, ignored
  • maxPadding: deprecated compatibility input, ignored
  • preventLabelOverlap: true | false (deprecated compatibility alias for vertical overlap)
  • preventVerticalLabelOverlap: true | false
  • preventHorizontalLabelOverlap: true | false
  • includePercentChangeWithLastValue: true | false
  • snapAnnotationsToPrices: true | false
  • primaryOnTheLeft: true | false
  • horizontalAxisPosition: bottom | top | both (default bottom)
  • nonEodLabelWithDate: true | false
  • ordinalName: string
  • labels: array of axis-label updates
    • item shape: { axis: 'vertical', text, index, paneIndex? }
  • contractTransition: line-style object (enabled, color, dashStyle, width, fillColor)
  • cycleTransition: line-style object (enabled, color, dashStyle, width, fillColor)

Behavior

  • Scale.Get reads scale from the main axis.
  • Scale.Update scale applies to all axes in the main pane.
  • marginBars sets right margin in bars (not pixels), default 0.
  • preventLabelOverlap and preventVerticalLabelOverlap apply to the Y axis only.
  • preventHorizontalLabelOverlap applies to the X axis only.
  • snapAnnotationsToPrices applies to the Y axis only and snaps annotation points to the nearest visible price on the main plot.
  • primaryOnTheLeft controls the visual side of the primary Y axis (false = right side, true = left side).
  • horizontalAxisPosition sets display.xAxis.position. The top strip appears above all chart panes, inside the chart below any host toolbar. In both mode, tick labels, crosshair dates, and annotation dates appear on both strips and share the same time scale. Hiding the X axis hides both strips.
  • nonEodLabelWithDate and ordinalName apply to X-axis labeling.
  • labels updates per-axis labels by axis index (optionally scoped by paneIndex).
  • contractTransition and cycleTransition update transition-line styling on the X axis.

Sub-actions

Get

Returns current scale/axis settings.

Parity notes:

  • Get mirrors most updateable scale state.
  • minPadding and maxPadding are compatibility inputs only (ignored) and are not part of returned state.
  • labels is write-only label-update input and is not returned by Get.
  • preventLabelOverlap is returned as a deprecated compatibility field.

Example:

const scaleState = chart.change({
id: "Scale",
context: { id: "Get" },
});

Update

Updates one or more scale/axis settings.

Example:

chart.change({
id: "Scale",
context: { primaryOnTheLeft: true },
});

Show the time axis at both edges:

chart.change({
id: "Scale",
context: { horizontalAxisPosition: "both" },
});