Visualizations
Install the visualization tarball and three. Renderers are framework-neutral and mount into DOM elements with a nonzero width and height.
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
| Function | Purpose |
|---|---|
createParetoScatter | Two-objective trade-offs and candidate selection |
createParetoSpace3d | Three-objective spatial view |
createParallelCoordinates | Compare several objectives |
createDiamondFitness | Direction-aware relative objective profiles |
createLeverProfile | Compare design variables |
createConstraintFeasibility | Inspect feasible and violated constraints |
createConvergenceHistory | Objective statistics over generations |
createGenerationCounts | Population 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.