Skip to content

Function: diffFigures() ​

ts
function diffFigures(prev, next, registry): FigureDiff;

Experimental

Diff two figure inputs (plan E1.8). Never mutates its arguments and never reads the contents of data arrays, so its cost is proportional to the size of the spec, not of the data.

Parameters ​

ParameterTypeDescription
prevAnyFigureThe figure currently shown (as input, i.e. before defaults).
nextAnyFigureThe figure passed to react.
registryRegistrySupplies trace and layout schemas, which decide which values are data arrays.

Returns ​

FigureDiff

Example ​

ts
const d = diffFigures(prev, next, registry);
if (!d.empty) {
  const stages = planDiff(d, { registry, fullData, fullLayout });
  // reuse scene objects for d.traces.matched, build d.traces.added, dispose d.traces.removed
}

Released under the MIT License.