Skip to content

Visualizations ​

Install the visualization tarball and three. Renderers are framework-neutral and mount into DOM elements with a nonzero width and height.

ts
import { createParetoScatter, createConvergenceHistory, validateDataset, type OptimizationDataset, type SelectionState } from '@genetic-assembly/visualizations';
export function renderResults(scatterElement: HTMLElement, historyElement: HTMLElement, dataset: OptimizationDataset) {
  validateDataset(dataset);
  const selection: SelectionState = { pinnedIds: [] };
  const scatter = createParetoScatter(scatterElement, { onSelect(id) { selection.activeId = id; update(); } });
  const history = createConvergenceHistory(historyElement);
  function update() { for (const chart of [scatter, history]) chart.update({ dataset, selection }); }
  const observer = new ResizeObserver(() => { scatter.resize(); history.resize(); });
  observer.observe(scatterElement); observer.observe(historyElement); update();
  return () => { observer.disconnect(); scatter.destroy(); history.destroy(); };
}

Use a separate element for each chart and call the returned cleanup function when your view unmounts. Pass updated data or selection through update, resize with the container, and destroy chart resources on removal.

Available views ​

FunctionPurpose
createParetoScatterTwo-objective trade-offs and candidate selection
createParetoSpace3dThree-objective spatial view
createParallelCoordinatesCompare several objectives
createDiamondFitnessDirection-aware relative objective profiles
createLeverProfileCompare design variables
createConstraintFeasibilityInspect feasible and violated constraints
createConvergenceHistoryObjective statistics over generations
createGenerationCountsPopulation and feasibility counts

Use validateDataset at integration boundaries. Selection state links views through candidate IDs. Missing complete history should remain visible as unavailable rather than being filled with invented values.

Recorded interactive examples · All visualization functions and types

Use fromGenerationSnapshots(study, snapshots, candidates) to adapt SDK-owned generation history. It uses exact population and front membership, computes chart statistics from the referenced aggregate measurements, and rejects missing candidate evidence. It does not infer survivors from evaluation order.

Genetic Assembly · Deterministic NSGA-II optimization