Skip to content

Compare action

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

Context

  • id?: Get | Update (Update is assumed if omitted)
  • plots: array of comparison plots
    • type: Symbol | Expression | Seasonal
    • symbol when type is Symbol
    • expression when type is Expression
    • seasonal when type is Seasonal
    • oppositeScale: true | false (leftScale is still accepted but deprecated)
    • curves: optional curve overrides
  • symbols: deprecated compatibility alias for symbol-only compare list
  • alignOnExpirations: true | false

Behavior

Configures comparison plots against the main plot.

  • Supports symbol, expression, and seasonal comparison plots.
  • Existing comparison plots are replaced by the incoming plots list.
  • By default, comparison plots share the main axis.
  • oppositeScale: true puts a plot on the secondary/opposite axis.
  • If curves is omitted, comparison plots render as lines with automatic colors.
  • Curve values are merged with defaults, so partial overrides are fine.
  • alignOnExpirations: true overlays eligible non-seasonal plots (mainly futures) as if they traded in the same year; the tooltip still shows actual trade dates.
  • Seasonal comparison plots align internally, so alignOnExpirations does not control seasonal alignment.

Get returns the same top-level shape (plots, alignOnExpirations). Compatibility note: returned plot axis side uses leftScale naming (legacy alias for opposite/secondary axis).

Example:

chart.change({
id: "Compare",
context: {
plots: [
{ type: "Symbol", symbol: "AAPL" },
{ type: "Seasonal", seasonal: "CLM24", oppositeScale: true },
],
alignOnExpirations: true,
},
});