← Files DataARCHIVED FILE
output_formats/html/src/charting/shared/config.js
1.7 KB · Nov 27, 2026 · 12:12 UTC
// Generated by scripts/sync-chart-semantics.mjs from skills/visualize-data/src/config.js.
// Edit the canonical source and regenerate; do not edit this distribution copy.
import { hasReviewedBoxPlotSummary } from "./core/chart-transforms.js";
import { semanticColorResolver } from "./core/chart-theme.js";
import { checkedPayload } from "./adapters/inline/input.js";
import { toRendererSpec } from "./adapters/inline/physical-axes.js";
import { chartConfigMembers } from "./config-envelope.js";
/** Shared JSON contract. Omitted schemaVersion is the original v1 envelope. */
export function checkedChartConfig(config, options) {
const charts = chartConfigMembers(config).map(chart => checkedPayload(chart, options));
return Object.hasOwn(config, "charts") ? { ...config, charts } : charts[0];
}
/** Renderer encoding is private; every public surface crosses this boundary. */
export function chartConfigEntries(config, options) {
const checked = checkedChartConfig(config, options);
return (checked.charts ?? [checked]).map(chart => {
const spec = toRendererSpec(chart.spec);
if (spec.type === "boxPlot" && !hasReviewedBoxPlotSummary(chart.rows)) spec.whiskers ??= "tukey";
return { ...chart, height: chart.height ?? 280, spec };
});
}
/** One retained allocator per configuration group, independent of its host. */
export function chartConfigColors(charts, metadata = null) {
return semanticColorResolver(Object.fromEntries(charts.map(chart => [chart.id, {
...chart, measureFields: chart.spec?.fields ?? (chart.spec ? [chart.spec.y] : chart.measureFields),
}])), metadata, {
palette: Array.from({ length: 12 }, (_, index) => `var(--chart-${index + 1})`),
categoryOrder: "appearance",
});
}
SHA-256: a4202ed6a1168bd298a9506cdb3aeaa203cccfeeb81b50a53442b255d70e4781