Data, scales, and legends
Pass values as Record<string, number> keyed by the code of each rendered unit. Missing or non-finite values use fillDefault.
Scale strategies
linear: equal-width numeric bins.quantile: bins derived from the rank distribution.threshold: explicit boundaries supplied throughthresholds.
Build the same descriptor used by the map and pass it to Legend:
import { ChileMap, Legend, scaleFromData } from "react-chile-map";
const options = {
colors: ["#dbeafe", "#1e40af"],
bins: 5,
type: "quantile" as const,
};
const scale = scaleFromData(data, options);
<>
<ChileMap topology={topology} data={data} colors={options.colors} bins={options.bins} scaleType={options.type} />
<Legend scale={scale} showMissing missingLabel="No data" />
</>;
colorFor can override individual features. Return undefined to fall back to the shared scale.