minerva-design 1.17.0 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/charts/engine/backing-store.cjs +2 -0
- package/dist/charts/engine/backing-store.cjs.map +1 -0
- package/dist/charts/engine/backing-store.d.cts +11 -0
- package/dist/charts/engine/backing-store.d.ts +11 -0
- package/dist/charts/engine/backing-store.js +27 -0
- package/dist/charts/engine/backing-store.js.map +1 -0
- package/dist/charts/engine/canvas.cjs +1 -1
- package/dist/charts/engine/canvas.cjs.map +1 -1
- package/dist/charts/engine/canvas.js +89 -86
- package/dist/charts/engine/canvas.js.map +1 -1
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +5 -0
- package/dist/charts/engine/model.d.ts +5 -0
- package/dist/charts/engine/model.js +1 -0
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +6 -0
- package/dist/charts/engine/overlay.d.ts +6 -0
- package/dist/charts/engine/overlay.js +68 -6
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +1 -1
- package/dist/charts/engine/presets.cjs.map +1 -1
- package/dist/charts/engine/presets.js +4 -0
- package/dist/charts/engine/presets.js.map +1 -1
- package/dist/charts/engine/scene.cjs +1 -1
- package/dist/charts/engine/scene.cjs.map +1 -1
- package/dist/charts/engine/scene.d.cts +11 -0
- package/dist/charts/engine/scene.d.ts +11 -0
- package/dist/charts/engine/scene.js +107 -90
- package/dist/charts/engine/scene.js.map +1 -1
- package/dist/charts/engine/shapes/canvas.cjs +1 -1
- package/dist/charts/engine/shapes/canvas.cjs.map +1 -1
- package/dist/charts/engine/shapes/canvas.js +97 -94
- package/dist/charts/engine/shapes/canvas.js.map +1 -1
- package/dist/charts/engine/types.d.cts +10 -0
- package/dist/charts/engine/types.d.ts +10 -0
- package/dist/native/charts/src/engine/backing-store.cjs +2 -0
- package/dist/native/charts/src/engine/backing-store.cjs.map +1 -0
- package/dist/native/charts/src/engine/backing-store.js +27 -0
- package/dist/native/charts/src/engine/backing-store.js.map +1 -0
- package/dist/native/charts/src/engine/model.cjs +1 -1
- package/dist/native/charts/src/engine/model.cjs.map +1 -1
- package/dist/native/charts/src/engine/model.js +1 -0
- package/dist/native/charts/src/engine/model.js.map +1 -1
- package/dist/native/charts/src/engine/overlay.cjs +1 -1
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
- package/dist/native/charts/src/engine/overlay.js +64 -2
- package/dist/native/charts/src/engine/overlay.js.map +1 -1
- package/dist/native/charts/src/engine/presets.cjs +1 -1
- package/dist/native/charts/src/engine/presets.cjs.map +1 -1
- package/dist/native/charts/src/engine/presets.js +4 -0
- package/dist/native/charts/src/engine/presets.js.map +1 -1
- package/dist/native/charts/src/engine/scene.cjs +1 -1
- package/dist/native/charts/src/engine/scene.cjs.map +1 -1
- package/dist/native/charts/src/engine/scene.js +107 -90
- package/dist/native/charts/src/engine/scene.js.map +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.cjs +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.cjs.map +1 -1
- package/dist/native/charts/src/engine/shapes/canvas.js +107 -104
- package/dist/native/charts/src/engine/shapes/canvas.js.map +1 -1
- package/dist/taro/chart-pixel-ratio.d.ts +10 -0
- package/dist/taro/{components-DoBebZ28.js → components-R1m1BIE0.js} +1 -1
- package/dist/taro/icons.js +1 -1
- package/dist/taro/index.js +1757 -1663
- package/dist/taro/monaco.js +1 -1
- package/dist/taro/style.css +102 -2
- package/dist/uni/QuadrantTaskBoard.vue +4 -14
- package/dist/uni/style.css +90 -0
- package/dist/weapp/charts/canvas.js +201 -18
- package/dist/weapp/controls.js +1 -1
- package/dist/weapp/controls.wxss +90 -0
- package/dist/weapp/quadrant-task-board/index.wxml +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","names":["PRESET_LABELS","presetLabels","localeLabels","locale","withSeriesType","series","t","s","type","stack","curve","lineSeries","area","extra","areaSeries","barSeries","stacked","labels","scatterSeries","candlestickSeries","heatmapChartOptions","numericX","config","c","numericY","base","sparklineOptions","quadrantGroups","groups","p","g","quadrantOf","i","QUADRANT_LABELS","quadrantLabels","quadrantCountText","showCounts","points","numberFormat","resolveLocale","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","y0","y1","right","x","xs","y","ys","quadrantCenter","visualRight","corner","CORNER_ORDER","quadrantData","cachedData","byKey","data","key","make","quadrantChartOptions","reverseX","color","pointSize","dotColor","colorKey","SURFACE","ring","unique","indices","id","grow","look","selected","focused","state","left","rect","xa","xb","ya","yb","region","detail","position","ends","visualLeft","texts","annotations","showTicks","interaction","item","event","sortedFinite","n","values","out","k","v","quantileOf","sorted","at","lo","hi","quantiles","ps","SPREAD_SAMPLE","binValues","min","max","options","span","rule","sturges","count","stride","sample","width","start","tickStep","end","counts","total","edges","histogramSeries","bins","format","formatEdge","value","a","b","boxplotStats","q1","median","q3","sum","whisker","low","high","outliers","reach","from","to","j","upper","boxplotData","boxplotSeries","waterfallSeries","up","down","running","steps","step","bubbleSeries","minSize","maxSize","valuesOf","list","top","sizeOf","size","d","THEMED","FALLBACK","paletteColor","fallback","themed","time","HOUR_MS","DAY_MS","SOLID_TASK","floorMinutes","ceilMinutes","floor","ganttSeries","names","rows","chartLabels","taskName","progressName","separator","idOf","rowOf","bars","tasks","barLabels","labelled","point","named","colorOf","formatProgress","share","details","progress","milestones","pad","domain","near","dependencies","rangeAreaSeries"],"sources":["../../../../charts/src/engine/presets.ts"],"sourcesContent":["// Option presets of the chart components, shared by every platform (React,\n// mini-programs, React Native): they turn component props into engine\n// options.\n\nimport {\n localeLabels,\n numberFormat,\n resolveLocale,\n type LabelDictionary,\n} from \"./locale\";\nimport { chartLabels } from \"./labels\";\nimport { tickStep } from \"./scale\";\nimport type {\n ChartAnnotation,\n ChartColorScheme,\n ChartConnectorOptions,\n ChartCurve,\n ChartDependency,\n ChartInteractionOptions,\n ChartOptions,\n ChartPointDatum,\n ChartSeries,\n ChartSeriesType,\n ChartTooltipDetail,\n ChartXValue,\n} from \"./types\";\n\n/** Default series names of the presets */\ninterface PresetLabels {\n value: string;\n values: string;\n count: string;\n change: string;\n tasks: string;\n progress: string;\n milestones: string;\n}\n\nconst PRESET_LABELS: LabelDictionary<PresetLabels> = {\n en: {\n value: \"Value\",\n values: \"Values\",\n count: \"Count\",\n change: \"Change\",\n tasks: \"Tasks\",\n progress: \"Progress\",\n milestones: \"Milestones\",\n },\n zh: {\n value: \"数值\",\n values: \"数值\",\n count: \"数量\",\n change: \"变化\",\n tasks: \"任务\",\n progress: \"进度\",\n milestones: \"里程碑\",\n },\n ja: {\n value: \"値\",\n values: \"値\",\n count: \"件数\",\n change: \"増減\",\n tasks: \"タスク\",\n progress: \"進捗\",\n milestones: \"マイルストーン\",\n },\n fr: {\n value: \"Valeur\",\n values: \"Valeurs\",\n count: \"Effectif\",\n change: \"Variation\",\n tasks: \"Tâches\",\n progress: \"Avancement\",\n milestones: \"Jalons\",\n },\n};\n\n/** Default series names of the presets in a locale (the page language by default) */\nexport const presetLabels = (locale?: string): PresetLabels =>\n localeLabels(PRESET_LABELS, locale);\n\n/** Gives the series without a `type` the type of the component */\nexport const withSeriesType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n curve?: ChartCurve,\n): ChartSeries[] =>\n series.map((s) => {\n const t = s.type ?? type;\n return {\n ...s,\n type: t,\n ...(stack !== undefined && t === type ? { stack: s.stack ?? stack } : {}),\n ...(curve !== undefined && (t === \"line\" || t === \"area\")\n ? { curve: s.curve ?? curve }\n : {}),\n };\n });\n\n/** Options of the line-like components */\nexport interface LineSeriesOptions {\n /** Stacks the series on top of each other */\n stacked?: boolean;\n /** Shape of the lines */\n curve?: ChartCurve;\n}\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (\n series: readonly ChartSeries[],\n area = false,\n extra: LineSeriesOptions = {},\n) =>\n withSeriesType(\n series,\n area ? \"area\" : \"line\",\n extra.stacked ? \"stack\" : undefined,\n extra.curve,\n );\n\n/** Series of an AreaChart */\nexport const areaSeries = (\n series: readonly ChartSeries[],\n extra: LineSeriesOptions = {},\n) => lineSeries(series, true, extra);\n\n/** Series of a BarChart (`stacked` stacks them, `labels` shows the values) */\nexport const barSeries = (\n series: readonly ChartSeries[],\n stacked = false,\n labels = false,\n) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined).map((s) =>\n labels && s.type === \"bar\" ? { ...s, showLabels: s.showLabels ?? true } : s,\n );\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\n\n/** Series of a CandlestickChart */\nexport const candlestickSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"candlestick\");\n\n/** A cell of a HeatmapChart */\nexport interface HeatmapCell {\n /** Column: a category name (or a number on a numeric axis) */\n x: string | number;\n /** Row: a category name (or a number on a numeric axis) */\n y: string | number;\n /** Value mapped to the color scale; `null` leaves the cell empty */\n value: number | null;\n}\n\n/** Settings of a heatmap (the props of HeatmapChart) */\nexport interface HeatmapConfig {\n /** Cells */\n data: readonly HeatmapCell[];\n /** Column names in order (collected from the data when omitted) */\n xCategories?: readonly string[];\n /** Row names from bottom to top (collected from the data when omitted) */\n yCategories?: readonly string[];\n /**\n * Colors from the lowest to the highest value (interpolated in OKLab), or\n * a built-in theme-aware ramp of the first palette color\n * @default \"sequential\"\n */\n colorScale?: readonly string[] | ChartColorScheme;\n /** Values at the ends of the color scale; the data range by default */\n valueRange?: readonly [number, number];\n /**\n * Value at the middle of the color scale (diverging data)\n * @default 0 for `diverging` ramps spanning it, else the middle of the range\n */\n colorMidpoint?: number;\n /** Name of the value in the tooltip */\n name?: string;\n /** Corner radius of the cells, in pixels */\n radius?: number;\n /** Formats the values in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a heatmap */\nexport const heatmapChartOptions = (\n config: HeatmapConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const numericX = config.data.some((c) => typeof c.x === \"number\");\n const numericY = config.data.some((c) => typeof c.y === \"number\");\n return {\n ...base,\n series: [\n {\n id: \"heatmap\",\n name: config.name ?? presetLabels(base.locale).value,\n type: \"heatmap\",\n data: config.data.map((c) => ({ x: c.x, y: c.y, value: c.value })),\n colorScale: config.colorScale,\n valueRange: config.valueRange,\n colorMidpoint: config.colorMidpoint,\n radius: config.radius,\n format: config.format,\n },\n ],\n xAxis: {\n ...(numericX\n ? {}\n : { type: \"category\" as const, categories: config.xCategories }),\n grid: false,\n ...base.xAxis,\n },\n yAxis: {\n ...(numericY\n ? {}\n : { type: \"category\" as const, categories: config.yCategories }),\n grid: false,\n ...base.yAxis,\n },\n // the color legend (visual map)\n legend: base.legend ?? true,\n interaction: base.interaction ?? { zoom: false },\n tooltip: base.tooltip ?? { mode: \"nearest\" },\n };\n};\n\n/** Settings of a sparkline (the props of Sparkline) */\nexport interface SparklineConfig {\n /** Values (or `[x, y]` pairs, typed arrays, ...) */\n data: ChartSeries[\"data\"];\n /**\n * How the values are drawn\n * @default \"line\"\n */\n type?: \"line\" | \"area\" | \"bar\";\n /** Color (any CSS color); the first palette color by default */\n color?: string;\n /**\n * Shape of the line\n * @default \"smooth\"\n */\n curve?: ChartCurve;\n /** Name shown in the tooltip */\n name?: string;\n /** Draws a reference line at this value (e.g. a target or the average) */\n reference?: number;\n /** Formats the value in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a sparkline: no axes, no legend, a tooltip only */\nexport const sparklineOptions = (\n config: SparklineConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const type = config.type ?? \"line\";\n return {\n ...base,\n series: [\n {\n id: \"sparkline\",\n name: config.name ?? presetLabels(base.locale).value,\n type,\n data: config.data,\n color: config.color,\n curve: type === \"bar\" ? undefined : (config.curve ?? \"smooth\"),\n lineWidth: 1.5,\n opacity: type === \"area\" ? 0.22 : undefined,\n radius: type === \"bar\" ? 1.5 : undefined,\n format: config.format,\n },\n ],\n xAxis: { visible: false, grid: false, ...base.xAxis },\n yAxis: { visible: false, grid: false, nice: false, ...base.yAxis },\n legend: false,\n padding: base.padding ?? { top: 4, right: 4, bottom: 4, left: 4 },\n interaction: base.interaction ?? { zoom: false },\n annotations:\n config.reference !== undefined\n ? [\n ...(base.annotations ?? []),\n {\n type: \"line\",\n axis: \"y\",\n value: config.reference,\n dash: [2, 3],\n },\n ]\n : base.annotations,\n };\n};\n\n/** A point of a QuadrantChart */\nexport interface QuadrantPoint {\n /** Position on the horizontal axis */\n x: number;\n /** Position on the vertical axis */\n y: number;\n /** Text drawn next to the dot and shown in the tooltip */\n label?: string;\n /** Dot color (any CSS color); the color of its quadrant by default */\n color?: string;\n /** Dot diameter in pixels */\n size?: number;\n}\n\n/** Title and color of a quadrant */\nexport interface QuadrantRegion {\n /** Title drawn in the outer corner of the quadrant */\n label?: string;\n /** Background tint and default dot color (any CSS color) */\n color?: string;\n /** Short code drawn in a pill before the title (e.g. \"Q1\") */\n badge?: string;\n /** Second line drawn under the title (e.g. \"Do it now\"); cut with … when too long */\n description?: string;\n}\n\n/** The four quadrants of a QuadrantChart */\nexport interface QuadrantRegions {\n topLeft?: QuadrantRegion;\n topRight?: QuadrantRegion;\n bottomLeft?: QuadrantRegion;\n bottomRight?: QuadrantRegion;\n}\n\n/** A quadrant, as seen on screen */\nexport type QuadrantCorner = keyof QuadrantRegions;\n\n/** Texts at the four ends of the dividers, inside the plot */\nexport interface QuadrantAxisLabels {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n}\n\n/** Settings of a quadrant matrix (the props of QuadrantChart) */\nexport interface QuadrantConfig {\n /** Points to place */\n points: readonly QuadrantPoint[];\n /**\n * Range of the horizontal axis\n * @default [0, 10]\n */\n xDomain?: [number, number];\n /**\n * Range of the vertical axis\n * @default [0, 10]\n */\n yDomain?: [number, number];\n /** X value of the vertical divider (the middle of `xDomain` by default) */\n xSplit?: number;\n /** Y value of the horizontal divider (the middle of `yDomain` by default) */\n ySplit?: number;\n /** Titles and colors of the quadrants */\n quadrants?: QuadrantRegions;\n /** Title of the horizontal axis */\n xLabel?: string;\n /** Title of the vertical axis */\n yLabel?: string;\n /** Texts at the ends of the dividers, drawn inside the plot (e.g. \"Important\" at the top) */\n axisLabels?: QuadrantAxisLabels;\n /**\n * Shows the numeric ticks of the axes; `false` keeps only the matrix\n * @default true\n */\n showTicks?: boolean;\n /** Reverses the horizontal axis (e.g. \"urgent\" on the left) */\n reverseX?: boolean;\n /**\n * Draws the labels next to the dots (overlapping labels are skipped)\n * @default true\n */\n showLabels?: boolean;\n /**\n * Dot diameter in pixels\n * @default 12\n */\n pointSize?: number;\n /** Name of the points in the tooltip */\n name?: string;\n /** Lets the user drag the dots (`drag` / `drop` events) */\n draggable?: boolean;\n /**\n * Shows the number of points of each quadrant after its title; a function\n * returns the text instead (e.g. `(n) => `${n} tasks``)\n * @default false\n */\n showCounts?:\n boolean | ((count: number, points: readonly QuadrantPoint[]) => string);\n /** Index of the selected point: drawn with a ring of its color (`null`: none) */\n selectedIndex?: number | null;\n /** Indices of the selected points (several selected points) */\n selectedIndices?: readonly number[];\n}\n\n/** State of a quadrant matrix that is not a prop (set by the components) */\nexport interface QuadrantChartState {\n /** Index of the keyboard-focused point: drawn with a focus ring */\n focusedIndex?: number | null;\n}\n\n/** Points of each quadrant, with their indices */\nexport interface QuadrantGroup {\n points: QuadrantPoint[];\n indices: number[];\n}\n\n/** The points of a matrix grouped by quadrant (as seen on screen) */\nexport const quadrantGroups = (\n config: Pick<\n QuadrantConfig,\n \"points\" | \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n): Record<QuadrantCorner, QuadrantGroup> => {\n const groups: Record<QuadrantCorner, QuadrantGroup> = {\n topLeft: { points: [], indices: [] },\n topRight: { points: [], indices: [] },\n bottomLeft: { points: [], indices: [] },\n bottomRight: { points: [], indices: [] },\n };\n config.points.forEach((p, i) => {\n if (!Number.isFinite(p.x) || !Number.isFinite(p.y)) return;\n const g = groups[quadrantOf(config, p.x, p.y)];\n g.points.push(p);\n g.indices.push(i);\n });\n return groups;\n};\n\n/** Built-in texts of the quadrant matrices (accessible point layer) */\nexport interface QuadrantLabels {\n /** Names of the quadrants without a title */\n topLeft: string;\n topRight: string;\n bottomLeft: string;\n bottomRight: string;\n /** Name of a point without a label: `{n}` is its number */\n point: string;\n /** Announced when a point is moved with the keyboard */\n moved: string;\n /** Accessible description of the points that can be moved */\n moveHint: string;\n /** Name of the action moving a point to another quadrant (touch screen readers, mini-programs) */\n moveTo: string;\n}\n\nconst QUADRANT_LABELS: LabelDictionary<QuadrantLabels> = {\n en: {\n topLeft: \"Top left quadrant\",\n topRight: \"Top right quadrant\",\n bottomLeft: \"Bottom left quadrant\",\n bottomRight: \"Bottom right quadrant\",\n point: \"Point {n}\",\n moved: \"{point} moved to {quadrant}\",\n moveHint: \"Shift + arrow keys move it to another quadrant\",\n moveTo: \"Move to {quadrant}\",\n },\n zh: {\n topLeft: \"左上象限\",\n topRight: \"右上象限\",\n bottomLeft: \"左下象限\",\n bottomRight: \"右下象限\",\n point: \"点 {n}\",\n moved: \"{point} 已移到{quadrant}\",\n moveHint: \"Shift + 方向键可移到其他象限\",\n moveTo: \"移到{quadrant}\",\n },\n ja: {\n topLeft: \"左上の象限\",\n topRight: \"右上の象限\",\n bottomLeft: \"左下の象限\",\n bottomRight: \"右下の象限\",\n point: \"点 {n}\",\n moved: \"{point} を{quadrant}に移動しました\",\n moveHint: \"Shift + 矢印キーで別の象限に移動できます\",\n moveTo: \"{quadrant}に移動\",\n },\n fr: {\n topLeft: \"Quadrant en haut à gauche\",\n topRight: \"Quadrant en haut à droite\",\n bottomLeft: \"Quadrant en bas à gauche\",\n bottomRight: \"Quadrant en bas à droite\",\n point: \"Point {n}\",\n moved: \"{point} déplacé vers {quadrant}\",\n moveHint: \"Maj + flèches pour le déplacer vers un autre quadrant\",\n moveTo: \"Déplacer vers {quadrant}\",\n },\n};\n\n/** Built-in texts of the quadrant matrices in a locale (the page language by default) */\nexport const quadrantLabels = (locale?: string): QuadrantLabels =>\n localeLabels(QUADRANT_LABELS, locale);\n\n/** Text of the count of a quadrant (`showCounts`), or `undefined` */\nexport const quadrantCountText = (\n showCounts: QuadrantConfig[\"showCounts\"],\n points: readonly QuadrantPoint[],\n locale?: string,\n): string | undefined =>\n !showCounts\n ? undefined\n : typeof showCounts === \"function\"\n ? showCounts(points.length, points)\n : numberFormat(resolveLocale(locale)).format(points.length);\n\nexport const DEFAULT_QUADRANT_COLORS: Required<Record<QuadrantCorner, string>> =\n {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n };\n\nconst DIVIDER = \"var(--border-strong-color, var(--border-color, #cbd5e1))\";\n\nconst splits = (config: QuadrantConfig) => {\n const [x0, x1] = config.xDomain ?? [0, 10];\n const [y0, y1] = config.yDomain ?? [0, 10];\n return {\n x0,\n x1,\n y0,\n y1,\n xs: config.xSplit ?? (x0 + x1) / 2,\n ys: config.ySplit ?? (y0 + y1) / 2,\n };\n};\n\n/** Quadrant of a data position, as seen on screen */\nexport const quadrantOf = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n x: number,\n y: number,\n): QuadrantCorner => {\n const { xs, ys } = splits(config as QuadrantConfig);\n const right = config.reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n};\n\n/** Center of a quadrant in data coordinates */\nexport const quadrantCenter = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n corner: QuadrantCorner,\n): { x: number; y: number } => {\n const { x0, x1, y0, y1, xs, ys } = splits(config as QuadrantConfig);\n const visualRight = corner.endsWith(\"Right\");\n const dataHigh = config.reverseX ? !visualRight : visualRight;\n return {\n x: dataHigh ? (xs + x1) / 2 : (x0 + xs) / 2,\n y: corner.startsWith(\"top\") ? (ys + y1) / 2 : (y0 + ys) / 2,\n };\n};\n\nconst CORNER_ORDER: readonly QuadrantCorner[] = [\n \"topLeft\",\n \"topRight\",\n \"bottomLeft\",\n \"bottomRight\",\n];\n\n/**\n * Series data of a matrix, kept per `points` array: re-renders passing the\n * same points (hover, focus, selection) keep the same data arrays, so the\n * engine keeps its buffers and the hovered point\n */\nconst quadrantData = new WeakMap<\n readonly QuadrantPoint[],\n Map<string, ChartPointDatum[]>\n>();\nconst cachedData = (\n points: readonly QuadrantPoint[],\n key: string,\n make: () => ChartPointDatum[],\n): ChartPointDatum[] => {\n let byKey = quadrantData.get(points);\n if (!byKey) quadrantData.set(points, (byKey = new Map()));\n let data = byKey.get(key);\n if (!data) {\n if (byKey.size >= 32) byKey.clear();\n byKey.set(key, (data = make()));\n }\n return data;\n};\n\n/** Engine options of a quadrant matrix */\nexport const quadrantChartOptions = (\n config: QuadrantConfig,\n base: Omit<ChartOptions, \"series\"> = {},\n state: QuadrantChartState = {},\n): ChartOptions => {\n const { x0, x1, y0, y1, xs, ys } = splits(config);\n const reverseX = !!config.reverseX;\n const color = (corner: QuadrantCorner) =>\n config.quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner];\n const pointSize = config.pointSize ?? 12;\n const dotColor = (p: QuadrantPoint) =>\n p.color ?? color(quadrantOf(config, p.x, p.y));\n // what the dot colors depend on, and the points themselves (arrays\n // changed in place, e.g. reactive arrays, get new data)\n const colorKey = JSON.stringify([\n x0,\n x1,\n y0,\n y1,\n xs,\n ys,\n reverseX,\n CORNER_ORDER.map(color),\n config.points.map((p) => [p.x, p.y, p.size, p.color, p.label]),\n ]);\n\n const series: ChartSeries[] = [\n {\n type: \"scatter\",\n name: config.name ?? \"\",\n pointSize,\n showLabels: config.showLabels ?? true,\n opacity: 0.9,\n data: cachedData(config.points, colorKey, () =>\n config.points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: dotColor(p),\n })),\n ),\n },\n ];\n // states of the selected and the focused dots, drawn over them (out of\n // hit tests): a soft glow, a ring in the surface color, an outer ring\n const SURFACE = \"var(--surface-color, var(--background-color, #fff))\";\n const ring = (\n id: string,\n indices: readonly number[],\n grow: number,\n look: { color?: string; stroke: number; opacity?: number },\n ): ChartSeries | null => {\n const unique = [...new Set(indices)].filter(\n (i) => Number.isInteger(i) && config.points[i],\n );\n if (!unique.length) return null;\n const data = cachedData(\n config.points,\n `${colorKey}|${id}|${grow}|${look.color ?? \"\"}|${pointSize}|${unique.join(\",\")}`,\n () =>\n unique.map((i) => {\n const p = config.points[i]!;\n return {\n x: p.x,\n y: p.y,\n size: (p.size ?? pointSize) + grow,\n color: look.color ?? dotColor(p),\n };\n }),\n );\n return {\n id,\n type: \"scatter\",\n // unnamed: left out of the accessible name of the chart\n name: \"\",\n tooltip: false,\n opacity: look.opacity ?? 0,\n stroke: look.stroke,\n data,\n };\n };\n const selected = [\n ...(config.selectedIndices ?? []),\n ...(config.selectedIndex !== undefined && config.selectedIndex !== null\n ? [config.selectedIndex]\n : []),\n ];\n const focused =\n state.focusedIndex !== undefined && state.focusedIndex !== null\n ? [state.focusedIndex]\n : [];\n for (const extra of [\n ring(\"quadrant:selected-glow\", selected, 18, { stroke: 0, opacity: 0.16 }),\n ring(\"quadrant:selected\", selected, 3, { color: SURFACE, stroke: 2.5 }),\n ring(\"quadrant:selected-ring\", selected, 10, { stroke: 2 }),\n ring(\"quadrant:focus-gap\", focused, 8, { color: SURFACE, stroke: 3 }),\n ring(\"quadrant:focus\", focused, 14, {\n color: \"var(--focus-ring-color, var(--primary-color, #4f46e5))\",\n stroke: 2.5,\n }),\n ])\n if (extra) series.push(extra);\n\n const groups = config.showCounts ? quadrantGroups(config) : null;\n\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: QuadrantCorner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => {\n const region = config.quadrants?.[corner];\n const detail = groups\n ? quadrantCountText(config.showCounts, groups[corner].points, base.locale)\n : undefined;\n return {\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: color(corner),\n opacity: 0.07,\n label: region?.label,\n labelPosition: position,\n ...(region?.badge ? { badge: region.badge } : {}),\n ...(region?.description ? { description: region.description } : {}),\n ...(detail ? { detail } : {}),\n };\n };\n const ends = config.axisLabels ?? {};\n const visualLeft = reverseX ? x1 : x0;\n const visualRight = reverseX ? x0 : x1;\n const texts: ChartAnnotation[] = [\n ...(ends.top\n ? [{ type: \"text\", x: xs, y: y1, text: ends.top, anchor: \"top\" } as const]\n : []),\n ...(ends.bottom\n ? [\n {\n type: \"text\",\n x: xs,\n y: y0,\n text: ends.bottom,\n anchor: \"bottom\",\n } as const,\n ]\n : []),\n ...(ends.left\n ? [\n {\n type: \"text\",\n x: visualLeft,\n y: ys,\n text: ends.left,\n anchor: \"left\",\n } as const,\n ]\n : []),\n ...(ends.right\n ? [\n {\n type: \"text\",\n x: visualRight,\n y: ys,\n text: ends.right,\n anchor: \"right\",\n } as const,\n ]\n : []),\n ];\n\n const annotations: ChartAnnotation[] = [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n { type: \"line\", axis: \"x\", value: xs, dash: [], color: DIVIDER },\n { type: \"line\", axis: \"y\", value: ys, dash: [], color: DIVIDER },\n ...texts,\n ...(base.annotations ?? []),\n ];\n\n const showTicks = config.showTicks ?? true;\n const interaction: boolean | ChartInteractionOptions =\n base.interaction === false\n ? false\n : {\n zoom: false,\n ...(typeof base.interaction === \"object\" ? base.interaction : {}),\n ...(config.draggable ? { dragPoints: true, dropTargets: true } : {}),\n };\n\n return {\n ...base,\n series,\n annotations,\n tooltip:\n base.tooltip ??\n (showTicks\n ? undefined\n : {\n render: (event) => {\n const item = event.items[0];\n if (!item) return null;\n const region =\n config.quadrants?.[quadrantOf(config, item.x, item.y)]?.label;\n return [item.label ?? config.name ?? \"\", region ?? \"\"]\n .filter(Boolean)\n .join(\"\\n\");\n },\n }),\n xAxis: {\n min: x0,\n max: x1,\n title: config.xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.xLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n yAxis: {\n min: y0,\n max: y1,\n title: config.yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.yLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n legend: base.legend ?? false,\n padding:\n base.padding ??\n (showTicks ? undefined : { top: 4, right: 4, bottom: 4, left: 4 }),\n interaction,\n };\n};\n\n// ------------------------------------------------------------- statistics\n\n/** Finite values of a list, as a sorted typed array */\nconst sortedFinite = (values: ArrayLike<number>): Float64Array => {\n let n = 0;\n for (let i = 0; i < values.length; i++) if (Number.isFinite(values[i])) n++;\n const out = new Float64Array(n);\n let k = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (Number.isFinite(v)) out[k++] = v;\n }\n return out.sort();\n};\n\n/** Quantile `p` (0-1) of sorted values, linearly interpolated (NumPy / Excel) */\nconst quantileOf = (sorted: ArrayLike<number>, p: number): number => {\n const n = sorted.length;\n if (!n) return NaN;\n const at = Math.min(1, Math.max(0, p)) * (n - 1);\n const lo = Math.floor(at);\n const hi = Math.min(n - 1, lo + 1);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (at - lo);\n};\n\n/**\n * Quantiles of values (`[0.5, 0.95, 0.99]` gives the median, p95 and p99),\n * linearly interpolated like NumPy and Excel; non-finite values are ignored\n */\nexport const quantiles = (\n values: ArrayLike<number>,\n ps: readonly number[],\n): number[] => {\n const sorted = sortedFinite(values);\n return ps.map((p) => quantileOf(sorted, p));\n};\n\n/** How the bins of a histogram are chosen: a count, or a rule */\nexport type HistogramBinning =\n number | \"auto\" | \"sturges\" | \"freedman-diaconis\";\n\n/** Options of `binValues` */\nexport interface BinOptions {\n /**\n * Number of bins, or the rule choosing it: `sturges` (log2 n + 1, for\n * small normal-ish samples), `freedman-diaconis` (bin width from the\n * interquartile range, robust to outliers); `auto` uses Freedman-Diaconis\n * and Sturges when the spread is zero\n * @default \"auto\"\n */\n bins?: HistogramBinning;\n /** Range covered by the bins (values outside are not counted); the data range by default */\n domain?: readonly [number, number];\n /**\n * Rounds the bin width to 1, 2 or 5 × 10^k and aligns the edges on it\n * @default true\n */\n nice?: boolean;\n}\n\n/** Bins of a histogram */\nexport interface HistogramBins {\n /** Edges of the bins: one more than the bins */\n edges: number[];\n /** Number of values in every bin */\n counts: number[];\n /** Width of a bin */\n width: number;\n /** Number of values counted (finite, inside the domain) */\n total: number;\n}\n\n/** At most this many values are sorted to estimate the spread (Freedman-Diaconis) */\nconst SPREAD_SAMPLE = 100_000;\n\n/**\n * Counts values into bins of equal width: linear in the number of values\n * (a million samples take a few milliseconds; the spread of large samples\n * is estimated on an even subsample)\n */\nexport const binValues = (\n values: ArrayLike<number>,\n options: BinOptions = {},\n): HistogramBins => {\n let n = 0;\n let min = Infinity;\n let max = -Infinity;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!Number.isFinite(v)) continue;\n n++;\n if (v < min) min = v;\n if (v > max) max = v;\n }\n let [lo, hi] = options.domain ?? [min, max];\n if (!n || !Number.isFinite(lo) || !Number.isFinite(hi)) {\n return { edges: [0, 1], counts: [0], width: 1, total: 0 };\n }\n if (lo > hi) [lo, hi] = [hi, lo];\n if (hi === lo) {\n lo -= 0.5;\n hi += 0.5;\n }\n const span = hi - lo;\n const rule = options.bins ?? \"auto\";\n const sturges = Math.ceil(Math.log2(n)) + 1;\n let count: number;\n if (typeof rule === \"number\") {\n count = Math.round(rule);\n } else if (rule === \"sturges\") {\n count = sturges;\n } else {\n // Freedman-Diaconis: width = 2 IQR / n^(1/3)\n const stride = Math.max(1, Math.floor(values.length / SPREAD_SAMPLE));\n const sample: number[] = [];\n for (let i = 0; i < values.length; i += stride) {\n const v = values[i];\n if (Number.isFinite(v)) sample.push(v);\n }\n const sorted = Float64Array.from(sample).sort();\n const iqr = quantileOf(sorted, 0.75) - quantileOf(sorted, 0.25);\n const width = (2 * iqr) / Math.cbrt(n);\n count = width > 0 ? Math.ceil(span / width) : sturges;\n }\n count = Math.max(1, Math.min(1000, count || 1));\n let width = span / count;\n let start = lo;\n if (options.nice ?? true) {\n width = tickStep(lo, hi, count) || width;\n start = Math.floor(lo / width + 1e-9) * width;\n count = Math.max(1, Math.ceil((hi - start) / width - 1e-9));\n }\n const end = start + count * width;\n const counts = new Array<number>(count).fill(0);\n let total = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!(v >= start && v <= end)) continue;\n // the last bin includes its right edge\n const k = Math.min(count - 1, Math.floor((v - start) / width));\n counts[k]++;\n total++;\n }\n const edges: number[] = [];\n for (let k = 0; k <= count; k++)\n edges.push(Number((start + k * width).toPrecision(12)));\n return { edges, counts, width, total };\n};\n\n/** Options of `histogramSeries` */\nexport interface HistogramSeriesOptions extends BinOptions {\n /** Name of the series (legend, tooltip) */\n name?: string;\n /** Bar color (any CSS color) */\n color?: string;\n /** Formats the edges of the bins in the tooltip */\n format?: (value: number) => string;\n /** Bins already computed (`binValues`): `values` are then ignored */\n binned?: HistogramBins;\n /**\n * Locale of the default name and of the bin edges\n * @default the page language\n */\n locale?: string;\n}\n\n/** Bar series of a histogram: one touching bar per bin, labelled with its range */\nexport const histogramSeries = (\n values: ArrayLike<number>,\n options: HistogramSeriesOptions = {},\n): ChartSeries => {\n const bins = options.binned ?? binValues(values, options);\n const locale = resolveLocale(options.locale);\n const format =\n options.format ?? ((value: number) => formatEdge(value, locale));\n return {\n id: \"histogram\",\n name: options.name ?? presetLabels(locale).count,\n type: \"bar\",\n color: options.color,\n barWidth: 1,\n radius: 1,\n data: bins.counts.map((count, k) => {\n const a = bins.edges[k] ?? 0;\n const b = bins.edges[k + 1] ?? a;\n return {\n x: (a + b) / 2,\n y: count,\n label: `${format(a)} – ${format(b)}`,\n };\n }),\n };\n};\n\nconst formatEdge = (value: number, locale: string) =>\n numberFormat(locale, { maximumSignificantDigits: 6 }).format(value);\n\n/** Options of `boxplotStats` */\nexport interface BoxplotStatsOptions {\n /**\n * Reach of the whiskers in interquartile ranges beyond the box (Tukey:\n * 1.5); `\"minmax\"` extends them to the extremes (no outliers)\n * @default 1.5\n */\n whisker?: number | \"minmax\";\n}\n\n/** Five-number summary of a sample, with the outliers */\nexport interface BoxplotStats {\n /** Lower whisker: the smallest value within reach */\n low: number;\n /** First quartile */\n q1: number;\n median: number;\n /** Third quartile */\n q3: number;\n /** Upper whisker: the largest value within reach */\n high: number;\n /** Values beyond the whiskers */\n outliers: number[];\n min: number;\n max: number;\n mean: number;\n /** Number of finite values */\n count: number;\n}\n\n/** Quartiles, whiskers (Tukey's 1.5 IQR by default) and outliers of raw values */\nexport const boxplotStats = (\n values: ArrayLike<number>,\n options: BoxplotStatsOptions = {},\n): BoxplotStats => {\n const sorted = sortedFinite(values);\n const n = sorted.length;\n if (!n) {\n return {\n low: NaN,\n q1: NaN,\n median: NaN,\n q3: NaN,\n high: NaN,\n outliers: [],\n min: NaN,\n max: NaN,\n mean: NaN,\n count: 0,\n };\n }\n const q1 = quantileOf(sorted, 0.25);\n const median = quantileOf(sorted, 0.5);\n const q3 = quantileOf(sorted, 0.75);\n const min = sorted[0];\n const max = sorted[n - 1];\n let sum = 0;\n for (let i = 0; i < n; i++) sum += sorted[i];\n const whisker = options.whisker ?? 1.5;\n let low = min;\n let high = max;\n const outliers: number[] = [];\n if (whisker !== \"minmax\") {\n const reach = (q3 - q1) * whisker;\n const from = q1 - reach;\n const to = q3 + reach;\n let i = 0;\n while (i < n && sorted[i] < from) outliers.push(sorted[i++]);\n low = i < n ? sorted[i] : q1;\n let j = n - 1;\n const upper: number[] = [];\n while (j >= 0 && sorted[j] > to) upper.push(sorted[j--]);\n high = j >= 0 ? sorted[j] : q3;\n outliers.push(...upper.reverse());\n }\n return {\n low: Math.min(low, q1),\n q1,\n median,\n q3,\n high: Math.max(high, q3),\n outliers,\n min,\n max,\n mean: sum / n,\n count: n,\n };\n};\n\n/** A sample of a box plot */\nexport interface BoxplotGroup {\n /** Category (or position) of the box */\n x: ChartXValue;\n /** Raw values: their quartiles, whiskers and outliers are computed */\n values: ArrayLike<number>;\n /** Color of the box (any CSS color) */\n color?: string;\n}\n\n/** Box plot data of raw samples (one datum per group) */\nexport const boxplotData = (\n groups: readonly BoxplotGroup[],\n options: BoxplotStatsOptions = {},\n): ChartPointDatum[] =>\n groups.map((g) => {\n const s = boxplotStats(g.values, options);\n return {\n x: g.x,\n y: Number.isFinite(s.median) ? s.median : null,\n low: s.low,\n q1: s.q1,\n q3: s.q3,\n high: s.high,\n outliers: s.outliers,\n ...(g.color ? { color: g.color } : {}),\n };\n });\n\n/** Series of a BoxPlotChart */\nexport const boxplotSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"boxplot\");\n\n// ---------------------------------------------------------------- waterfall\n\n/** A bar of a waterfall chart */\nexport interface WaterfallStep {\n /** Category name of the bar */\n label: string;\n /** Change (positive or negative); ignored by totals */\n value?: number;\n /**\n * `subtotal` and `total` bars show the running total, from zero\n * @default \"change\"\n */\n kind?: \"change\" | \"subtotal\" | \"total\";\n /** Color of this bar (any CSS color) */\n color?: string;\n}\n\n/** Options of `waterfallSeries` */\nexport interface WaterfallOptions {\n /** Name of the series (tooltip) */\n name?: string;\n /** Color of the increases @default the success color */\n upColor?: string;\n /** Color of the decreases @default the danger color */\n downColor?: string;\n /** Color of the totals and subtotals @default the primary color */\n totalColor?: string;\n /**\n * Value the first change starts from\n * @default 0\n */\n start?: number;\n /**\n * Writes the change (or the total) at the end of every bar\n * @default false\n */\n labels?: boolean;\n /** Formats the values (labels, tooltip) */\n format?: (value: number) => string;\n /**\n * Thin lines from the end of every bar to the next one; an object styles\n * them\n * @default true (dashed, secondary text color)\n */\n connector?: boolean | ChartConnectorOptions;\n /**\n * Locale of the default name\n * @default the page language\n */\n locale?: string;\n}\n\n/**\n * Floating bar series of a waterfall (bridge) chart: every change starts\n * where the previous one ended; totals and subtotals start from zero\n */\nexport const waterfallSeries = (\n steps: readonly WaterfallStep[],\n options: WaterfallOptions = {},\n): ChartSeries => {\n const up = options.upColor ?? \"var(--success-color, #16a34a)\";\n const down = options.downColor ?? \"var(--danger-color, #dc2626)\";\n const total = options.totalColor ?? \"var(--primary-color, #4f46e5)\";\n let running = options.start ?? 0;\n const data: ChartPointDatum[] = steps.map((step) => {\n if (step.kind === \"total\" || step.kind === \"subtotal\") {\n return { x: step.label, y: running, color: step.color ?? total };\n }\n const value = step.value ?? 0;\n const from = running;\n running += value;\n return {\n x: step.label,\n y0: from,\n y: running,\n color: step.color ?? (value >= 0 ? up : down),\n };\n });\n return {\n id: \"waterfall\",\n name: options.name ?? presetLabels(options.locale).change,\n type: \"bar\",\n color: total,\n data,\n showLabels: options.labels ?? false,\n format: options.format,\n connector: options.connector ?? true,\n };\n};\n\n// ------------------------------------------------------------------ bubbles\n\n/** Options of `bubbleSeries` */\nexport interface BubbleOptions {\n /**\n * Diameter in pixels of the smallest bubbles\n * @default 6\n */\n minSize?: number;\n /**\n * Diameter in pixels of the largest value\n * @default 48\n */\n maxSize?: number;\n /** Value drawn with `maxSize` (share a scale between charts); the largest value by default */\n maxValue?: number;\n}\n\n/**\n * Scatter series whose dots are sized by the `value` of their points: the\n * area of a bubble is proportional to its value (diameter ∝ √value), the\n * scale is shared by every series. Points are drawn from the largest to\n * the smallest, so small bubbles stay on top (hover indexes refer to that\n * order).\n */\nexport const bubbleSeries = (\n series: readonly ChartSeries[],\n options: BubbleOptions = {},\n): ChartSeries[] => {\n const minSize = options.minSize ?? 6;\n const maxSize = options.maxSize ?? 48;\n const valuesOf = (data: ChartSeries[\"data\"]): ArrayLike<number> | null => {\n if (typeof data !== \"object\" || data === null) return null;\n if (!(\"length\" in data)) {\n const v = (data as { value?: ArrayLike<number> }).value;\n return v ?? null;\n }\n const list = data as ArrayLike<unknown>;\n const out = new Float64Array(list.length).fill(NaN);\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const v = (item as { value?: unknown }).value;\n if (typeof v === \"number\") out[i] = v;\n }\n }\n return out;\n };\n let top = options.maxValue ?? 0;\n if (options.maxValue === undefined) {\n for (const s of series) {\n const values = valuesOf(s.data);\n if (!values) continue;\n for (let i = 0; i < values.length; i++) {\n const v = Math.abs(values[i]);\n if (v > top) top = v;\n }\n }\n }\n const sizeOf = (v: number) =>\n Number.isFinite(v) && top > 0\n ? Math.max(minSize, maxSize * Math.sqrt(Math.min(1, Math.abs(v) / top)))\n : minSize;\n return series.map((s) => {\n const base: ChartSeries = {\n ...s,\n type: s.type ?? \"scatter\",\n opacity: s.opacity ?? 0.68,\n };\n if (base.type !== \"scatter\") return base;\n const data = s.data;\n if (typeof data === \"object\" && data !== null && !(\"length\" in data)) {\n const values = (data as { value?: ArrayLike<number> }).value;\n if (!values) return base;\n const size = new Float32Array(values.length);\n for (let i = 0; i < values.length; i++) size[i] = sizeOf(values[i]);\n return { ...base, data: { ...data, size } };\n }\n const list = data as ArrayLike<unknown>;\n const points: ChartPointDatum[] = [];\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (!item || typeof item !== \"object\" || Array.isArray(item)) continue;\n const d = item as ChartPointDatum;\n points.push({\n ...d,\n size: d.size ?? sizeOf(typeof d.value === \"number\" ? d.value : NaN),\n });\n }\n points.sort((a, b) => (b.size ?? 0) - (a.size ?? 0));\n return { ...base, data: points };\n });\n};\n\n// -------------------------------------------------------------------- gantt\n\n/** A task (or milestone) of a Gantt chart */\nexport interface GanttTask {\n /** Name of the task (tooltip title; the row name when there is no `row`) */\n name: string;\n /**\n * Identifier referenced by the `dependencies` of other tasks; the `name`\n * by default (give ids when several tasks have the same name)\n */\n id?: string;\n /**\n * Row of the task: several tasks can share one (a resource, a lane); the\n * `name` by default, one row per task\n */\n row?: string;\n /** Start (a timestamp or a date) */\n start: number | Date;\n /** End; omitted for milestones */\n end?: number | Date;\n /** Share done, 0-1: drawn as a solid bar over the task */\n progress?: number;\n /** Group (phase, team): a color and a legend entry per group */\n group?: string;\n /** Color of the task (any CSS color); the color of its group by default */\n color?: string;\n /** Draws a dot at `start` instead of a bar */\n milestone?: boolean;\n /**\n * Tasks this one waits for, by `id` (or `name`): tooltip, and arrows from\n * their ends to its start\n */\n dependencies?: readonly string[];\n}\n\n/** Options of `ganttSeries` */\nexport interface GanttOptions {\n /** Colors of the groups in order of appearance (any CSS colors); the chart palette by default */\n colors?: readonly string[];\n /**\n * Name of the tasks without a group\n * @default \"Tasks\" (in the `locale`)\n */\n taskName?: string;\n /**\n * Name of the progress bars (legend, tooltip)\n * @default \"Progress\" (in the `locale`)\n */\n progressName?: string;\n /**\n * Name of the milestones (legend, tooltip)\n * @default \"Milestones\" (in the `locale`)\n */\n milestoneName?: string;\n /** Formats the progress shares (tooltip) @default \"60%\" */\n formatProgress?: (share: number) => string;\n /**\n * Name of the dependencies row of the tooltip\n * @default \"Depends on\" (in the `locale`)\n */\n dependenciesName?: string;\n /**\n * Draws the dependencies as elbow arrows from the end of every\n * predecessor to the start of the task\n * @default true\n */\n dependencyArrows?: boolean;\n /** Color of the dependency arrows (any CSS color); the secondary text color by default */\n dependencyColor?: string;\n /**\n * Writes the name of every task inside its bar (cut with an ellipsis,\n * in a color contrasting with the bar; skipped when the bar is too\n * small): `\"auto\"` when several tasks share a row (`row`), so the bars\n * of a lane can be told apart without hovering; `true` / `\"inside\"`\n * always, `false` never\n * @default \"auto\"\n */\n barLabels?: boolean | \"inside\" | \"auto\";\n /**\n * Locale of the default names and of the progress shares\n * @default the page language\n */\n locale?: string;\n}\n\n/** Series of a Gantt chart and the row names in order */\nexport interface GanttSeries {\n series: ChartSeries[];\n /** Rows from top to bottom (the `categories` of the x axis) */\n categories: string[];\n /** Time range of the tasks with a small margin (the `min` / `max` of the value axis) */\n domain: [number, number];\n /** Arrows of the dependencies between existing tasks (the `dependencies` of the chart) */\n dependencies: ChartDependency[];\n}\n\nconst THEMED = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n];\nconst FALLBACK = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\n/** Color `k` of the chart palette as a CSS color (theme variables first) */\nexport const paletteColor = (k: number): string => {\n const i = k % 8;\n const fallback = FALLBACK[i] ?? \"#4f46e5\";\n const themed = THEMED[i];\n return themed\n ? `var(--chart-series-${i + 1}, var(${themed}, ${fallback}))`\n : `var(--chart-series-${i + 1}, ${fallback})`;\n};\n\nconst time = (v: number | Date | undefined) =>\n v instanceof Date ? v.getTime() : v === undefined ? NaN : v;\n\nconst HOUR_MS = 3_600_000;\nconst DAY_MS = 24 * HOUR_MS;\n/** Opacity of the Gantt tasks without a `progress` (near-solid) */\nconst SOLID_TASK = 0.9;\n\n/** Local time rounded down to a multiple of `step` minutes (15 or 60) */\nconst floorMinutes = (v: number, step: number): number => {\n const d = new Date(v);\n d.setMinutes(d.getMinutes() - (d.getMinutes() % step), 0, 0);\n return d.getTime();\n};\n\n/** Local time rounded up to a multiple of `step` minutes (15 or 60) */\nconst ceilMinutes = (v: number, step: number): number => {\n const floor = floorMinutes(v, step);\n if (floor >= v) return floor;\n const d = new Date(floor);\n d.setMinutes(d.getMinutes() + step);\n return d.getTime();\n};\n\n/**\n * Floating bar series of a Gantt chart (horizontal, on a time axis): a\n * translucent bar per task with its progress drawn over it, one series per\n * group, and the milestones as dots\n */\nexport const ganttSeries = (\n tasks: readonly GanttTask[],\n options: GanttOptions = {},\n): GanttSeries => {\n const locale = resolveLocale(options.locale);\n const names = presetLabels(locale);\n const rows = chartLabels(locale);\n const taskName = options.taskName ?? names.tasks;\n const progressName = options.progressName ?? names.progress;\n const separator = /^(zh|ja)\\b/i.test(locale) ? \"、\" : \", \";\n const idOf = (t: GanttTask) => t.id ?? t.name;\n const rowOf = (t: GanttTask) => t.row ?? t.name;\n const bars = tasks.filter((t) => !t.milestone);\n const barLabels = options.barLabels ?? \"auto\";\n const labelled =\n barLabels === \"auto\"\n ? new Set(bars.map(rowOf)).size < bars.length\n : !!barLabels;\n // tasks by id, then by name (the first one wins)\n const byKey = new Map<string, GanttTask>();\n for (const t of tasks) if (!byKey.has(idOf(t))) byKey.set(idOf(t), t);\n for (const t of tasks) if (!byKey.has(t.name)) byKey.set(t.name, t);\n // tasks in a shared row: their name is the title of the tooltip (and the\n // text inside their bar)\n const point = (t: GanttTask, named = false) => ({\n x: rowOf(t),\n id: idOf(t),\n ...(named || rowOf(t) !== t.name ? { label: t.name } : {}),\n });\n const groups: string[] = [];\n for (const t of tasks) {\n const g = t.group ?? taskName;\n if (!t.milestone && !groups.includes(g)) groups.push(g);\n }\n const colorOf = (g: string) => {\n const k = Math.max(0, groups.indexOf(g));\n return options.colors?.[k] ?? paletteColor(k);\n };\n const formatProgress =\n options.formatProgress ??\n ((share: number) =>\n numberFormat(locale, {\n style: \"percent\",\n maximumFractionDigits: 0,\n }).format(share));\n // translucent bars under the progress of their task, solid ones otherwise\n const series: ChartSeries[] = groups.map((g) => ({\n id: `gantt:${g}`,\n name: g,\n type: \"bar\",\n stack: \"gantt\",\n color: colorOf(g),\n opacity: 0.3,\n barWidth: 0.62,\n radius: 4,\n ...(labelled ? { showLabels: \"inside\" as const } : {}),\n data: bars\n .filter((t) => (t.group ?? taskName) === g)\n .map((t) => {\n // the tooltip of a task: its progress and what it waits for\n const details: ChartTooltipDetail[] = [];\n if (t.progress !== undefined)\n details.push({\n name: progressName,\n value: formatProgress(Math.min(1, Math.max(0, t.progress))),\n });\n if (t.dependencies?.length)\n details.push({\n name: options.dependenciesName ?? rows.dependencies,\n value: t.dependencies\n .map((k) => byKey.get(k)?.name ?? k)\n .join(separator),\n });\n return {\n ...point(t, labelled),\n y0: time(t.start),\n y: time(t.end ?? t.start),\n ...(t.color ? { color: t.color } : {}),\n ...(t.progress === undefined ? { opacity: SOLID_TASK } : {}),\n ...(details.length ? { details } : {}),\n };\n }),\n }));\n const progress = tasks.filter(\n (t) => !t.milestone && t.progress !== undefined && t.progress > 0,\n );\n if (progress.length) {\n series.push({\n id: \"gantt:progress\",\n name: progressName,\n type: \"bar\",\n stack: \"gantt\",\n // shown in the tooltip of its task\n tooltip: false,\n // every bar has the color of its task: a neutral legend swatch\n color: \"var(--text-secondary-color, #6b7280)\",\n radius: 4,\n data: progress.map((t) => {\n const start = time(t.start);\n const end = time(t.end ?? t.start);\n const share = Math.min(1, Math.max(0, t.progress ?? 0));\n return {\n x: rowOf(t),\n y0: start,\n y: start + (end - start) * share,\n label: formatProgress(share),\n color: t.color ?? colorOf(t.group ?? taskName),\n };\n }),\n });\n }\n const milestones = tasks.filter((t) => t.milestone);\n if (milestones.length) {\n series.push({\n id: \"gantt:milestones\",\n name: options.milestoneName ?? names.milestones,\n type: \"scatter\",\n color: \"var(--text-color, #1f2937)\",\n pointSize: 13,\n opacity: 1,\n data: milestones.map((t) => ({\n ...point(t),\n y: time(t.start),\n ...(t.color ? { color: t.color } : {}),\n })),\n });\n }\n let lo = Infinity;\n let hi = -Infinity;\n for (const t of tasks) {\n for (const v of [time(t.start), time(t.end ?? t.start)]) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n }\n // room for the milestone dots at the ends\n const pad = Number.isFinite(hi - lo) ? Math.max((hi - lo) * 0.025, 1) : 0;\n let domain: [number, number] = Number.isFinite(lo)\n ? [lo - pad, hi + pad]\n : [0, 1];\n // schedules of a day or two: whole hours (quarter hours under 3 hours) at\n // the ends, so the first and last ticks are the edges (08:00 – 22:00);\n // only for real dates (plain numbers such as days or weeks keep the margin)\n const span = hi - lo;\n const dates = lo >= 1e11 || tasks.some((t) => t.start instanceof Date);\n if (dates && span >= 60_000 && span <= 2 * DAY_MS) {\n const step = span <= 3 * HOUR_MS ? 15 : 60;\n const near = (v: number) =>\n milestones.some((t) => Math.abs(time(t.start) - v) < pad);\n domain = [\n floorMinutes(lo - (near(lo) ? pad : 0), step),\n ceilMinutes(hi + (near(hi) ? pad : 0), step),\n ];\n }\n const dependencies: ChartDependency[] = [];\n if (options.dependencyArrows !== false) {\n for (const t of tasks) {\n for (const key of t.dependencies ?? []) {\n const from = byKey.get(key);\n if (!from || from === t) continue;\n dependencies.push({\n from: idOf(from),\n to: idOf(t),\n ...(options.dependencyColor\n ? { color: options.dependencyColor }\n : {}),\n });\n }\n }\n }\n return {\n series,\n categories: [...new Set(tasks.map(rowOf))],\n domain,\n dependencies,\n };\n};\n\n// -------------------------------------------------------------- range areas\n\n/** Series of a RangeAreaChart: bands between `y0` and `y` (thin edges) */\nexport const rangeAreaSeries = (\n series: readonly ChartSeries[],\n curve?: ChartCurve,\n) =>\n withSeriesType(series, \"area\", undefined, curve).map((s) =>\n s.type === \"area\" ? { ...s, lineWidth: s.lineWidth ?? 1.5 } : s,\n );\n"],"mappings":";;;;AAsCA,IAAMA,IAA+C;CACnD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;EACV,YAAY;CACd;CACA,IAAI;EACF,OAAO;EACP,QAAQ;E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,CAAG;EAC1D,IAAS,CACPxB,EAAarE,KAAM+F,EAAK/F,CAAE,IAAI6F,IAAM,IAAI3C,CAAI,GAC5CoB,EAAYrE,KAAM8F,EAAK9F,CAAE,IAAI4F,IAAM,IAAI3C,CAAI,CAC7C;CACF;CACA,IAAM8C,IAAkC,CAAC;CACzC,IAAIxF,EAAQ,qBAAqB,IAC/B,KAAK,IAAM,KAAK0E,GACd,KAAK,IAAM9H,KAAO,EAAE,gBAAgB,CAAC,GAAG;EACtC,IAAMmF,IAAOrF,EAAM,IAAIE,CAAG;EAC1B,AAAKmF,KAAQA,MAAS,KACtByD,EAAa,KAAK;GAChB,MAAMjB,EAAKxC,CAAI;GACf,IAAIwC,EAAK,CAAC;GACV,GAAIvE,EAAQ,kBACR,EAAE,OAAOA,EAAQ,gBAAgB,IACjC,CAAC;EACP,CAAC;CACH;CAGJ,OAAO;EACL;EACA,YAAY,CAAC,GAAG,IAAI,IAAI0E,EAAM,IAAIF,CAAK,CAAC,CAAC;EACzC;EACA;CACF;AACF,GAKaiB,KACX,GACA,MAEArM,EAAeC,GAAQ,QAAQ,KAAA,GAAWK,CAAK,CAAC,CAAC,KAAK,MACpDH,EAAE,SAAS,SAAS;CAAE,GAAGA;CAAG,WAAWA,EAAE,aAAa;AAAI,IAAIA,CAChE"}
|
|
1
|
+
{"version":3,"file":"presets.js","names":["PRESET_LABELS","presetLabels","localeLabels","locale","withSeriesType","series","t","s","type","stack","curve","lineSeries","area","extra","areaSeries","barSeries","stacked","labels","scatterSeries","candlestickSeries","heatmapChartOptions","numericX","config","c","numericY","base","sparklineOptions","quadrantGroups","groups","p","g","quadrantOf","i","QUADRANT_LABELS","quadrantLabels","quadrantCountText","showCounts","points","numberFormat","resolveLocale","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","y0","y1","right","x","xs","y","ys","quadrantCenter","visualRight","corner","CORNER_ORDER","quadrantData","cachedData","byKey","data","key","make","quadrantChartOptions","reverseX","color","pointSize","dotColor","colorKey","SURFACE","ring","unique","indices","id","grow","look","selected","focused","state","left","rect","xa","xb","ya","yb","region","detail","position","ends","visualLeft","texts","annotations","showTicks","interaction","item","event","sortedFinite","n","values","out","k","v","quantileOf","sorted","at","lo","hi","quantiles","ps","SPREAD_SAMPLE","binValues","min","max","options","span","rule","sturges","count","stride","sample","width","start","tickStep","end","counts","total","edges","histogramSeries","bins","format","formatEdge","value","a","b","boxplotStats","q1","median","q3","sum","whisker","low","high","outliers","reach","from","to","j","upper","boxplotData","boxplotSeries","waterfallSeries","up","down","running","steps","step","bubbleSeries","minSize","maxSize","valuesOf","list","top","sizeOf","size","d","THEMED","FALLBACK","paletteColor","fallback","themed","time","HOUR_MS","DAY_MS","SOLID_TASK","floorMinutes","ceilMinutes","floor","ganttSeries","names","rows","chartLabels","taskName","progressName","separator","idOf","rowOf","bars","tasks","barLabels","labelled","point","named","colorOf","formatProgress","share","details","progress","milestones","pad","domain","near","dependencies","rangeAreaSeries"],"sources":["../../../../charts/src/engine/presets.ts"],"sourcesContent":["// Option presets of the chart components, shared by every platform (React,\n// mini-programs, React Native): they turn component props into engine\n// options.\n\nimport {\n localeLabels,\n numberFormat,\n resolveLocale,\n type LabelDictionary,\n} from \"./locale\";\nimport { chartLabels } from \"./labels\";\nimport { tickStep } from \"./scale\";\nimport type {\n ChartAnnotation,\n ChartColorScheme,\n ChartConnectorOptions,\n ChartCurve,\n ChartDependency,\n ChartInteractionOptions,\n ChartOptions,\n ChartPointDatum,\n ChartSeries,\n ChartSeriesType,\n ChartTooltipDetail,\n ChartXValue,\n} from \"./types\";\n\n/** Default series names of the presets */\ninterface PresetLabels {\n value: string;\n values: string;\n count: string;\n change: string;\n tasks: string;\n progress: string;\n milestones: string;\n}\n\nconst PRESET_LABELS: LabelDictionary<PresetLabels> = {\n en: {\n value: \"Value\",\n values: \"Values\",\n count: \"Count\",\n change: \"Change\",\n tasks: \"Tasks\",\n progress: \"Progress\",\n milestones: \"Milestones\",\n },\n zh: {\n value: \"数值\",\n values: \"数值\",\n count: \"数量\",\n change: \"变化\",\n tasks: \"任务\",\n progress: \"进度\",\n milestones: \"里程碑\",\n },\n ja: {\n value: \"値\",\n values: \"値\",\n count: \"件数\",\n change: \"増減\",\n tasks: \"タスク\",\n progress: \"進捗\",\n milestones: \"マイルストーン\",\n },\n fr: {\n value: \"Valeur\",\n values: \"Valeurs\",\n count: \"Effectif\",\n change: \"Variation\",\n tasks: \"Tâches\",\n progress: \"Avancement\",\n milestones: \"Jalons\",\n },\n};\n\n/** Default series names of the presets in a locale (the page language by default) */\nexport const presetLabels = (locale?: string): PresetLabels =>\n localeLabels(PRESET_LABELS, locale);\n\n/** Gives the series without a `type` the type of the component */\nexport const withSeriesType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n curve?: ChartCurve,\n): ChartSeries[] =>\n series.map((s) => {\n const t = s.type ?? type;\n return {\n ...s,\n type: t,\n ...(stack !== undefined && t === type ? { stack: s.stack ?? stack } : {}),\n ...(curve !== undefined && (t === \"line\" || t === \"area\")\n ? { curve: s.curve ?? curve }\n : {}),\n };\n });\n\n/** Options of the line-like components */\nexport interface LineSeriesOptions {\n /** Stacks the series on top of each other */\n stacked?: boolean;\n /** Shape of the lines */\n curve?: ChartCurve;\n}\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (\n series: readonly ChartSeries[],\n area = false,\n extra: LineSeriesOptions = {},\n) =>\n withSeriesType(\n series,\n area ? \"area\" : \"line\",\n extra.stacked ? \"stack\" : undefined,\n extra.curve,\n );\n\n/** Series of an AreaChart */\nexport const areaSeries = (\n series: readonly ChartSeries[],\n extra: LineSeriesOptions = {},\n) => lineSeries(series, true, extra);\n\n/** Series of a BarChart (`stacked` stacks them, `labels` shows the values) */\nexport const barSeries = (\n series: readonly ChartSeries[],\n stacked = false,\n labels = false,\n) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined).map((s) =>\n labels && s.type === \"bar\" ? { ...s, showLabels: s.showLabels ?? true } : s,\n );\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\n\n/** Series of a CandlestickChart */\nexport const candlestickSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"candlestick\");\n\n/** A cell of a HeatmapChart */\nexport interface HeatmapCell {\n /** Column: a category name (or a number on a numeric axis) */\n x: string | number;\n /** Row: a category name (or a number on a numeric axis) */\n y: string | number;\n /** Value mapped to the color scale; `null` leaves the cell empty */\n value: number | null;\n}\n\n/** Settings of a heatmap (the props of HeatmapChart) */\nexport interface HeatmapConfig {\n /** Cells */\n data: readonly HeatmapCell[];\n /** Column names in order (collected from the data when omitted) */\n xCategories?: readonly string[];\n /** Row names from bottom to top (collected from the data when omitted) */\n yCategories?: readonly string[];\n /**\n * Colors from the lowest to the highest value (interpolated in OKLab), or\n * a built-in theme-aware ramp of the first palette color\n * @default \"sequential\"\n */\n colorScale?: readonly string[] | ChartColorScheme;\n /** Values at the ends of the color scale; the data range by default */\n valueRange?: readonly [number, number];\n /**\n * Value at the middle of the color scale (diverging data)\n * @default 0 for `diverging` ramps spanning it, else the middle of the range\n */\n colorMidpoint?: number;\n /** Name of the value in the tooltip */\n name?: string;\n /** Corner radius of the cells, in pixels */\n radius?: number;\n /** Formats the values in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a heatmap */\nexport const heatmapChartOptions = (\n config: HeatmapConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const numericX = config.data.some((c) => typeof c.x === \"number\");\n const numericY = config.data.some((c) => typeof c.y === \"number\");\n return {\n ...base,\n series: [\n {\n id: \"heatmap\",\n name: config.name ?? presetLabels(base.locale).value,\n type: \"heatmap\",\n data: config.data.map((c) => ({ x: c.x, y: c.y, value: c.value })),\n colorScale: config.colorScale,\n valueRange: config.valueRange,\n colorMidpoint: config.colorMidpoint,\n radius: config.radius,\n format: config.format,\n },\n ],\n xAxis: {\n ...(numericX\n ? {}\n : { type: \"category\" as const, categories: config.xCategories }),\n grid: false,\n ...base.xAxis,\n },\n yAxis: {\n ...(numericY\n ? {}\n : { type: \"category\" as const, categories: config.yCategories }),\n grid: false,\n ...base.yAxis,\n },\n // the color legend (visual map)\n legend: base.legend ?? true,\n interaction: base.interaction ?? { zoom: false },\n tooltip: base.tooltip ?? { mode: \"nearest\" },\n };\n};\n\n/** Settings of a sparkline (the props of Sparkline) */\nexport interface SparklineConfig {\n /** Values (or `[x, y]` pairs, typed arrays, ...) */\n data: ChartSeries[\"data\"];\n /**\n * How the values are drawn\n * @default \"line\"\n */\n type?: \"line\" | \"area\" | \"bar\";\n /** Color (any CSS color); the first palette color by default */\n color?: string;\n /**\n * Shape of the line\n * @default \"smooth\"\n */\n curve?: ChartCurve;\n /** Name shown in the tooltip */\n name?: string;\n /** Draws a reference line at this value (e.g. a target or the average) */\n reference?: number;\n /** Formats the value in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a sparkline: no axes, no legend, a tooltip only */\nexport const sparklineOptions = (\n config: SparklineConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const type = config.type ?? \"line\";\n return {\n ...base,\n series: [\n {\n id: \"sparkline\",\n name: config.name ?? presetLabels(base.locale).value,\n type,\n data: config.data,\n color: config.color,\n curve: type === \"bar\" ? undefined : (config.curve ?? \"smooth\"),\n lineWidth: 1.5,\n opacity: type === \"area\" ? 0.22 : undefined,\n radius: type === \"bar\" ? 1.5 : undefined,\n format: config.format,\n },\n ],\n xAxis: { visible: false, grid: false, ...base.xAxis },\n yAxis: { visible: false, grid: false, nice: false, ...base.yAxis },\n legend: false,\n padding: base.padding ?? { top: 4, right: 4, bottom: 4, left: 4 },\n interaction: base.interaction ?? { zoom: false },\n annotations:\n config.reference !== undefined\n ? [\n ...(base.annotations ?? []),\n {\n type: \"line\",\n axis: \"y\",\n value: config.reference,\n dash: [2, 3],\n },\n ]\n : base.annotations,\n };\n};\n\n/** A point of a QuadrantChart */\nexport interface QuadrantPoint {\n /** Position on the horizontal axis */\n x: number;\n /** Position on the vertical axis */\n y: number;\n /** Text drawn next to the dot and shown in the tooltip */\n label?: string;\n /** Dot color (any CSS color); the color of its quadrant by default */\n color?: string;\n /** Dot diameter in pixels */\n size?: number;\n}\n\n/** Title and color of a quadrant */\nexport interface QuadrantRegion {\n /** Title drawn in the outer corner of the quadrant */\n label?: string;\n /** Background tint and default dot color (any CSS color) */\n color?: string;\n /** Short code drawn in a pill before the title (e.g. \"Q1\") */\n badge?: string;\n /** Second line drawn under the title (e.g. \"Do it now\"); cut with … when too long */\n description?: string;\n}\n\n/** The four quadrants of a QuadrantChart */\nexport interface QuadrantRegions {\n topLeft?: QuadrantRegion;\n topRight?: QuadrantRegion;\n bottomLeft?: QuadrantRegion;\n bottomRight?: QuadrantRegion;\n}\n\n/** A quadrant, as seen on screen */\nexport type QuadrantCorner = keyof QuadrantRegions;\n\n/** Texts at the four ends of the dividers, inside the plot */\nexport interface QuadrantAxisLabels {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n}\n\n/** Settings of a quadrant matrix (the props of QuadrantChart) */\nexport interface QuadrantConfig {\n /** Points to place */\n points: readonly QuadrantPoint[];\n /**\n * Range of the horizontal axis\n * @default [0, 10]\n */\n xDomain?: [number, number];\n /**\n * Range of the vertical axis\n * @default [0, 10]\n */\n yDomain?: [number, number];\n /** X value of the vertical divider (the middle of `xDomain` by default) */\n xSplit?: number;\n /** Y value of the horizontal divider (the middle of `yDomain` by default) */\n ySplit?: number;\n /** Titles and colors of the quadrants */\n quadrants?: QuadrantRegions;\n /** Title of the horizontal axis */\n xLabel?: string;\n /** Title of the vertical axis */\n yLabel?: string;\n /** Texts at the ends of the dividers, drawn inside the plot (e.g. \"Important\" at the top) */\n axisLabels?: QuadrantAxisLabels;\n /**\n * Shows the numeric ticks of the axes; `false` keeps only the matrix\n * @default true\n */\n showTicks?: boolean;\n /** Reverses the horizontal axis (e.g. \"urgent\" on the left) */\n reverseX?: boolean;\n /**\n * Draws the labels next to the dots (overlapping labels are skipped)\n * @default true\n */\n showLabels?: boolean;\n /**\n * Dot diameter in pixels\n * @default 12\n */\n pointSize?: number;\n /** Name of the points in the tooltip */\n name?: string;\n /** Lets the user drag the dots (`drag` / `drop` events) */\n draggable?: boolean;\n /**\n * Shows the number of points of each quadrant after its title; a function\n * returns the text instead (e.g. `(n) => `${n} tasks``)\n * @default false\n */\n showCounts?:\n boolean | ((count: number, points: readonly QuadrantPoint[]) => string);\n /** Index of the selected point: drawn with a ring of its color (`null`: none) */\n selectedIndex?: number | null;\n /** Indices of the selected points (several selected points) */\n selectedIndices?: readonly number[];\n}\n\n/** State of a quadrant matrix that is not a prop (set by the components) */\nexport interface QuadrantChartState {\n /** Index of the keyboard-focused point: drawn with a focus ring */\n focusedIndex?: number | null;\n}\n\n/** Points of each quadrant, with their indices */\nexport interface QuadrantGroup {\n points: QuadrantPoint[];\n indices: number[];\n}\n\n/** The points of a matrix grouped by quadrant (as seen on screen) */\nexport const quadrantGroups = (\n config: Pick<\n QuadrantConfig,\n \"points\" | \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n): Record<QuadrantCorner, QuadrantGroup> => {\n const groups: Record<QuadrantCorner, QuadrantGroup> = {\n topLeft: { points: [], indices: [] },\n topRight: { points: [], indices: [] },\n bottomLeft: { points: [], indices: [] },\n bottomRight: { points: [], indices: [] },\n };\n config.points.forEach((p, i) => {\n if (!Number.isFinite(p.x) || !Number.isFinite(p.y)) return;\n const g = groups[quadrantOf(config, p.x, p.y)];\n g.points.push(p);\n g.indices.push(i);\n });\n return groups;\n};\n\n/** Built-in texts of the quadrant matrices (accessible point layer) */\nexport interface QuadrantLabels {\n /** Names of the quadrants without a title */\n topLeft: string;\n topRight: string;\n bottomLeft: string;\n bottomRight: string;\n /** Name of a point without a label: `{n}` is its number */\n point: string;\n /** Announced when a point is moved with the keyboard */\n moved: string;\n /** Accessible description of the points that can be moved */\n moveHint: string;\n /** Name of the action moving a point to another quadrant (touch screen readers, mini-programs) */\n moveTo: string;\n}\n\nconst QUADRANT_LABELS: LabelDictionary<QuadrantLabels> = {\n en: {\n topLeft: \"Top left quadrant\",\n topRight: \"Top right quadrant\",\n bottomLeft: \"Bottom left quadrant\",\n bottomRight: \"Bottom right quadrant\",\n point: \"Point {n}\",\n moved: \"{point} moved to {quadrant}\",\n moveHint: \"Shift + arrow keys move it to another quadrant\",\n moveTo: \"Move to {quadrant}\",\n },\n zh: {\n topLeft: \"左上象限\",\n topRight: \"右上象限\",\n bottomLeft: \"左下象限\",\n bottomRight: \"右下象限\",\n point: \"点 {n}\",\n moved: \"{point} 已移到{quadrant}\",\n moveHint: \"Shift + 方向键可移到其他象限\",\n moveTo: \"移到{quadrant}\",\n },\n ja: {\n topLeft: \"左上の象限\",\n topRight: \"右上の象限\",\n bottomLeft: \"左下の象限\",\n bottomRight: \"右下の象限\",\n point: \"点 {n}\",\n moved: \"{point} を{quadrant}に移動しました\",\n moveHint: \"Shift + 矢印キーで別の象限に移動できます\",\n moveTo: \"{quadrant}に移動\",\n },\n fr: {\n topLeft: \"Quadrant en haut à gauche\",\n topRight: \"Quadrant en haut à droite\",\n bottomLeft: \"Quadrant en bas à gauche\",\n bottomRight: \"Quadrant en bas à droite\",\n point: \"Point {n}\",\n moved: \"{point} déplacé vers {quadrant}\",\n moveHint: \"Maj + flèches pour le déplacer vers un autre quadrant\",\n moveTo: \"Déplacer vers {quadrant}\",\n },\n};\n\n/** Built-in texts of the quadrant matrices in a locale (the page language by default) */\nexport const quadrantLabels = (locale?: string): QuadrantLabels =>\n localeLabels(QUADRANT_LABELS, locale);\n\n/** Text of the count of a quadrant (`showCounts`), or `undefined` */\nexport const quadrantCountText = (\n showCounts: QuadrantConfig[\"showCounts\"],\n points: readonly QuadrantPoint[],\n locale?: string,\n): string | undefined =>\n !showCounts\n ? undefined\n : typeof showCounts === \"function\"\n ? showCounts(points.length, points)\n : numberFormat(resolveLocale(locale)).format(points.length);\n\nexport const DEFAULT_QUADRANT_COLORS: Required<Record<QuadrantCorner, string>> =\n {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n };\n\nconst DIVIDER = \"var(--border-strong-color, var(--border-color, #cbd5e1))\";\n\nconst splits = (config: QuadrantConfig) => {\n const [x0, x1] = config.xDomain ?? [0, 10];\n const [y0, y1] = config.yDomain ?? [0, 10];\n return {\n x0,\n x1,\n y0,\n y1,\n xs: config.xSplit ?? (x0 + x1) / 2,\n ys: config.ySplit ?? (y0 + y1) / 2,\n };\n};\n\n/** Quadrant of a data position, as seen on screen */\nexport const quadrantOf = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n x: number,\n y: number,\n): QuadrantCorner => {\n const { xs, ys } = splits(config as QuadrantConfig);\n const right = config.reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n};\n\n/** Center of a quadrant in data coordinates */\nexport const quadrantCenter = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n corner: QuadrantCorner,\n): { x: number; y: number } => {\n const { x0, x1, y0, y1, xs, ys } = splits(config as QuadrantConfig);\n const visualRight = corner.endsWith(\"Right\");\n const dataHigh = config.reverseX ? !visualRight : visualRight;\n return {\n x: dataHigh ? (xs + x1) / 2 : (x0 + xs) / 2,\n y: corner.startsWith(\"top\") ? (ys + y1) / 2 : (y0 + ys) / 2,\n };\n};\n\nconst CORNER_ORDER: readonly QuadrantCorner[] = [\n \"topLeft\",\n \"topRight\",\n \"bottomLeft\",\n \"bottomRight\",\n];\n\n/**\n * Series data of a matrix, kept per `points` array: re-renders passing the\n * same points (hover, focus, selection) keep the same data arrays, so the\n * engine keeps its buffers and the hovered point\n */\nconst quadrantData = new WeakMap<\n readonly QuadrantPoint[],\n Map<string, ChartPointDatum[]>\n>();\nconst cachedData = (\n points: readonly QuadrantPoint[],\n key: string,\n make: () => ChartPointDatum[],\n): ChartPointDatum[] => {\n let byKey = quadrantData.get(points);\n if (!byKey) quadrantData.set(points, (byKey = new Map()));\n let data = byKey.get(key);\n if (!data) {\n if (byKey.size >= 32) byKey.clear();\n byKey.set(key, (data = make()));\n }\n return data;\n};\n\n/** Engine options of a quadrant matrix */\nexport const quadrantChartOptions = (\n config: QuadrantConfig,\n base: Omit<ChartOptions, \"series\"> = {},\n state: QuadrantChartState = {},\n): ChartOptions => {\n const { x0, x1, y0, y1, xs, ys } = splits(config);\n const reverseX = !!config.reverseX;\n const color = (corner: QuadrantCorner) =>\n config.quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner];\n const pointSize = config.pointSize ?? 12;\n const dotColor = (p: QuadrantPoint) =>\n p.color ?? color(quadrantOf(config, p.x, p.y));\n // what the dot colors depend on, and the points themselves (arrays\n // changed in place, e.g. reactive arrays, get new data)\n const colorKey = JSON.stringify([\n x0,\n x1,\n y0,\n y1,\n xs,\n ys,\n reverseX,\n CORNER_ORDER.map(color),\n config.points.map((p) => [p.x, p.y, p.size, p.color, p.label]),\n ]);\n\n const series: ChartSeries[] = [\n {\n type: \"scatter\",\n name: config.name ?? \"\",\n pointSize,\n showLabels: config.showLabels ?? true,\n // a label stays in the quadrant of its dot, off the dividers\n labelCells: { x: xs, y: ys },\n opacity: 0.9,\n data: cachedData(config.points, colorKey, () =>\n config.points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: dotColor(p),\n })),\n ),\n },\n ];\n // states of the selected and the focused dots, drawn over them (out of\n // hit tests): a soft glow, a ring in the surface color, an outer ring\n const SURFACE = \"var(--surface-color, var(--background-color, #fff))\";\n const ring = (\n id: string,\n indices: readonly number[],\n grow: number,\n look: { color?: string; stroke: number; opacity?: number },\n ): ChartSeries | null => {\n const unique = [...new Set(indices)].filter(\n (i) => Number.isInteger(i) && config.points[i],\n );\n if (!unique.length) return null;\n const data = cachedData(\n config.points,\n `${colorKey}|${id}|${grow}|${look.color ?? \"\"}|${pointSize}|${unique.join(\",\")}`,\n () =>\n unique.map((i) => {\n const p = config.points[i]!;\n return {\n x: p.x,\n y: p.y,\n size: (p.size ?? pointSize) + grow,\n color: look.color ?? dotColor(p),\n };\n }),\n );\n return {\n id,\n type: \"scatter\",\n // unnamed: left out of the accessible name of the chart\n name: \"\",\n tooltip: false,\n opacity: look.opacity ?? 0,\n stroke: look.stroke,\n data,\n };\n };\n const selected = [\n ...(config.selectedIndices ?? []),\n ...(config.selectedIndex !== undefined && config.selectedIndex !== null\n ? [config.selectedIndex]\n : []),\n ];\n const focused =\n state.focusedIndex !== undefined && state.focusedIndex !== null\n ? [state.focusedIndex]\n : [];\n for (const extra of [\n ring(\"quadrant:selected-glow\", selected, 18, { stroke: 0, opacity: 0.16 }),\n ring(\"quadrant:selected\", selected, 3, { color: SURFACE, stroke: 2.5 }),\n ring(\"quadrant:selected-ring\", selected, 10, { stroke: 2 }),\n ring(\"quadrant:focus-gap\", focused, 8, { color: SURFACE, stroke: 3 }),\n ring(\"quadrant:focus\", focused, 14, {\n color: \"var(--focus-ring-color, var(--primary-color, #4f46e5))\",\n stroke: 2.5,\n }),\n ])\n if (extra) series.push(extra);\n\n const groups = config.showCounts ? quadrantGroups(config) : null;\n\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: QuadrantCorner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => {\n const region = config.quadrants?.[corner];\n const detail = groups\n ? quadrantCountText(config.showCounts, groups[corner].points, base.locale)\n : undefined;\n return {\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: color(corner),\n opacity: 0.07,\n label: region?.label,\n labelPosition: position,\n ...(region?.badge ? { badge: region.badge } : {}),\n ...(region?.description ? { description: region.description } : {}),\n ...(detail ? { detail } : {}),\n };\n };\n const ends = config.axisLabels ?? {};\n const visualLeft = reverseX ? x1 : x0;\n const visualRight = reverseX ? x0 : x1;\n const texts: ChartAnnotation[] = [\n ...(ends.top\n ? [{ type: \"text\", x: xs, y: y1, text: ends.top, anchor: \"top\" } as const]\n : []),\n ...(ends.bottom\n ? [\n {\n type: \"text\",\n x: xs,\n y: y0,\n text: ends.bottom,\n anchor: \"bottom\",\n } as const,\n ]\n : []),\n ...(ends.left\n ? [\n {\n type: \"text\",\n x: visualLeft,\n y: ys,\n text: ends.left,\n anchor: \"left\",\n } as const,\n ]\n : []),\n ...(ends.right\n ? [\n {\n type: \"text\",\n x: visualRight,\n y: ys,\n text: ends.right,\n anchor: \"right\",\n } as const,\n ]\n : []),\n ];\n\n const annotations: ChartAnnotation[] = [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n { type: \"line\", axis: \"x\", value: xs, dash: [], color: DIVIDER },\n { type: \"line\", axis: \"y\", value: ys, dash: [], color: DIVIDER },\n ...texts,\n ...(base.annotations ?? []),\n ];\n\n const showTicks = config.showTicks ?? true;\n const interaction: boolean | ChartInteractionOptions =\n base.interaction === false\n ? false\n : {\n zoom: false,\n ...(typeof base.interaction === \"object\" ? base.interaction : {}),\n ...(config.draggable ? { dragPoints: true, dropTargets: true } : {}),\n };\n\n return {\n ...base,\n series,\n annotations,\n tooltip:\n base.tooltip ??\n (showTicks\n ? undefined\n : {\n render: (event) => {\n const item = event.items[0];\n if (!item) return null;\n const region =\n config.quadrants?.[quadrantOf(config, item.x, item.y)]?.label;\n return [item.label ?? config.name ?? \"\", region ?? \"\"]\n .filter(Boolean)\n .join(\"\\n\");\n },\n }),\n xAxis: {\n min: x0,\n max: x1,\n title: config.xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.xLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n yAxis: {\n min: y0,\n max: y1,\n title: config.yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.yLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n legend: base.legend ?? false,\n padding:\n base.padding ??\n (showTicks ? undefined : { top: 4, right: 4, bottom: 4, left: 4 }),\n interaction,\n };\n};\n\n// ------------------------------------------------------------- statistics\n\n/** Finite values of a list, as a sorted typed array */\nconst sortedFinite = (values: ArrayLike<number>): Float64Array => {\n let n = 0;\n for (let i = 0; i < values.length; i++) if (Number.isFinite(values[i])) n++;\n const out = new Float64Array(n);\n let k = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (Number.isFinite(v)) out[k++] = v;\n }\n return out.sort();\n};\n\n/** Quantile `p` (0-1) of sorted values, linearly interpolated (NumPy / Excel) */\nconst quantileOf = (sorted: ArrayLike<number>, p: number): number => {\n const n = sorted.length;\n if (!n) return NaN;\n const at = Math.min(1, Math.max(0, p)) * (n - 1);\n const lo = Math.floor(at);\n const hi = Math.min(n - 1, lo + 1);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (at - lo);\n};\n\n/**\n * Quantiles of values (`[0.5, 0.95, 0.99]` gives the median, p95 and p99),\n * linearly interpolated like NumPy and Excel; non-finite values are ignored\n */\nexport const quantiles = (\n values: ArrayLike<number>,\n ps: readonly number[],\n): number[] => {\n const sorted = sortedFinite(values);\n return ps.map((p) => quantileOf(sorted, p));\n};\n\n/** How the bins of a histogram are chosen: a count, or a rule */\nexport type HistogramBinning =\n number | \"auto\" | \"sturges\" | \"freedman-diaconis\";\n\n/** Options of `binValues` */\nexport interface BinOptions {\n /**\n * Number of bins, or the rule choosing it: `sturges` (log2 n + 1, for\n * small normal-ish samples), `freedman-diaconis` (bin width from the\n * interquartile range, robust to outliers); `auto` uses Freedman-Diaconis\n * and Sturges when the spread is zero\n * @default \"auto\"\n */\n bins?: HistogramBinning;\n /** Range covered by the bins (values outside are not counted); the data range by default */\n domain?: readonly [number, number];\n /**\n * Rounds the bin width to 1, 2 or 5 × 10^k and aligns the edges on it\n * @default true\n */\n nice?: boolean;\n}\n\n/** Bins of a histogram */\nexport interface HistogramBins {\n /** Edges of the bins: one more than the bins */\n edges: number[];\n /** Number of values in every bin */\n counts: number[];\n /** Width of a bin */\n width: number;\n /** Number of values counted (finite, inside the domain) */\n total: number;\n}\n\n/** At most this many values are sorted to estimate the spread (Freedman-Diaconis) */\nconst SPREAD_SAMPLE = 100_000;\n\n/**\n * Counts values into bins of equal width: linear in the number of values\n * (a million samples take a few milliseconds; the spread of large samples\n * is estimated on an even subsample)\n */\nexport const binValues = (\n values: ArrayLike<number>,\n options: BinOptions = {},\n): HistogramBins => {\n let n = 0;\n let min = Infinity;\n let max = -Infinity;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!Number.isFinite(v)) continue;\n n++;\n if (v < min) min = v;\n if (v > max) max = v;\n }\n let [lo, hi] = options.domain ?? [min, max];\n if (!n || !Number.isFinite(lo) || !Number.isFinite(hi)) {\n return { edges: [0, 1], counts: [0], width: 1, total: 0 };\n }\n if (lo > hi) [lo, hi] = [hi, lo];\n if (hi === lo) {\n lo -= 0.5;\n hi += 0.5;\n }\n const span = hi - lo;\n const rule = options.bins ?? \"auto\";\n const sturges = Math.ceil(Math.log2(n)) + 1;\n let count: number;\n if (typeof rule === \"number\") {\n count = Math.round(rule);\n } else if (rule === \"sturges\") {\n count = sturges;\n } else {\n // Freedman-Diaconis: width = 2 IQR / n^(1/3)\n const stride = Math.max(1, Math.floor(values.length / SPREAD_SAMPLE));\n const sample: number[] = [];\n for (let i = 0; i < values.length; i += stride) {\n const v = values[i];\n if (Number.isFinite(v)) sample.push(v);\n }\n const sorted = Float64Array.from(sample).sort();\n const iqr = quantileOf(sorted, 0.75) - quantileOf(sorted, 0.25);\n const width = (2 * iqr) / Math.cbrt(n);\n count = width > 0 ? Math.ceil(span / width) : sturges;\n }\n count = Math.max(1, Math.min(1000, count || 1));\n let width = span / count;\n let start = lo;\n if (options.nice ?? true) {\n width = tickStep(lo, hi, count) || width;\n start = Math.floor(lo / width + 1e-9) * width;\n count = Math.max(1, Math.ceil((hi - start) / width - 1e-9));\n }\n const end = start + count * width;\n const counts = new Array<number>(count).fill(0);\n let total = 0;\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n if (!(v >= start && v <= end)) continue;\n // the last bin includes its right edge\n const k = Math.min(count - 1, Math.floor((v - start) / width));\n counts[k]++;\n total++;\n }\n const edges: number[] = [];\n for (let k = 0; k <= count; k++)\n edges.push(Number((start + k * width).toPrecision(12)));\n return { edges, counts, width, total };\n};\n\n/** Options of `histogramSeries` */\nexport interface HistogramSeriesOptions extends BinOptions {\n /** Name of the series (legend, tooltip) */\n name?: string;\n /** Bar color (any CSS color) */\n color?: string;\n /** Formats the edges of the bins in the tooltip */\n format?: (value: number) => string;\n /** Bins already computed (`binValues`): `values` are then ignored */\n binned?: HistogramBins;\n /**\n * Locale of the default name and of the bin edges\n * @default the page language\n */\n locale?: string;\n}\n\n/** Bar series of a histogram: one touching bar per bin, labelled with its range */\nexport const histogramSeries = (\n values: ArrayLike<number>,\n options: HistogramSeriesOptions = {},\n): ChartSeries => {\n const bins = options.binned ?? binValues(values, options);\n const locale = resolveLocale(options.locale);\n const format =\n options.format ?? ((value: number) => formatEdge(value, locale));\n return {\n id: \"histogram\",\n name: options.name ?? presetLabels(locale).count,\n type: \"bar\",\n color: options.color,\n barWidth: 1,\n radius: 1,\n data: bins.counts.map((count, k) => {\n const a = bins.edges[k] ?? 0;\n const b = bins.edges[k + 1] ?? a;\n return {\n x: (a + b) / 2,\n y: count,\n label: `${format(a)} – ${format(b)}`,\n };\n }),\n };\n};\n\nconst formatEdge = (value: number, locale: string) =>\n numberFormat(locale, { maximumSignificantDigits: 6 }).format(value);\n\n/** Options of `boxplotStats` */\nexport interface BoxplotStatsOptions {\n /**\n * Reach of the whiskers in interquartile ranges beyond the box (Tukey:\n * 1.5); `\"minmax\"` extends them to the extremes (no outliers)\n * @default 1.5\n */\n whisker?: number | \"minmax\";\n}\n\n/** Five-number summary of a sample, with the outliers */\nexport interface BoxplotStats {\n /** Lower whisker: the smallest value within reach */\n low: number;\n /** First quartile */\n q1: number;\n median: number;\n /** Third quartile */\n q3: number;\n /** Upper whisker: the largest value within reach */\n high: number;\n /** Values beyond the whiskers */\n outliers: number[];\n min: number;\n max: number;\n mean: number;\n /** Number of finite values */\n count: number;\n}\n\n/** Quartiles, whiskers (Tukey's 1.5 IQR by default) and outliers of raw values */\nexport const boxplotStats = (\n values: ArrayLike<number>,\n options: BoxplotStatsOptions = {},\n): BoxplotStats => {\n const sorted = sortedFinite(values);\n const n = sorted.length;\n if (!n) {\n return {\n low: NaN,\n q1: NaN,\n median: NaN,\n q3: NaN,\n high: NaN,\n outliers: [],\n min: NaN,\n max: NaN,\n mean: NaN,\n count: 0,\n };\n }\n const q1 = quantileOf(sorted, 0.25);\n const median = quantileOf(sorted, 0.5);\n const q3 = quantileOf(sorted, 0.75);\n const min = sorted[0];\n const max = sorted[n - 1];\n let sum = 0;\n for (let i = 0; i < n; i++) sum += sorted[i];\n const whisker = options.whisker ?? 1.5;\n let low = min;\n let high = max;\n const outliers: number[] = [];\n if (whisker !== \"minmax\") {\n const reach = (q3 - q1) * whisker;\n const from = q1 - reach;\n const to = q3 + reach;\n let i = 0;\n while (i < n && sorted[i] < from) outliers.push(sorted[i++]);\n low = i < n ? sorted[i] : q1;\n let j = n - 1;\n const upper: number[] = [];\n while (j >= 0 && sorted[j] > to) upper.push(sorted[j--]);\n high = j >= 0 ? sorted[j] : q3;\n outliers.push(...upper.reverse());\n }\n return {\n low: Math.min(low, q1),\n q1,\n median,\n q3,\n high: Math.max(high, q3),\n outliers,\n min,\n max,\n mean: sum / n,\n count: n,\n };\n};\n\n/** A sample of a box plot */\nexport interface BoxplotGroup {\n /** Category (or position) of the box */\n x: ChartXValue;\n /** Raw values: their quartiles, whiskers and outliers are computed */\n values: ArrayLike<number>;\n /** Color of the box (any CSS color) */\n color?: string;\n}\n\n/** Box plot data of raw samples (one datum per group) */\nexport const boxplotData = (\n groups: readonly BoxplotGroup[],\n options: BoxplotStatsOptions = {},\n): ChartPointDatum[] =>\n groups.map((g) => {\n const s = boxplotStats(g.values, options);\n return {\n x: g.x,\n y: Number.isFinite(s.median) ? s.median : null,\n low: s.low,\n q1: s.q1,\n q3: s.q3,\n high: s.high,\n outliers: s.outliers,\n ...(g.color ? { color: g.color } : {}),\n };\n });\n\n/** Series of a BoxPlotChart */\nexport const boxplotSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"boxplot\");\n\n// ---------------------------------------------------------------- waterfall\n\n/** A bar of a waterfall chart */\nexport interface WaterfallStep {\n /** Category name of the bar */\n label: string;\n /** Change (positive or negative); ignored by totals */\n value?: number;\n /**\n * `subtotal` and `total` bars show the running total, from zero\n * @default \"change\"\n */\n kind?: \"change\" | \"subtotal\" | \"total\";\n /** Color of this bar (any CSS color) */\n color?: string;\n}\n\n/** Options of `waterfallSeries` */\nexport interface WaterfallOptions {\n /** Name of the series (tooltip) */\n name?: string;\n /** Color of the increases @default the success color */\n upColor?: string;\n /** Color of the decreases @default the danger color */\n downColor?: string;\n /** Color of the totals and subtotals @default the primary color */\n totalColor?: string;\n /**\n * Value the first change starts from\n * @default 0\n */\n start?: number;\n /**\n * Writes the change (or the total) at the end of every bar\n * @default false\n */\n labels?: boolean;\n /** Formats the values (labels, tooltip) */\n format?: (value: number) => string;\n /**\n * Thin lines from the end of every bar to the next one; an object styles\n * them\n * @default true (dashed, secondary text color)\n */\n connector?: boolean | ChartConnectorOptions;\n /**\n * Locale of the default name\n * @default the page language\n */\n locale?: string;\n}\n\n/**\n * Floating bar series of a waterfall (bridge) chart: every change starts\n * where the previous one ended; totals and subtotals start from zero\n */\nexport const waterfallSeries = (\n steps: readonly WaterfallStep[],\n options: WaterfallOptions = {},\n): ChartSeries => {\n const up = options.upColor ?? \"var(--success-color, #16a34a)\";\n const down = options.downColor ?? \"var(--danger-color, #dc2626)\";\n const total = options.totalColor ?? \"var(--primary-color, #4f46e5)\";\n let running = options.start ?? 0;\n const data: ChartPointDatum[] = steps.map((step) => {\n if (step.kind === \"total\" || step.kind === \"subtotal\") {\n return { x: step.label, y: running, color: step.color ?? total };\n }\n const value = step.value ?? 0;\n const from = running;\n running += value;\n return {\n x: step.label,\n y0: from,\n y: running,\n color: step.color ?? (value >= 0 ? up : down),\n };\n });\n return {\n id: \"waterfall\",\n name: options.name ?? presetLabels(options.locale).change,\n type: \"bar\",\n color: total,\n data,\n showLabels: options.labels ?? false,\n format: options.format,\n connector: options.connector ?? true,\n };\n};\n\n// ------------------------------------------------------------------ bubbles\n\n/** Options of `bubbleSeries` */\nexport interface BubbleOptions {\n /**\n * Diameter in pixels of the smallest bubbles\n * @default 6\n */\n minSize?: number;\n /**\n * Diameter in pixels of the largest value\n * @default 48\n */\n maxSize?: number;\n /** Value drawn with `maxSize` (share a scale between charts); the largest value by default */\n maxValue?: number;\n}\n\n/**\n * Scatter series whose dots are sized by the `value` of their points: the\n * area of a bubble is proportional to its value (diameter ∝ √value), the\n * scale is shared by every series. Points are drawn from the largest to\n * the smallest, so small bubbles stay on top (hover indexes refer to that\n * order).\n */\nexport const bubbleSeries = (\n series: readonly ChartSeries[],\n options: BubbleOptions = {},\n): ChartSeries[] => {\n const minSize = options.minSize ?? 6;\n const maxSize = options.maxSize ?? 48;\n const valuesOf = (data: ChartSeries[\"data\"]): ArrayLike<number> | null => {\n if (typeof data !== \"object\" || data === null) return null;\n if (!(\"length\" in data)) {\n const v = (data as { value?: ArrayLike<number> }).value;\n return v ?? null;\n }\n const list = data as ArrayLike<unknown>;\n const out = new Float64Array(list.length).fill(NaN);\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (item && typeof item === \"object\" && !Array.isArray(item)) {\n const v = (item as { value?: unknown }).value;\n if (typeof v === \"number\") out[i] = v;\n }\n }\n return out;\n };\n let top = options.maxValue ?? 0;\n if (options.maxValue === undefined) {\n for (const s of series) {\n const values = valuesOf(s.data);\n if (!values) continue;\n for (let i = 0; i < values.length; i++) {\n const v = Math.abs(values[i]);\n if (v > top) top = v;\n }\n }\n }\n const sizeOf = (v: number) =>\n Number.isFinite(v) && top > 0\n ? Math.max(minSize, maxSize * Math.sqrt(Math.min(1, Math.abs(v) / top)))\n : minSize;\n return series.map((s) => {\n const base: ChartSeries = {\n ...s,\n type: s.type ?? \"scatter\",\n opacity: s.opacity ?? 0.68,\n };\n if (base.type !== \"scatter\") return base;\n const data = s.data;\n if (typeof data === \"object\" && data !== null && !(\"length\" in data)) {\n const values = (data as { value?: ArrayLike<number> }).value;\n if (!values) return base;\n const size = new Float32Array(values.length);\n for (let i = 0; i < values.length; i++) size[i] = sizeOf(values[i]);\n return { ...base, data: { ...data, size } };\n }\n const list = data as ArrayLike<unknown>;\n const points: ChartPointDatum[] = [];\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (!item || typeof item !== \"object\" || Array.isArray(item)) continue;\n const d = item as ChartPointDatum;\n points.push({\n ...d,\n size: d.size ?? sizeOf(typeof d.value === \"number\" ? d.value : NaN),\n });\n }\n points.sort((a, b) => (b.size ?? 0) - (a.size ?? 0));\n return { ...base, data: points };\n });\n};\n\n// -------------------------------------------------------------------- gantt\n\n/** A task (or milestone) of a Gantt chart */\nexport interface GanttTask {\n /** Name of the task (tooltip title; the row name when there is no `row`) */\n name: string;\n /**\n * Identifier referenced by the `dependencies` of other tasks; the `name`\n * by default (give ids when several tasks have the same name)\n */\n id?: string;\n /**\n * Row of the task: several tasks can share one (a resource, a lane); the\n * `name` by default, one row per task\n */\n row?: string;\n /** Start (a timestamp or a date) */\n start: number | Date;\n /** End; omitted for milestones */\n end?: number | Date;\n /** Share done, 0-1: drawn as a solid bar over the task */\n progress?: number;\n /** Group (phase, team): a color and a legend entry per group */\n group?: string;\n /** Color of the task (any CSS color); the color of its group by default */\n color?: string;\n /** Draws a dot at `start` instead of a bar */\n milestone?: boolean;\n /**\n * Tasks this one waits for, by `id` (or `name`): tooltip, and arrows from\n * their ends to its start\n */\n dependencies?: readonly string[];\n}\n\n/** Options of `ganttSeries` */\nexport interface GanttOptions {\n /** Colors of the groups in order of appearance (any CSS colors); the chart palette by default */\n colors?: readonly string[];\n /**\n * Name of the tasks without a group\n * @default \"Tasks\" (in the `locale`)\n */\n taskName?: string;\n /**\n * Name of the progress bars (legend, tooltip)\n * @default \"Progress\" (in the `locale`)\n */\n progressName?: string;\n /**\n * Name of the milestones (legend, tooltip)\n * @default \"Milestones\" (in the `locale`)\n */\n milestoneName?: string;\n /** Formats the progress shares (tooltip) @default \"60%\" */\n formatProgress?: (share: number) => string;\n /**\n * Name of the dependencies row of the tooltip\n * @default \"Depends on\" (in the `locale`)\n */\n dependenciesName?: string;\n /**\n * Draws the dependencies as elbow arrows from the end of every\n * predecessor to the start of the task\n * @default true\n */\n dependencyArrows?: boolean;\n /** Color of the dependency arrows (any CSS color); the secondary text color by default */\n dependencyColor?: string;\n /**\n * Writes the name of every task inside its bar (cut with an ellipsis,\n * in a color contrasting with the bar; skipped when the bar is too\n * small): `\"auto\"` when several tasks share a row (`row`), so the bars\n * of a lane can be told apart without hovering; `true` / `\"inside\"`\n * always, `false` never\n * @default \"auto\"\n */\n barLabels?: boolean | \"inside\" | \"auto\";\n /**\n * Locale of the default names and of the progress shares\n * @default the page language\n */\n locale?: string;\n}\n\n/** Series of a Gantt chart and the row names in order */\nexport interface GanttSeries {\n series: ChartSeries[];\n /** Rows from top to bottom (the `categories` of the x axis) */\n categories: string[];\n /** Time range of the tasks with a small margin (the `min` / `max` of the value axis) */\n domain: [number, number];\n /** Arrows of the dependencies between existing tasks (the `dependencies` of the chart) */\n dependencies: ChartDependency[];\n}\n\nconst THEMED = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n];\nconst FALLBACK = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\n/** Color `k` of the chart palette as a CSS color (theme variables first) */\nexport const paletteColor = (k: number): string => {\n const i = k % 8;\n const fallback = FALLBACK[i] ?? \"#4f46e5\";\n const themed = THEMED[i];\n return themed\n ? `var(--chart-series-${i + 1}, var(${themed}, ${fallback}))`\n : `var(--chart-series-${i + 1}, ${fallback})`;\n};\n\nconst time = (v: number | Date | undefined) =>\n v instanceof Date ? v.getTime() : v === undefined ? NaN : v;\n\nconst HOUR_MS = 3_600_000;\nconst DAY_MS = 24 * HOUR_MS;\n/** Opacity of the Gantt tasks without a `progress` (near-solid) */\nconst SOLID_TASK = 0.9;\n\n/** Local time rounded down to a multiple of `step` minutes (15 or 60) */\nconst floorMinutes = (v: number, step: number): number => {\n const d = new Date(v);\n d.setMinutes(d.getMinutes() - (d.getMinutes() % step), 0, 0);\n return d.getTime();\n};\n\n/** Local time rounded up to a multiple of `step` minutes (15 or 60) */\nconst ceilMinutes = (v: number, step: number): number => {\n const floor = floorMinutes(v, step);\n if (floor >= v) return floor;\n const d = new Date(floor);\n d.setMinutes(d.getMinutes() + step);\n return d.getTime();\n};\n\n/**\n * Floating bar series of a Gantt chart (horizontal, on a time axis): a\n * translucent bar per task with its progress drawn over it, one series per\n * group, and the milestones as dots\n */\nexport const ganttSeries = (\n tasks: readonly GanttTask[],\n options: GanttOptions = {},\n): GanttSeries => {\n const locale = resolveLocale(options.locale);\n const names = presetLabels(locale);\n const rows = chartLabels(locale);\n const taskName = options.taskName ?? names.tasks;\n const progressName = options.progressName ?? names.progress;\n const separator = /^(zh|ja)\\b/i.test(locale) ? \"、\" : \", \";\n const idOf = (t: GanttTask) => t.id ?? t.name;\n const rowOf = (t: GanttTask) => t.row ?? t.name;\n const bars = tasks.filter((t) => !t.milestone);\n const barLabels = options.barLabels ?? \"auto\";\n const labelled =\n barLabels === \"auto\"\n ? new Set(bars.map(rowOf)).size < bars.length\n : !!barLabels;\n // tasks by id, then by name (the first one wins)\n const byKey = new Map<string, GanttTask>();\n for (const t of tasks) if (!byKey.has(idOf(t))) byKey.set(idOf(t), t);\n for (const t of tasks) if (!byKey.has(t.name)) byKey.set(t.name, t);\n // tasks in a shared row: their name is the title of the tooltip (and the\n // text inside their bar)\n const point = (t: GanttTask, named = false) => ({\n x: rowOf(t),\n id: idOf(t),\n ...(named || rowOf(t) !== t.name ? { label: t.name } : {}),\n });\n const groups: string[] = [];\n for (const t of tasks) {\n const g = t.group ?? taskName;\n if (!t.milestone && !groups.includes(g)) groups.push(g);\n }\n const colorOf = (g: string) => {\n const k = Math.max(0, groups.indexOf(g));\n return options.colors?.[k] ?? paletteColor(k);\n };\n const formatProgress =\n options.formatProgress ??\n ((share: number) =>\n numberFormat(locale, {\n style: \"percent\",\n maximumFractionDigits: 0,\n }).format(share));\n // translucent bars under the progress of their task, solid ones otherwise\n const series: ChartSeries[] = groups.map((g) => ({\n id: `gantt:${g}`,\n name: g,\n type: \"bar\",\n stack: \"gantt\",\n color: colorOf(g),\n opacity: 0.3,\n barWidth: 0.62,\n radius: 4,\n ...(labelled ? { showLabels: \"inside\" as const } : {}),\n data: bars\n .filter((t) => (t.group ?? taskName) === g)\n .map((t) => {\n // the tooltip of a task: its progress and what it waits for\n const details: ChartTooltipDetail[] = [];\n if (t.progress !== undefined)\n details.push({\n name: progressName,\n value: formatProgress(Math.min(1, Math.max(0, t.progress))),\n });\n if (t.dependencies?.length)\n details.push({\n name: options.dependenciesName ?? rows.dependencies,\n value: t.dependencies\n .map((k) => byKey.get(k)?.name ?? k)\n .join(separator),\n });\n return {\n ...point(t, labelled),\n y0: time(t.start),\n y: time(t.end ?? t.start),\n ...(t.color ? { color: t.color } : {}),\n ...(t.progress === undefined ? { opacity: SOLID_TASK } : {}),\n ...(details.length ? { details } : {}),\n };\n }),\n }));\n const progress = tasks.filter(\n (t) => !t.milestone && t.progress !== undefined && t.progress > 0,\n );\n if (progress.length) {\n series.push({\n id: \"gantt:progress\",\n name: progressName,\n type: \"bar\",\n stack: \"gantt\",\n // shown in the tooltip of its task\n tooltip: false,\n // every bar has the color of its task: a neutral legend swatch\n color: \"var(--text-secondary-color, #6b7280)\",\n radius: 4,\n data: progress.map((t) => {\n const start = time(t.start);\n const end = time(t.end ?? t.start);\n const share = Math.min(1, Math.max(0, t.progress ?? 0));\n return {\n x: rowOf(t),\n y0: start,\n y: start + (end - start) * share,\n label: formatProgress(share),\n color: t.color ?? colorOf(t.group ?? taskName),\n };\n }),\n });\n }\n const milestones = tasks.filter((t) => t.milestone);\n if (milestones.length) {\n series.push({\n id: \"gantt:milestones\",\n name: options.milestoneName ?? names.milestones,\n type: \"scatter\",\n color: \"var(--text-color, #1f2937)\",\n pointSize: 13,\n opacity: 1,\n data: milestones.map((t) => ({\n ...point(t),\n y: time(t.start),\n ...(t.color ? { color: t.color } : {}),\n })),\n });\n }\n let lo = Infinity;\n let hi = -Infinity;\n for (const t of tasks) {\n for (const v of [time(t.start), time(t.end ?? t.start)]) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n }\n // room for the milestone dots at the ends\n const pad = Number.isFinite(hi - lo) ? Math.max((hi - lo) * 0.025, 1) : 0;\n let domain: [number, number] = Number.isFinite(lo)\n ? [lo - pad, hi + pad]\n : [0, 1];\n // schedules of a day or two: whole hours (quarter hours under 3 hours) at\n // the ends, so the first and last ticks are the edges (08:00 – 22:00);\n // only for real dates (plain numbers such as days or weeks keep the margin)\n const span = hi - lo;\n const dates = lo >= 1e11 || tasks.some((t) => t.start instanceof Date);\n if (dates && span >= 60_000 && span <= 2 * DAY_MS) {\n const step = span <= 3 * HOUR_MS ? 15 : 60;\n const near = (v: number) =>\n milestones.some((t) => Math.abs(time(t.start) - v) < pad);\n domain = [\n floorMinutes(lo - (near(lo) ? pad : 0), step),\n ceilMinutes(hi + (near(hi) ? pad : 0), step),\n ];\n }\n const dependencies: ChartDependency[] = [];\n if (options.dependencyArrows !== false) {\n for (const t of tasks) {\n for (const key of t.dependencies ?? []) {\n const from = byKey.get(key);\n if (!from || from === t) continue;\n dependencies.push({\n from: idOf(from),\n to: idOf(t),\n ...(options.dependencyColor\n ? { color: options.dependencyColor }\n : {}),\n });\n }\n }\n }\n return {\n series,\n categories: [...new Set(tasks.map(rowOf))],\n domain,\n dependencies,\n };\n};\n\n// -------------------------------------------------------------- range areas\n\n/** Series of a RangeAreaChart: bands between `y0` and `y` (thin edges) */\nexport const rangeAreaSeries = (\n series: readonly ChartSeries[],\n curve?: ChartCurve,\n) =>\n withSeriesType(series, \"area\", undefined, curve).map((s) =>\n s.type === \"area\" ? { ...s, lineWidth: s.lineWidth ?? 1.5 } : s,\n );\n"],"mappings":";;;;AAsCA,IAAMA,IAA+C;CACnD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;EACV,YAAY;CACd;CACA,IAAI;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;EACV,YAAY;CACd;CACA,IAAI;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;EACV,YAAY;CACd;CACA,IAAI;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;EACV,YAAY;CACd;AACF,GAGaC,KAAgB,MAC3BC,EAAaF,GAAeG,CAAM,GAGvBC,KACX,GACA,GACA,GACA,MAEAC,EAAO,KAAK,MAAM;CAChB,IAAMC,IAAIC,EAAE,QAAQC;CACpB,OAAO;EACL,GAAGD;EACH,MAAM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,MAAS,KACtByD,EAAa,KAAK;GAChB,MAAMjB,EAAKxC,CAAI;GACf,IAAIwC,EAAK,CAAC;GACV,GAAIvE,EAAQ,kBACR,EAAE,OAAOA,EAAQ,gBAAgB,IACjC,CAAC;EACP,CAAC;CACH;CAGJ,OAAO;EACL;EACA,YAAY,CAAC,GAAG,IAAI,IAAI0E,EAAM,IAAIF,CAAK,CAAC,CAAC;EACzC;EACA;CACF;AACF,GAKaiB,KACX,GACA,MAEArM,EAAeC,GAAQ,QAAQ,KAAA,GAAWK,CAAK,CAAC,CAAC,KAAK,MACpDH,EAAE,SAAS,SAAS;CAAE,GAAGA;CAAG,WAAWA,EAAE,aAAa;AAAI,IAAIA,CAChE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./data.cjs"),t=require("./color.cjs"),n=require("./layout.cjs"),r=require("./overlay.cjs"),i=require("./locale.cjs"),a=require("./format.cjs"),o=require("./axis.cjs"),s=require("./model.cjs");var c={top:12,right:16,bottom:4,left:4},l=(e,t)=>t,u=(e,n,r,i)=>{let a=n.resolve??l,o=e=>r&&e!==void 0?r(e):e,s=e=>i&&e!==void 0?i(e):e;return(e??[]).map(e=>{if(e.type===`rect`){let r=e.color?a(e.color,n.primary):n.primary;return{type:`rect`,x0:s(e.x0),x1:s(e.x1),y0:o(e.y0),y1:o(e.y1),color:r,opacity:e.opacity??.08,label:e.label,labelPosition:e.labelPosition??`top-left`,labelColor:e.labelColor?a(e.labelColor,r):t.mix(r,n.text,.2),...e.badge?{badge:e.badge}:{},...e.detail?{detail:e.detail}:{},...e.description?{description:e.description}:{}}}return e.type===`text`?{type:`text`,x:s(e.x),y:o(e.y),text:e.text,anchor:e.anchor??`center`,color:e.color?a(e.color,n.textMuted):n.textMuted,weight:e.weight??500}:{type:`line`,axis:e.axis,value:e.axis===`y`?o(e.value):s(e.value),color:e.color?a(e.color,n.textMuted):n.textMuted,width:e.width??1,dash:[...e.dash??[4,4]],label:e.label}})},d=e=>{let{model:t,view:r,theme:i,width:a,height:s,measure:l}=e;if(t.horizontal)return p(e);let u=t.y.tickCount??(t.y.type===`category`?Math.max(1,Math.floor((s-40)/(i.fontSize+5))):s>=220?5:Math.max(2,Math.round((s-48)/52))),d=o.axisTicks(t.y,r.y,u),m=0;if(t.y.visible)for(let e of d.labels)m=Math.max(m,l(e));let h=f(t,d,r.y,u),g=0;if(h&&t.y2?.visible)for(let e of h.labels)g=Math.max(g,l(e));let _=48;if(t.x.type===`category`){_=0;let e=Math.max(1,Math.floor(t.x.categories.length/200));for(let n=0;n<t.x.categories.length;n+=e)_=Math.max(_,l(t.x.categories[n]))}let v={...c,...e.padding},y=n.computePlot({width:a,height:s,padding:v,yLabelWidth:t.y.visible?Math.ceil(m):0,y2LabelWidth:Math.ceil(g),y2Title:!!t.y2?.title&&!!t.y2.visible,xAxisVisible:t.x.visible,xTitle:!!t.x.title&&t.x.visible,yTitle:!!t.y.title&&t.y.visible,fontSize:i.fontSize});e.top&&(y.y+=e.top);let b=t.x.type===`category`?Math.max(1,Math.floor(y.width/(_+14))):t.x.tickCount??Math.max(3,Math.floor(y.width/88)),x=o.axisTicks(t.x,r.x,b);return{plot:y,scales:n.createScales(y,r,t.x.reverse,t.y.reverse),xTicks:x,yTicks:d,y2Ticks:h}},f=(e,t,n,r)=>{let i=e.y2,s=e.y2Map;if(!i||!s||!s.scale)return null;if(s.log){let e=(n[0]-s.offset)/s.scale,t=(n[1]-s.offset)/s.scale,a=o.axisTicks(i,[Math.min(e,t),Math.max(e,t)],r);return{...a,values:a.values.map(e=>e*s.scale+s.offset)}}let c=t.values.map(e=>(e-s.offset)/s.scale),l=c.length>1?Math.abs(c[1]-c[0]):1,u=0;for(let e of c)u=Math.max(u,Math.abs(e));let d=i.format??a.tickFormatter(l,u,e.locale);return{values:t.values,labels:c.map(d),formatValue:i.format??e.formatValue}},p=e=>{let{model:t,view:r,theme:i,width:a,height:s,measure:l}=e,u=Math.max(1,Math.floor((s-40)/(i.fontSize+5))),d=t.x.tickCount??(t.x.type===`category`?u:s>=220?5:Math.max(2,Math.round((s-48)/52))),f=o.axisTicks(t.x,r.x,d),p=0;if(t.x.visible){if(t.x.type===`category`){let e=t.x.categories,n=Math.max(1,Math.floor(e.length/200));for(let r=0;r<e.length;r+=n){let n=t.x.format?t.x.format(r):e[r];p=Math.max(p,l(n))}}else for(let e of f.labels)p=Math.max(p,l(e))}let m={...c,...e.padding},h=n.computePlot({width:a,height:s,padding:m,yLabelWidth:t.x.visible?Math.ceil(p):0,xAxisVisible:t.y.visible,xTitle:!!t.y.title&&t.y.visible,yTitle:!!t.x.title&&t.x.visible,fontSize:i.fontSize});e.top&&(h.y+=e.top);let g=t.y.tickCount??(t.y.type===`category`?Math.max(1,Math.floor(h.width/60)):Math.max(t.y.type===`time`?4:3,Math.min(8,Math.floor(h.width/88)))),_=o.axisTicks(t.y,r.y,g);return{plot:h,scales:n.createScales(h,r,t.x.reverse,t.y.reverse,!0),xTicks:f,yTicks:_,y2Ticks:null}},m=(e,t,i,a,o,c)=>{let l=[],u=e.percent?e.formatValue:a?.formatValue??e.formatValue;for(let a of e.series){if(a.hidden||!a.showLabels)continue;if(a.type===`bar`&&a.barTop){let c=a.format??(a.yAxis===`right`?e.y2?.format??e.formatValue:u),{x:d,count:f}=a.cols,{y:p,y0:m,labels:h}=a.raw,g=a.barTop,[_,v]=t.x[0]<=t.x[1]?t.x:[t.x[1],t.x[0]];for(let t=0;t<f&&l.length<300;t++){let u=d[t]+a.barOffset;if(!Number.isFinite(p[t])||u<_||u>v)continue;let f=g[t]<(a.barBase?.[t]??0)!==e.y.reverse,y=n.toScreen(i,u,g[t]),b=a.floating&&m&&Number.isFinite(m[t]);if(b&&e.y.type===`time`&&!h?.[t])continue;let x=b?p[t]-(m?.[t]??0):0,S=h?.[t]??(b?`${x>0?`+`:``}${c(x)}`:c(p[t]));if(a.labelsInside){let e=a.barBase?.[t]??0,c=a.barHalfWidth,d=a.pointColors?.[t]??a.color,f=[d[0],d[1],d[2],d[3]*s.barOpacity(a,t)],p=o?r.insideLabelColor(f,o):void 0,m=n.toScreen(i,u,(e+g[t])/2);l.push({x:m.x,y:m.y,r:0,text:S,placement:`inside`,align:i.horizontal?`start`:`center`,bar:n.screenRect(i,i.xToPx(u-c),i.xToPx(u+c),i.yToPx(e),i.yToPx(g[t])),...p?{color:p}:{}});continue}l.push({x:y.x,y:y.y,r:0,text:S,placement:i.horizontal?f?`left`:`right`:f?`below`:`above`})}continue}if(a.type!==`scatter`)continue;let{x:d,y:f,count:p,labels:m,size:h}=a.cols;if(m)for(let e=0;e<p&&l.length<300;e++){let r=m[e];if(!r||c&&c.seriesIndex===a.index&&c.index===e)continue;let o=d[e],s=f[e];if(o<t.x[0]||o>t.x[1]||s<t.y[0]||s>t.y[1])continue;let u=h&&h[e]>0?h[e]:a.pointSize,p=n.toScreen(i,o,s);l.push({x:p.x,y:p.y,r:u/2,text:r})}}return l},h=e=>e.type===`bar`||e.type===`boxplot`?e.barOffset:0,g=(e,t,r)=>{let i=n.toScreen(r,e.cols.x[t]+h(e),s.plottedY(e,t));return{px:i.x,py:i.y}},_=(e,t,n,r,i,a,o)=>{let s=e.yToPx(r),c=e.yToPx(i);return Math.abs(a-t)<=n&&o>=Math.min(s,c)-2&&o<=Math.max(s,c)+2},v=(e,t,r,i,a)=>{let o=g(e,t,a),s=n.alongX(a,r,i),c=n.alongY(a,r,i),l=a.xToPx(e.cols.x[t]+h(e)),u=!1;if(e.type===`bar`&&e.barBase&&e.barTop)u=_(a,l,e.barHalfWidth/Math.abs(a.xPerPx),e.barBase[t],e.barTop[t],s,c);else if(e.type===`candlestick`||e.type===`boxplot`){let{high:n,low:r,y:i}=e.cols;u=_(a,l,Math.max(e.barHalfWidth/Math.abs(a.xPerPx),3),n?n[t]:i[t],r?r[t]:i[t],s,c)}return{series:e,index:t,px:o.px,py:o.py,dx:Math.abs(a.xToPx(e.cols.x[t])-s),dist:u?0:Math.hypot(o.px-r,o.py-i),inside:u}},y=(e,t,r,i,a,o)=>{let s=e.cols.outliers?.[t];if(!s)return;let c=a.xToPx(e.cols.x[t]+h(e)),l=n.alongX(a,r,i)-c,u=n.alongY(a,r,i),d=e.outlierSize/2+4+o,f,p=d;return s.forEach((n,r)=>{let i=Math.hypot(l,a.yToPx(n)-u);i<=p&&(p=i,f=e.raw.outliers?.[t]?.[r]??n)}),f},b=(e,t)=>e.cols.size&&e.cols.size[t]>0?e.cols.size[t]:e.pointSize,x=new WeakMap,S=e=>{let t=e.cols.size;if(!t)return e.pointSize;let n=x.get(t);if(n===void 0){n=e.pointSize;for(let e=0;e<t.length;e++)t[e]>n&&(n=t[e]);x.set(t,n)}return n},C=(e,t,r,i,a)=>{let o=Math.max(S(e)/2+6,10)+a,c=n.toData(i,t,r),l=o*Math.abs(i.xPerPx),u=o*Math.abs(i.yPerPx),d=-1,f=1/0,{x:p,y:m}=e.cols;return s.gridOf(e).query(c.x-l,c.x+l,c.y-u,c.y+u,o=>{let s=n.toScreen(i,p[o],m[o]),c=Math.hypot(s.x-t,s.y-r);c<=Math.max(b(e,o)/2+4,8)+a&&c<=f&&(f=c,d=o)}),d},w=(e,t,n)=>{let{x:r,y:i}=e.cellHalf,{x:a,y:o}=e.cols,c=-1;return s.gridOf(e).query(t-r,t+r,n-i,n+i,s=>{e.cellColors?.[s]&&Math.abs(a[s]-t)<=r&&Math.abs(o[s]-n)<=i&&(c=s)}),c},T=(t,n)=>{let{x:r,y:i,count:a,sorted:o}=t.cols;if(o)return e.nearestIndex(r,i,a,n);let s=-1,c=1/0;for(let e=0;e<a;e++){if(!Number.isFinite(i[e]))continue;let t=Math.abs(r[e]-n);t<c&&(c=t,s=e)}return s},E=(e,n)=>{let r=e.pointColors?.[n],{open:i,high:a,low:o,value:s,y0:c,q1:l,q3:u,outliers:d,labels:f}=e.raw,p=f?.[n],m=r?t.toCss(r):e.colorCss,h={};if(e.type===`candlestick`){let r=i?i[n]:NaN;Number.isFinite(r)&&(h.open=r),a&&Number.isFinite(a[n])&&(h.high=a[n]),o&&Number.isFinite(o[n])&&(h.low=o[n]),m=t.toCss(e.raw.y[n]<r?e.downColor:e.upColor)}else if(e.type===`heatmap`){let r=s?s[n]:e.raw.y[n];Number.isFinite(r)&&(h.value=r);let i=e.cellColors?.[n];i&&(m=t.toCss(t.unpackColor(i)))}else if(e.type===`boxplot`){a&&Number.isFinite(a[n])&&(h.high=a[n]),o&&Number.isFinite(o[n])&&(h.low=o[n]),l&&Number.isFinite(l[n])&&(h.q1=l[n]),u&&Number.isFinite(u[n])&&(h.q3=u[n]);let e=d?.[n];e&&(h.outliers=e.length)}else c&&Number.isFinite(c[n])&&(h.y0=c[n]),e.type===`scatter`&&s&&Number.isFinite(s[n])&&(h.value=s[n]);return{seriesIndex:e.index,seriesId:e.id,seriesName:e.name,index:n,x:e.raw.x[n],y:e.raw.y[n],color:m,...p===void 0?{}:{label:p},...h}},D=(e,t)=>{if(!e.length)return null;e.sort((e,t)=>e.series.index-t.series.index);let n=e.map(e=>{let t=E(e.series,e.index);return e.outlier!==void 0&&(t.outlier=e.outlier),t}),r=n[0].x;return{items:n,x:r,xLabel:t?.formatValue(r)??String(r)}},O=(e,t,r,i,a,o=0)=>{let{plot:s}=t,c=6+o;if(i<s.x-c||i>s.x+s.width+c||a<s.y-c||a>s.y+s.height+c)return null;let l=n.toData(t,i,a),u=[],d=[];for(let n of e.series)if(!n.hidden&&n.tooltip&&n.cols.count!==0){if(n.type===`scatter`){let e=C(n,i,a,t,o);e>=0&&u.push(v(n,e,i,a,t))}else if(n.type===`heatmap`){let e=w(n,l.x,l.y);if(e>=0){let r=v(n,e,i,a,t);r.inside=!0,r.dist=0,u.push(r)}}else{let e=T(n,l.x);if(e<0)continue;let r=v(n,e,i,a,t);n.type===`boxplot`&&(r.outlier=y(n,e,i,a,t,o),r.outlier!==void 0&&(r.inside=!0,r.dist=0)),d.push(r)}}let f=d.filter(e=>(e.series.type===`line`||e.series.type===`area`)&&e.dist<=8+o);if((e.tooltipMode===`item`||e.tooltipMode===`nearest`)&&f.length)return D([f.reduce((e,t)=>t.dist<e.dist?t:e)],r);if(e.tooltipMode===`item`){let e=[...u,...d].filter(e=>e.inside||e.series.type===`scatter`||(e.series.type===`line`||e.series.type===`area`)&&e.dist<=8+o);return e.length?D([e.reduce((e,t)=>t.dist<e.dist||t.dist===e.dist&&t.series.index>e.series.index?t:e)],r):null}if(e.tooltipMode===`nearest`){let e=[...u,...d].filter(e=>e.inside||e.series.type===`scatter`||e.dist<=32+o);return e.length?D([e.reduce((e,t)=>t.dist<=e.dist?t:e)],r):null}if(!d.length)return u.length?D([u.reduce((e,t)=>t.dist<=e.dist?t:e)],r):null;let p=Math.min(...d.map(e=>e.dx)),m=e.x.type===`category`?.5/Math.abs(t.xPerPx):0,h=d.filter(e=>e.dx<=p+Math.max(1,m)),g=h.reduce((e,t)=>t.dx<e.dx?t:e),_=D([g,...h.filter(e=>e!==g),...u],r);return _&&(_.x=E(g.series,g.index).x,_.xLabel=r?.formatValue(_.x)??String(_.x)),_},ee=(e,t)=>e===t||!!e&&!!t&&e.items.length===t.items.length&&e.items.every((e,n)=>e.index===t.items[n].index&&e.seriesIndex===t.items[n].seriesIndex),k={style:`percent`,minimumFractionDigits:2,maximumFractionDigits:2},A=(e,t)=>e.raw.details?.[t]?.map(e=>({color:null,name:e.name,value:e.value}))??[],j=(e,t,n,r=null)=>{let o=n?.formatValue??String,s=t=>t.format??(t.yAxis===`right`?r?.formatValue??e.y2?.format??e.formatValue:o),c=e.labels,l=t.items[0],u=l?e.series[l.seriesIndex]:null;if(t.items.length===1&&l&&u?.type===`bar`&&l.y0!==void 0&&e.y.type===`time`){let n=s(u);return{title:l.label??t.xLabel,titleColor:l.color,subtitle:l.label===void 0?u.name:`${t.xLabel} · ${u.name}`,rows:[{color:null,name:c.start,value:n(l.y0)},{color:null,name:c.end,value:n(l.y)},{color:null,name:c.duration,value:a.formatDuration(l.y-l.y0,e.locale)},...A(u,l.index)]}}if(t.items.length===1&&u?.type===`heatmap`){let n=e.y.type===`category`?e.y.categories[Math.round(l.y)]??o(l.y):o(l.y);return{title:`${t.xLabel} · ${n}`,titleColor:null,rows:[{color:l.color,name:l.label??u.name,value:l.value===void 0?`–`:(u.format??e.formatValue)(l.value)},...A(u,l.index)]}}if(t.items.every(t=>e.series[t.seriesIndex].type===`scatter`)&&t.items.length===1){let n=t.items[0],i=e.series[n.seriesIndex],a=n.value===void 0?[]:[{color:null,name:i.valueName??c.value,value:(i.format??e.formatValue)(n.value)}];if(e.x.type===`category`)return{title:n.label??t.xLabel,titleColor:null,rows:[{color:n.color,name:n.seriesName,value:s(i)(n.y)},...a,...A(i,n.index)]};let l=i.yAxis===`right`?r?.formatValue??e.y2?.format??e.formatValue:o,u=[{color:null,name:e.x.title??c.x,value:t.xLabel},{color:null,name:(i.yAxis===`right`?e.y2?.title:e.y.title)??c.y,value:(n.value===void 0?s(i):l)(n.y)},...a,...A(i,n.index)];return{title:n.label??n.seriesName,titleColor:n.color,...n.label!==void 0&&e.series.length>1?{subtitle:n.seriesName}:{},rows:u}}let d=[],f=[],p=t.items.length===1&&u?.type===`bar`&&e.x.type!==`category`&&l?.label!==void 0?l.label:null;for(let n of t.items){let t=e.series[n.seriesIndex],r=s(t);if(f.push(d.length),t.type===`candlestick`){let a=n.open!==void 0&&n.open!==0?(n.y-n.open)/Math.abs(n.open)*100:NaN;d.push({color:n.color,name:t.name,value:Number.isFinite(a)?`${a>=0?`+`:``}${i.numberFormat(e.locale,k).format(a/100)}`:``});let o=[[c.open,n.open],[c.high,n.high],[c.low,n.low],[c.close,n.y]];for(let[e,t]of o)t!==void 0&&Number.isFinite(t)&&d.push({color:null,name:e,value:r(t)});continue}if(t.type===`boxplot`){if(n.outlier!==void 0){d.push({color:n.color,name:n.label?`${n.seriesName} · ${n.label}`:n.seriesName,value:``},{color:null,name:c.outlier,value:r(n.outlier)});continue}d.push({color:n.color,name:n.label?`${n.seriesName} · ${n.label}`:n.seriesName,value:``});let e=[[c.max,n.high],[c.q3,n.q3],[c.median,n.y],[c.q1,n.q1],[c.min,n.low]];for(let[t,n]of e)n!==void 0&&Number.isFinite(n)&&d.push({color:null,name:t,value:r(n)});n.outliers&&d.push({color:null,name:c.outliers,value:String(n.outliers)});continue}let a=r(n.y);if(n.y0!==void 0){let i=n.y-n.y0;a=t.type===`bar`&&e.y.type!==`time`?`${i>0?`+`:``}${r(i)}`:`${r(n.y0)} – ${r(n.y)}`}d.push({color:n.color,name:n.label&&p===null?`${n.seriesName} · ${n.label}`:n.seriesName,value:a}),d.push(...A(t,n.index))}if(e.percent){let n=new Map;for(let r of t.items){let t=M(e,r.seriesIndex);t!==null&&Number.isFinite(r.y)&&n.set(t,(n.get(t)??0)+Math.abs(r.y))}t.items.forEach((t,r)=>{let i=M(e,t.seriesIndex),o=i===null?void 0:n.get(i),s=d[f[r]];o&&s&&Number.isFinite(t.y)&&(s.value=`${(e.series[t.seriesIndex].format??e.formatValue)(t.y)} · ${a.formatPercent(Math.abs(t.y)/o*100,e.locale,!0)}`)})}return{title:p??t.xLabel,titleColor:null,rows:d}},M=(e,t)=>e.series[t].hidden?null:e.stacks[t],te=(e,r,i)=>{let a=[],{plot:o}=r,s=1/0,c=-1/0;for(let l of i.items){let i=e.series[l.seriesIndex],u=i.cols.x[l.index]??l.x;if(i.type===`boxplot`&&l.outlier!==void 0){let e=n.toScreen(r,u+h(i),B(i,l));a.push({kind:`dot`,x:e.x,y:e.y,size:i.outlierSize+3,color:l.color,halo:t.toCss(i.pointColors?.[l.index]??i.color,.2)});continue}if(i.type===`bar`||i.type===`candlestick`||i.type===`boxplot`){let t=r.xToPx(u+h(i)),n=Math.max(i.barHalfWidth/Math.abs(r.xPerPx),1);s=Math.min(s,t-n),c=Math.max(c,t+n),i.type===`bar`&&a.push(...R(e,r,i,l.index));continue}if(i.type===`heatmap`){let e=r.xToPx(u),s=r.yToPx(l.y),c=Math.abs(i.cellHalf.x/r.xPerPx),d=Math.abs(i.cellHalf.y/r.yPerPx),f=n.screenRect(r,e-c,e+c,s-d,s+d),p=n.heatCellStyle(f.width,f.height,i.radius),m=Math.max(o.y,f.y),h=Math.min(o.y+o.height,f.y+f.height),g=Math.max(o.x,f.x),_=Math.min(o.x+o.width,f.x+f.width);h>m&&a.push({kind:`guide`,x:o.x,y:m,width:o.width,height:h-m}),_>g&&a.push({kind:`guide`,x:g,y:o.y,width:_-g,height:o.height});let v=i.cellColors?.[l.index],y=v?t.unpackColor(v):i.color;a.push({kind:`cell`,x:f.x+p.inset,y:f.y+p.inset,width:Math.max(1,f.width-p.inset*2),height:Math.max(1,f.height-p.inset*2),seriesIndex:i.index,index:l.index,color:l.color,ring:N(y),radius:p.radius});continue}let{px:d,py:f}=g(i,l.index,r);if(d<o.x-1||d>o.x+o.width+1||f<o.y-1||f>o.y+o.height+1)continue;let p=i.type===`scatter`?b(i,l.index)+4:Math.max(9,i.lineWidth*2+5),m=i.pointColors?.[l.index]??i.color;a.push({kind:`dot`,x:d,y:f,size:p,color:l.color,halo:t.toCss(m,.2)})}if(c>s){let e=Math.max(4,(c-s)*.14),t=r.horizontal?o.y:o.x,n=t+(r.horizontal?o.height:o.width),i=Math.max(t,s-e),l=Math.min(n,c+e);l>i&&a.unshift({kind:`band`,...r.horizontal?{x:o.x,y:i,width:o.width,height:l-i}:{x:i,y:o.y,width:l-i,height:o.height}})}return a},N=e=>t.luminance(e)>.45?`rgba(15, 23, 42, 0.78)`:`rgba(255, 255, 255, 0.9)`,ne=.6,P=(e,t)=>!t.floating&&e.series.some(e=>e!==t&&!e.hidden&&e.type===`bar`&&!e.floating&&e.barOffset===t.barOffset)?0:t.radius,F=(e,t)=>{let n=1/0;for(let r of e.series){if(r.hidden||r.type!==`bar`&&r.type!==`boxplot`)continue;let e=Math.abs(r.barOffset-t.barOffset);e>0&&e<n&&(n=e)}return Number.isFinite(n)?Math.max(0,n/2-t.barHalfWidth):null},I=(e,t,n,r)=>{let i=Math.min(5,Math.max(1.5,r*.08)),a=F(e,n);return a!==null&&(i=Math.min(i,a/Math.abs(t.xPerPx)*.5)),i>=.75?Math.round(i*4)/4:0},L=(e,t,r,i)=>{let a=r.barBase?.[i],o=r.barTop?.[i],s=r.cols.x[i];if(a===void 0||o===void 0||Number.isNaN(a)||Number.isNaN(o)||!Number.isFinite(s))return null;let{plot:c}=t,l=t.xToPx(s+r.barOffset),u=Math.max(r.barHalfWidth/Math.abs(t.xPerPx),.5),d=t.horizontal?c.x:c.y,f=d+(t.horizontal?c.width:c.height),p=e=>Math.min(f+16,Math.max(d-16,Number.isNaN(e)?d:e)),m=p(t.yToPx(a)),h=p(t.yToPx(o));if(Math.abs(m-h)<.5)return null;let g=n.screenRect(t,l-u,l+u,m,h);return g.x>c.x+c.width||g.x+g.width<c.x||g.y>c.y+c.height||g.y+g.height<c.y?null:{...g,radius:Math.min(P(e,r),g.width/2,g.height/2),base:t.horizontal?m<h?`left`:`right`:m>h?`bottom`:`top`}},R=(e,n,r,i)=>{let a=L(e,n,r,i);if(!a)return[];let o=I(e,n,r,a.base===`top`||a.base===`bottom`?a.width:a.height),c=r.pointColors?.[i]??r.color,l=c[3]*s.barOpacity(r,i),u=l<ne,d=[{kind:`bar`,...a,seriesIndex:r.index,index:i,color:t.toCss(c,s.barOpacity(r,i)),backdrop:l<.98,ring:u?t.toCss([c[0],c[1],c[2],1]):N(c),grow:o}],f=Math.min(r.barBase?.[i]??NaN,r.barTop?.[i]??NaN),p=Math.max(r.barBase?.[i]??NaN,r.barTop?.[i]??NaN);if(!r.floating||!(p>=f))return d;let m=(p-f)*1e-9;for(let a of e.series)if(a!==r&&!a.hidden&&!a.tooltip&&a.type===`bar`&&a.floating&&a.barOffset===r.barOffset&&a.barBase&&a.barTop)for(let c=0;c<a.cols.count;c++){if(a.cols.x[c]!==r.cols.x[i])continue;let l=Math.min(a.barBase[c],a.barTop[c]),u=Math.max(a.barBase[c],a.barTop[c]);if(!(l>=f-m&&u<=p+m))continue;let h=L(e,n,a,c);if(!h)continue;let g=a.pointColors?.[c]??a.color;d.push({kind:`bar`,...h,seriesIndex:a.index,index:c,color:t.toCss(g,s.barOpacity(a,c)),backdrop:!1,ring:null,grow:o})}return d},z=e=>e.base===`top`||e.base===`bottom`?{x:e.x-e.grow,y:e.y,width:e.width+e.grow*2,height:e.height}:{x:e.x,y:e.y-e.grow,width:e.width,height:e.height+e.grow*2},B=(e,t)=>{let n=e.raw.outliers?.[t.index],r=n?n.indexOf(t.outlier??NaN):-1;return(r>=0?e.cols.outliers?.[t.index]?.[r]:void 0)??t.outlier??0},V=(e,r)=>{let i=[];for(let a of e.series){let e=a.connector;if(!e||a.hidden||a.type!==`bar`||!a.barTop)continue;let{x:o,count:s}=a.cols,c=a.barTop,l=a.barHalfWidth,[u,d]=r.view.x[0]<=r.view.x[1]?r.view.x:[r.view.x[1],r.view.x[0]],f=t.toCss(e.color,.75),p=-1;for(let t=0;t<s&&i.length<1200;t++)if(Number.isFinite(c[t])&&Number.isFinite(o[t])){if(p>=0&&o[t]+l>=u&&o[p]-l<=d){let s=n.toScreen(r,o[p]+a.barOffset+l,c[p]),u=n.toScreen(r,o[t]+a.barOffset-l,c[p]);i.push({x0:s.x,y0:s.y,x1:u.x,y1:u.y,color:f,width:e.width,dash:e.dash})}p=t}}return i},H=(e,n)=>{let r=n.resolve??l,i=t.toCss(n.textMuted,.85);return(e??[]).map(e=>({from:e.from,to:e.to,color:e.color?t.toCss(r(e.color,n.textMuted)):i}))},U={length:6,half:3.5},W=(e,t,n,r)=>{let i={boxes:[],byId:new Map,byRow:new Map,ids:new Set},a=e.x.type===`category`?e.x.categories:null;for(let o of e.series){if(o.type!==`bar`&&o.type!==`scatter`)continue;let e=o.raw.ids;if(e)for(let t of e)t!==void 0&&i.ids.add(t);if(o.hidden||!o.tooltip)continue;let{x:s,y:c,count:l}=o.cols,u=o.type===`bar`&&o.barBase&&o.barTop,d=h(o);for(let f=0;f<l;f++){let l=u?o.barBase[f]:c[f],p=u?o.barTop[f]:c[f];if(!Number.isFinite(s[f])||!Number.isFinite(l)||!Number.isFinite(p))continue;let m=u?o.barHalfWidth/Math.abs(t.xPerPx):b(o,f)/2,h=n(Math.min(l,p)),g=n(Math.max(l,p)),_=u?0:m,v={c:r(s[f]+d),half:m,start:h,end:g,lo:Math.min(h,g)-_,hi:Math.max(h,g)+_,dot:!u};i.boxes.push(v);let y=e?.[f];y!==void 0&&!i.byId.has(y)&&i.byId.set(y,v);let x=a?a[Math.round(s[f])]:String(o.raw.x[f]);x!==void 0&&!i.byRow.has(x)&&i.byRow.set(x,v)}}return i},G=8,K=4,q=e=>{let t=e.map(e=>[e.lo-K,e.hi+K]).sort((e,t)=>e[0]-t[0]),n=[];for(let e of t){let t=n[n.length-1];t&&e[0]<=t[1]?t[1]=Math.max(t[1],e[1]):n.push(e)}return n},J=(e,t)=>e.some(([e,n])=>t>e+1e-6&&t<n-1e-6),Y=(e,t,n,r)=>{let i=[t];for(let[t,n]of e)i.push(t,n);let a=null;for(let o of i){let i=r*(o-t);i<0||r*(n-o)<0||J(e,o)||(a===null||i<r*(a-t))&&(a=o)}return a},X=(e,t)=>{let n=e.find(([e,n])=>t>e+1e-6&&t<n-1e-6);if(!n)return t;let[r,i]=n;return t-r<=i-t?r:i},Z=e=>{let t=[],n=(e,t)=>Math.abs(e-t)<1e-6;for(let r of e){let e=t[t.length-1];if(e&&n(e[0],r[0])&&n(e[1],r[1]))continue;let i=t[t.length-2];i&&e&&(n(i[0],e[0])&&n(e[0],r[0])||n(i[1],e[1])&&n(e[1],r[1]))&&t.pop(),t.push(r)}return t},re=(e,t,n,r,i,a)=>{let o=e.c,s=t.c,c=n+i*G,l=i*(r-c)>=0,u=Math.min(o,s),d=Math.max(o,s),f=d-u<.5?[]:a.filter(n=>n!==e&&n!==t&&n.c+n.half>u&&n.c-n.half<d);if(l){let e=Y(q(f),c,r,i);if(e!==null)return Z([[n,o],[e,o],[e,s],[r,s]])}let p=Math.sign(s-o)||1,m=new Map;for(let e of f){if(Math.abs(e.c-o)<.5||Math.abs(e.c-s)<.5)continue;let t=Math.round(e.c*2),n=m.get(t);n?(n.half=Math.max(n.half,e.half),n.of.push(e)):m.set(t,{c:e.c,half:e.half,of:[e]})}let h=[{c:o,half:e.half,lanes:[]},...[...m.values()].sort((e,t)=>p*(e.c-t.c)).map(e=>({c:e.c,half:e.half,lanes:q(e.of)})),{c:s,half:t.half,lanes:[]}],g=r-i*G,_=[[n,o],[c,o]],v=c;for(let e=0;e+1<h.length;e++){let t=h[e],n=h[e+1],a=Math.abs(n.c-t.c)<.5?t.c+p*(Math.max(t.half,n.half)+K):(t.c+p*t.half+n.c-p*n.half)/2,o=e+2===h.length?l&&i*(r-v)>=0?v:g:X(n.lanes,l?v:g);o!==v&&(_.push([v,a],[o,a]),v=o)}return _.push([v,s],[r,s]),Z(_)},ie=(e,t,r)=>{if(!r.length)return[];let i=t.horizontal,a=(e,t)=>i?{x:e,y:t}:{x:t,y:e},o=e=>{let r=n.toScreen(t,0,e);return i?r.x:r.y},s=e=>{let r=n.toScreen(t,e,0);return i?r.y:r.x},c=Math.sign(o(t.view.y[1])-o(t.view.y[0]))||1,l=W(e,t,o,s),u=e=>l.byId.get(e)??(l.ids.has(e)?void 0:l.byRow.get(e)),{length:d,half:f}=U,p=[];for(let e of r){let t=u(e.from),n=u(e.to);if(!t||!n||t===n)continue;let r=t.end+(t.dot?c*t.half:0),i=n.start-c*(n.dot?n.half+1:1),o=i-c*d,s=re(t,n,r,o,c,l.boxes);p.push({points:s.map(([e,t])=>a(e,t)),head:[a(i,n.c),a(o,n.c-f),a(o,n.c+f)],color:e.color,width:1.25})}return p},ae=12,Q=e=>{if(!e.series.length||e.series.some(e=>e.type!==`heatmap`))return null;let n=e.series.find(e=>!e.hidden&&e.colorLut),r=n?.colorLut;if(!n||!r)return null;let i=[];for(let e=0;e<ae;e++){let n=r[Math.round(e/11*(r.length-1))];i.push(t.toCss(t.unpackColor(n??0)))}let a=n.format??e.formatValue,[o,s]=n.valueRange,c=[{at:0,text:a(o)},{at:1,text:a(s)}],l=n.colorMidpoint;return l!==null&&l>o&&l<s&&c.splice(1,0,{at:.5,text:a(l)}),{seriesIndex:n.index,stops:i,labels:c}},oe=(e,t,n)=>e===void 0?n>1||Q(t)!==null:!!e,se=e=>e===`scatter`?`dot`:e===`line`?`line`:`square`,$=(e,t,n)=>n??(e.tooltipMode===`axis`&&t.items.some(t=>{let n=e.series[t.seriesIndex].type;return n===`line`||n===`area`})&&!t.items.some(t=>{let n=e.series[t.seriesIndex].type;return n===`bar`||n===`candlestick`||n===`boxplot`})),ce=(e,t,n,r)=>{if(!$(e,n,r))return null;let i=n.items[0],a=t.xToPx(e.series[i.seriesIndex]?.cols.x[i.index]??s.toPlotX(e,i.x)),o=t.horizontal?t.plot.y:t.plot.x,c=o+(t.horizontal?t.plot.height:t.plot.width);return a>=o&&a<=c?a:null};exports.ARROW_HEAD=U,exports.DEFAULT_PADDING=c,exports.collectPointLabels=m,exports.colorLegend=Q,exports.connectorSegments=V,exports.contrastRing=N,exports.crosshairAt=ce,exports.dependencyArrows=ie,exports.dotSize=b,exports.fallbackResolve=l,exports.hitTest=O,exports.hoverItemOf=E,exports.hoverMarks=te,exports.layoutChart=d,exports.legendShape=se,exports.legendShown=oe,exports.liftedBarRect=z,exports.pointOf=g,exports.resolveAnnotations=u,exports.resolveDependencies=H,exports.sameHover=ee,exports.showsCrosshair=$,exports.tooltipContent=j;
|
|
1
|
+
const e=require("./data.cjs"),t=require("./color.cjs"),n=require("./layout.cjs"),r=require("./overlay.cjs"),i=require("./locale.cjs"),a=require("./format.cjs"),o=require("./axis.cjs"),s=require("./model.cjs");var c={top:12,right:16,bottom:4,left:4},l=(e,t)=>t,u=(e,n,r,i)=>{let a=n.resolve??l,o=e=>r&&e!==void 0?r(e):e,s=e=>i&&e!==void 0?i(e):e;return(e??[]).map(e=>{if(e.type===`rect`){let r=e.color?a(e.color,n.primary):n.primary;return{type:`rect`,x0:s(e.x0),x1:s(e.x1),y0:o(e.y0),y1:o(e.y1),color:r,opacity:e.opacity??.08,label:e.label,labelPosition:e.labelPosition??`top-left`,labelColor:e.labelColor?a(e.labelColor,r):t.mix(r,n.text,.2),...e.badge?{badge:e.badge}:{},...e.detail?{detail:e.detail}:{},...e.description?{description:e.description}:{}}}return e.type===`text`?{type:`text`,x:s(e.x),y:o(e.y),text:e.text,anchor:e.anchor??`center`,color:e.color?a(e.color,n.textMuted):n.textMuted,weight:e.weight??500}:{type:`line`,axis:e.axis,value:e.axis===`y`?o(e.value):s(e.value),color:e.color?a(e.color,n.textMuted):n.textMuted,width:e.width??1,dash:[...e.dash??[4,4]],label:e.label}})},d=e=>{let{model:t,view:r,theme:i,width:a,height:s,measure:l}=e;if(t.horizontal)return p(e);let u=t.y.tickCount??(t.y.type===`category`?Math.max(1,Math.floor((s-40)/(i.fontSize+5))):s>=220?5:Math.max(2,Math.round((s-48)/52))),d=o.axisTicks(t.y,r.y,u),m=0;if(t.y.visible)for(let e of d.labels)m=Math.max(m,l(e));let h=f(t,d,r.y,u),g=0;if(h&&t.y2?.visible)for(let e of h.labels)g=Math.max(g,l(e));let _=48;if(t.x.type===`category`){_=0;let e=Math.max(1,Math.floor(t.x.categories.length/200));for(let n=0;n<t.x.categories.length;n+=e)_=Math.max(_,l(t.x.categories[n]))}let v={...c,...e.padding},y=n.computePlot({width:a,height:s,padding:v,yLabelWidth:t.y.visible?Math.ceil(m):0,y2LabelWidth:Math.ceil(g),y2Title:!!t.y2?.title&&!!t.y2.visible,xAxisVisible:t.x.visible,xTitle:!!t.x.title&&t.x.visible,yTitle:!!t.y.title&&t.y.visible,fontSize:i.fontSize});e.top&&(y.y+=e.top);let b=t.x.type===`category`?Math.max(1,Math.floor(y.width/(_+14))):t.x.tickCount??Math.max(3,Math.floor(y.width/88)),x=o.axisTicks(t.x,r.x,b);return{plot:y,scales:n.createScales(y,r,t.x.reverse,t.y.reverse),xTicks:x,yTicks:d,y2Ticks:h}},f=(e,t,n,r)=>{let i=e.y2,s=e.y2Map;if(!i||!s||!s.scale)return null;if(s.log){let e=(n[0]-s.offset)/s.scale,t=(n[1]-s.offset)/s.scale,a=o.axisTicks(i,[Math.min(e,t),Math.max(e,t)],r);return{...a,values:a.values.map(e=>e*s.scale+s.offset)}}let c=t.values.map(e=>(e-s.offset)/s.scale),l=c.length>1?Math.abs(c[1]-c[0]):1,u=0;for(let e of c)u=Math.max(u,Math.abs(e));let d=i.format??a.tickFormatter(l,u,e.locale);return{values:t.values,labels:c.map(d),formatValue:i.format??e.formatValue}},p=e=>{let{model:t,view:r,theme:i,width:a,height:s,measure:l}=e,u=Math.max(1,Math.floor((s-40)/(i.fontSize+5))),d=t.x.tickCount??(t.x.type===`category`?u:s>=220?5:Math.max(2,Math.round((s-48)/52))),f=o.axisTicks(t.x,r.x,d),p=0;if(t.x.visible){if(t.x.type===`category`){let e=t.x.categories,n=Math.max(1,Math.floor(e.length/200));for(let r=0;r<e.length;r+=n){let n=t.x.format?t.x.format(r):e[r];p=Math.max(p,l(n))}}else for(let e of f.labels)p=Math.max(p,l(e))}let m={...c,...e.padding},h=n.computePlot({width:a,height:s,padding:m,yLabelWidth:t.x.visible?Math.ceil(p):0,xAxisVisible:t.y.visible,xTitle:!!t.y.title&&t.y.visible,yTitle:!!t.x.title&&t.x.visible,fontSize:i.fontSize});e.top&&(h.y+=e.top);let g=t.y.tickCount??(t.y.type===`category`?Math.max(1,Math.floor(h.width/60)):Math.max(t.y.type===`time`?4:3,Math.min(8,Math.floor(h.width/88)))),_=o.axisTicks(t.y,r.y,g);return{plot:h,scales:n.createScales(h,r,t.x.reverse,t.y.reverse,!0),xTicks:f,yTicks:_,y2Ticks:null}},m=(e,t,n)=>{let{plot:r}=e,i=r.x,a=r.x+r.width,o=r.y,s=r.y+r.height,c=[],l=[];t.x!==void 0&&Number.isFinite(t.x)&&(e.horizontal?l:c).push(e.xToPx(t.x)),t.y!==void 0&&Number.isFinite(t.y)&&(e.horizontal?c:l).push(e.yToPx(t.y));for(let e of c)e>i&&e<a&&(n.x<e?a=e:i=e);for(let e of l)e>o&&e<s&&(n.y<e?s=e:o=e);return{x:i,y:o,width:a-i,height:s-o}},h=(e,t,i,a,o,c)=>{let l=[],u=e.percent?e.formatValue:a?.formatValue??e.formatValue;for(let a of e.series){if(a.hidden||!a.showLabels)continue;if(a.type===`bar`&&a.barTop){let c=a.format??(a.yAxis===`right`?e.y2?.format??e.formatValue:u),{x:d,count:f}=a.cols,{y:p,y0:m,labels:h}=a.raw,g=a.barTop,[_,v]=t.x[0]<=t.x[1]?t.x:[t.x[1],t.x[0]];for(let t=0;t<f&&l.length<300;t++){let u=d[t]+a.barOffset;if(!Number.isFinite(p[t])||u<_||u>v)continue;let f=g[t]<(a.barBase?.[t]??0)!==e.y.reverse,y=n.toScreen(i,u,g[t]),b=a.floating&&m&&Number.isFinite(m[t]);if(b&&e.y.type===`time`&&!h?.[t])continue;let x=b?p[t]-(m?.[t]??0):0,S=h?.[t]??(b?`${x>0?`+`:``}${c(x)}`:c(p[t]));if(a.labelsInside){let e=a.barBase?.[t]??0,c=a.barHalfWidth,d=a.pointColors?.[t]??a.color,f=[d[0],d[1],d[2],d[3]*s.barOpacity(a,t)],p=o?r.insideLabelColor(f,o):void 0,m=n.toScreen(i,u,(e+g[t])/2);l.push({x:m.x,y:m.y,r:0,text:S,placement:`inside`,align:i.horizontal?`start`:`center`,bar:n.screenRect(i,i.xToPx(u-c),i.xToPx(u+c),i.yToPx(e),i.yToPx(g[t])),...p?{color:p}:{}});continue}l.push({x:y.x,y:y.y,r:0,text:S,placement:i.horizontal?f?`left`:`right`:f?`below`:`above`})}continue}if(a.type!==`scatter`)continue;let{x:d,y:f,count:p,labels:h,size:g}=a.cols;if(h)for(let e=0;e<p&&l.length<300;e++){let r=h[e];if(!r||c&&c.seriesIndex===a.index&&c.index===e)continue;let o=d[e],s=f[e];if(o<t.x[0]||o>t.x[1]||s<t.y[0]||s>t.y[1])continue;let u=g&&g[e]>0?g[e]:a.pointSize,p=n.toScreen(i,o,s);l.push(a.labelCells?{x:p.x,y:p.y,r:u/2,text:r,bounds:m(i,a.labelCells,p)}:{x:p.x,y:p.y,r:u/2,text:r})}}return l},g=e=>e.type===`bar`||e.type===`boxplot`?e.barOffset:0,_=(e,t,r)=>{let i=n.toScreen(r,e.cols.x[t]+g(e),s.plottedY(e,t));return{px:i.x,py:i.y}},v=(e,t,n,r,i,a,o)=>{let s=e.yToPx(r),c=e.yToPx(i);return Math.abs(a-t)<=n&&o>=Math.min(s,c)-2&&o<=Math.max(s,c)+2},y=(e,t,r,i,a)=>{let o=_(e,t,a),s=n.alongX(a,r,i),c=n.alongY(a,r,i),l=a.xToPx(e.cols.x[t]+g(e)),u=!1;if(e.type===`bar`&&e.barBase&&e.barTop)u=v(a,l,e.barHalfWidth/Math.abs(a.xPerPx),e.barBase[t],e.barTop[t],s,c);else if(e.type===`candlestick`||e.type===`boxplot`){let{high:n,low:r,y:i}=e.cols;u=v(a,l,Math.max(e.barHalfWidth/Math.abs(a.xPerPx),3),n?n[t]:i[t],r?r[t]:i[t],s,c)}return{series:e,index:t,px:o.px,py:o.py,dx:Math.abs(a.xToPx(e.cols.x[t])-s),dist:u?0:Math.hypot(o.px-r,o.py-i),inside:u}},b=(e,t,r,i,a,o)=>{let s=e.cols.outliers?.[t];if(!s)return;let c=a.xToPx(e.cols.x[t]+g(e)),l=n.alongX(a,r,i)-c,u=n.alongY(a,r,i),d=e.outlierSize/2+4+o,f,p=d;return s.forEach((n,r)=>{let i=Math.hypot(l,a.yToPx(n)-u);i<=p&&(p=i,f=e.raw.outliers?.[t]?.[r]??n)}),f},x=(e,t)=>e.cols.size&&e.cols.size[t]>0?e.cols.size[t]:e.pointSize,S=new WeakMap,ee=e=>{let t=e.cols.size;if(!t)return e.pointSize;let n=S.get(t);if(n===void 0){n=e.pointSize;for(let e=0;e<t.length;e++)t[e]>n&&(n=t[e]);S.set(t,n)}return n},C=(e,t,r,i,a)=>{let o=Math.max(ee(e)/2+6,10)+a,c=n.toData(i,t,r),l=o*Math.abs(i.xPerPx),u=o*Math.abs(i.yPerPx),d=-1,f=1/0,{x:p,y:m}=e.cols;return s.gridOf(e).query(c.x-l,c.x+l,c.y-u,c.y+u,o=>{let s=n.toScreen(i,p[o],m[o]),c=Math.hypot(s.x-t,s.y-r);c<=Math.max(x(e,o)/2+4,8)+a&&c<=f&&(f=c,d=o)}),d},te=(e,t,n)=>{let{x:r,y:i}=e.cellHalf,{x:a,y:o}=e.cols,c=-1;return s.gridOf(e).query(t-r,t+r,n-i,n+i,s=>{e.cellColors?.[s]&&Math.abs(a[s]-t)<=r&&Math.abs(o[s]-n)<=i&&(c=s)}),c},w=(t,n)=>{let{x:r,y:i,count:a,sorted:o}=t.cols;if(o)return e.nearestIndex(r,i,a,n);let s=-1,c=1/0;for(let e=0;e<a;e++){if(!Number.isFinite(i[e]))continue;let t=Math.abs(r[e]-n);t<c&&(c=t,s=e)}return s},T=(e,n)=>{let r=e.pointColors?.[n],{open:i,high:a,low:o,value:s,y0:c,q1:l,q3:u,outliers:d,labels:f}=e.raw,p=f?.[n],m=r?t.toCss(r):e.colorCss,h={};if(e.type===`candlestick`){let r=i?i[n]:NaN;Number.isFinite(r)&&(h.open=r),a&&Number.isFinite(a[n])&&(h.high=a[n]),o&&Number.isFinite(o[n])&&(h.low=o[n]),m=t.toCss(e.raw.y[n]<r?e.downColor:e.upColor)}else if(e.type===`heatmap`){let r=s?s[n]:e.raw.y[n];Number.isFinite(r)&&(h.value=r);let i=e.cellColors?.[n];i&&(m=t.toCss(t.unpackColor(i)))}else if(e.type===`boxplot`){a&&Number.isFinite(a[n])&&(h.high=a[n]),o&&Number.isFinite(o[n])&&(h.low=o[n]),l&&Number.isFinite(l[n])&&(h.q1=l[n]),u&&Number.isFinite(u[n])&&(h.q3=u[n]);let e=d?.[n];e&&(h.outliers=e.length)}else c&&Number.isFinite(c[n])&&(h.y0=c[n]),e.type===`scatter`&&s&&Number.isFinite(s[n])&&(h.value=s[n]);return{seriesIndex:e.index,seriesId:e.id,seriesName:e.name,index:n,x:e.raw.x[n],y:e.raw.y[n],color:m,...p===void 0?{}:{label:p},...h}},E=(e,t)=>{if(!e.length)return null;e.sort((e,t)=>e.series.index-t.series.index);let n=e.map(e=>{let t=T(e.series,e.index);return e.outlier!==void 0&&(t.outlier=e.outlier),t}),r=n[0].x;return{items:n,x:r,xLabel:t?.formatValue(r)??String(r)}},D=(e,t,r,i,a,o=0)=>{let{plot:s}=t,c=6+o;if(i<s.x-c||i>s.x+s.width+c||a<s.y-c||a>s.y+s.height+c)return null;let l=n.toData(t,i,a),u=[],d=[];for(let n of e.series)if(!n.hidden&&n.tooltip&&n.cols.count!==0){if(n.type===`scatter`){let e=C(n,i,a,t,o);e>=0&&u.push(y(n,e,i,a,t))}else if(n.type===`heatmap`){let e=te(n,l.x,l.y);if(e>=0){let r=y(n,e,i,a,t);r.inside=!0,r.dist=0,u.push(r)}}else{let e=w(n,l.x);if(e<0)continue;let r=y(n,e,i,a,t);n.type===`boxplot`&&(r.outlier=b(n,e,i,a,t,o),r.outlier!==void 0&&(r.inside=!0,r.dist=0)),d.push(r)}}let f=d.filter(e=>(e.series.type===`line`||e.series.type===`area`)&&e.dist<=8+o);if((e.tooltipMode===`item`||e.tooltipMode===`nearest`)&&f.length)return E([f.reduce((e,t)=>t.dist<e.dist?t:e)],r);if(e.tooltipMode===`item`){let e=[...u,...d].filter(e=>e.inside||e.series.type===`scatter`||(e.series.type===`line`||e.series.type===`area`)&&e.dist<=8+o);return e.length?E([e.reduce((e,t)=>t.dist<e.dist||t.dist===e.dist&&t.series.index>e.series.index?t:e)],r):null}if(e.tooltipMode===`nearest`){let e=[...u,...d].filter(e=>e.inside||e.series.type===`scatter`||e.dist<=32+o);return e.length?E([e.reduce((e,t)=>t.dist<=e.dist?t:e)],r):null}if(!d.length)return u.length?E([u.reduce((e,t)=>t.dist<=e.dist?t:e)],r):null;let p=Math.min(...d.map(e=>e.dx)),m=e.x.type===`category`?.5/Math.abs(t.xPerPx):0,h=d.filter(e=>e.dx<=p+Math.max(1,m)),g=h.reduce((e,t)=>t.dx<e.dx?t:e),_=E([g,...h.filter(e=>e!==g),...u],r);return _&&(_.x=T(g.series,g.index).x,_.xLabel=r?.formatValue(_.x)??String(_.x)),_},O=(e,t)=>e===t||!!e&&!!t&&e.items.length===t.items.length&&e.items.every((e,n)=>e.index===t.items[n].index&&e.seriesIndex===t.items[n].seriesIndex),k={style:`percent`,minimumFractionDigits:2,maximumFractionDigits:2},A=(e,t)=>e.raw.details?.[t]?.map(e=>({color:null,name:e.name,value:e.value}))??[],j=(e,t,n,r=null)=>{let o=n?.formatValue??String,s=t=>t.format??(t.yAxis===`right`?r?.formatValue??e.y2?.format??e.formatValue:o),c=e.labels,l=t.items[0],u=l?e.series[l.seriesIndex]:null;if(t.items.length===1&&l&&u?.type===`bar`&&l.y0!==void 0&&e.y.type===`time`){let n=s(u);return{title:l.label??t.xLabel,titleColor:l.color,subtitle:l.label===void 0?u.name:`${t.xLabel} · ${u.name}`,rows:[{color:null,name:c.start,value:n(l.y0)},{color:null,name:c.end,value:n(l.y)},{color:null,name:c.duration,value:a.formatDuration(l.y-l.y0,e.locale)},...A(u,l.index)]}}if(t.items.length===1&&u?.type===`heatmap`){let n=e.y.type===`category`?e.y.categories[Math.round(l.y)]??o(l.y):o(l.y);return{title:`${t.xLabel} · ${n}`,titleColor:null,rows:[{color:l.color,name:l.label??u.name,value:l.value===void 0?`–`:(u.format??e.formatValue)(l.value)},...A(u,l.index)]}}if(t.items.every(t=>e.series[t.seriesIndex].type===`scatter`)&&t.items.length===1){let n=t.items[0],i=e.series[n.seriesIndex],a=n.value===void 0?[]:[{color:null,name:i.valueName??c.value,value:(i.format??e.formatValue)(n.value)}];if(e.x.type===`category`)return{title:n.label??t.xLabel,titleColor:null,rows:[{color:n.color,name:n.seriesName,value:s(i)(n.y)},...a,...A(i,n.index)]};let l=i.yAxis===`right`?r?.formatValue??e.y2?.format??e.formatValue:o,u=[{color:null,name:e.x.title??c.x,value:t.xLabel},{color:null,name:(i.yAxis===`right`?e.y2?.title:e.y.title)??c.y,value:(n.value===void 0?s(i):l)(n.y)},...a,...A(i,n.index)];return{title:n.label??n.seriesName,titleColor:n.color,...n.label!==void 0&&e.series.length>1?{subtitle:n.seriesName}:{},rows:u}}let d=[],f=[],p=t.items.length===1&&u?.type===`bar`&&e.x.type!==`category`&&l?.label!==void 0?l.label:null;for(let n of t.items){let t=e.series[n.seriesIndex],r=s(t);if(f.push(d.length),t.type===`candlestick`){let a=n.open!==void 0&&n.open!==0?(n.y-n.open)/Math.abs(n.open)*100:NaN;d.push({color:n.color,name:t.name,value:Number.isFinite(a)?`${a>=0?`+`:``}${i.numberFormat(e.locale,k).format(a/100)}`:``});let o=[[c.open,n.open],[c.high,n.high],[c.low,n.low],[c.close,n.y]];for(let[e,t]of o)t!==void 0&&Number.isFinite(t)&&d.push({color:null,name:e,value:r(t)});continue}if(t.type===`boxplot`){if(n.outlier!==void 0){d.push({color:n.color,name:n.label?`${n.seriesName} · ${n.label}`:n.seriesName,value:``},{color:null,name:c.outlier,value:r(n.outlier)});continue}d.push({color:n.color,name:n.label?`${n.seriesName} · ${n.label}`:n.seriesName,value:``});let e=[[c.max,n.high],[c.q3,n.q3],[c.median,n.y],[c.q1,n.q1],[c.min,n.low]];for(let[t,n]of e)n!==void 0&&Number.isFinite(n)&&d.push({color:null,name:t,value:r(n)});n.outliers&&d.push({color:null,name:c.outliers,value:String(n.outliers)});continue}let a=r(n.y);if(n.y0!==void 0){let i=n.y-n.y0;a=t.type===`bar`&&e.y.type!==`time`?`${i>0?`+`:``}${r(i)}`:`${r(n.y0)} – ${r(n.y)}`}d.push({color:n.color,name:n.label&&p===null?`${n.seriesName} · ${n.label}`:n.seriesName,value:a}),d.push(...A(t,n.index))}if(e.percent){let n=new Map;for(let r of t.items){let t=M(e,r.seriesIndex);t!==null&&Number.isFinite(r.y)&&n.set(t,(n.get(t)??0)+Math.abs(r.y))}t.items.forEach((t,r)=>{let i=M(e,t.seriesIndex),o=i===null?void 0:n.get(i),s=d[f[r]];o&&s&&Number.isFinite(t.y)&&(s.value=`${(e.series[t.seriesIndex].format??e.formatValue)(t.y)} · ${a.formatPercent(Math.abs(t.y)/o*100,e.locale,!0)}`)})}return{title:p??t.xLabel,titleColor:null,rows:d}},M=(e,t)=>e.series[t].hidden?null:e.stacks[t],ne=(e,r,i)=>{let a=[],{plot:o}=r,s=1/0,c=-1/0;for(let l of i.items){let i=e.series[l.seriesIndex],u=i.cols.x[l.index]??l.x;if(i.type===`boxplot`&&l.outlier!==void 0){let e=n.toScreen(r,u+g(i),V(i,l));a.push({kind:`dot`,x:e.x,y:e.y,size:i.outlierSize+3,color:l.color,halo:t.toCss(i.pointColors?.[l.index]??i.color,.2)});continue}if(i.type===`bar`||i.type===`candlestick`||i.type===`boxplot`){let t=r.xToPx(u+g(i)),n=Math.max(i.barHalfWidth/Math.abs(r.xPerPx),1);s=Math.min(s,t-n),c=Math.max(c,t+n),i.type===`bar`&&a.push(...z(e,r,i,l.index));continue}if(i.type===`heatmap`){let e=r.xToPx(u),s=r.yToPx(l.y),c=Math.abs(i.cellHalf.x/r.xPerPx),d=Math.abs(i.cellHalf.y/r.yPerPx),f=n.screenRect(r,e-c,e+c,s-d,s+d),p=n.heatCellStyle(f.width,f.height,i.radius),m=Math.max(o.y,f.y),h=Math.min(o.y+o.height,f.y+f.height),g=Math.max(o.x,f.x),_=Math.min(o.x+o.width,f.x+f.width);h>m&&a.push({kind:`guide`,x:o.x,y:m,width:o.width,height:h-m}),_>g&&a.push({kind:`guide`,x:g,y:o.y,width:_-g,height:o.height});let v=i.cellColors?.[l.index],y=v?t.unpackColor(v):i.color;a.push({kind:`cell`,x:f.x+p.inset,y:f.y+p.inset,width:Math.max(1,f.width-p.inset*2),height:Math.max(1,f.height-p.inset*2),seriesIndex:i.index,index:l.index,color:l.color,ring:N(y),radius:p.radius});continue}let{px:d,py:f}=_(i,l.index,r);if(d<o.x-1||d>o.x+o.width+1||f<o.y-1||f>o.y+o.height+1)continue;let p=i.type===`scatter`?x(i,l.index)+4:Math.max(9,i.lineWidth*2+5),m=i.pointColors?.[l.index]??i.color;a.push({kind:`dot`,x:d,y:f,size:p,color:l.color,halo:t.toCss(m,.2)})}if(c>s){let e=Math.max(4,(c-s)*.14),t=r.horizontal?o.y:o.x,n=t+(r.horizontal?o.height:o.width),i=Math.max(t,s-e),l=Math.min(n,c+e);l>i&&a.unshift({kind:`band`,...r.horizontal?{x:o.x,y:i,width:o.width,height:l-i}:{x:i,y:o.y,width:l-i,height:o.height}})}return a},N=e=>t.luminance(e)>.45?`rgba(15, 23, 42, 0.78)`:`rgba(255, 255, 255, 0.9)`,P=.6,F=(e,t)=>!t.floating&&e.series.some(e=>e!==t&&!e.hidden&&e.type===`bar`&&!e.floating&&e.barOffset===t.barOffset)?0:t.radius,I=(e,t)=>{let n=1/0;for(let r of e.series){if(r.hidden||r.type!==`bar`&&r.type!==`boxplot`)continue;let e=Math.abs(r.barOffset-t.barOffset);e>0&&e<n&&(n=e)}return Number.isFinite(n)?Math.max(0,n/2-t.barHalfWidth):null},L=(e,t,n,r)=>{let i=Math.min(5,Math.max(1.5,r*.08)),a=I(e,n);return a!==null&&(i=Math.min(i,a/Math.abs(t.xPerPx)*.5)),i>=.75?Math.round(i*4)/4:0},R=(e,t,r,i)=>{let a=r.barBase?.[i],o=r.barTop?.[i],s=r.cols.x[i];if(a===void 0||o===void 0||Number.isNaN(a)||Number.isNaN(o)||!Number.isFinite(s))return null;let{plot:c}=t,l=t.xToPx(s+r.barOffset),u=Math.max(r.barHalfWidth/Math.abs(t.xPerPx),.5),d=t.horizontal?c.x:c.y,f=d+(t.horizontal?c.width:c.height),p=e=>Math.min(f+16,Math.max(d-16,Number.isNaN(e)?d:e)),m=p(t.yToPx(a)),h=p(t.yToPx(o));if(Math.abs(m-h)<.5)return null;let g=n.screenRect(t,l-u,l+u,m,h);return g.x>c.x+c.width||g.x+g.width<c.x||g.y>c.y+c.height||g.y+g.height<c.y?null:{...g,radius:Math.min(F(e,r),g.width/2,g.height/2),base:t.horizontal?m<h?`left`:`right`:m>h?`bottom`:`top`}},z=(e,n,r,i)=>{let a=R(e,n,r,i);if(!a)return[];let o=L(e,n,r,a.base===`top`||a.base===`bottom`?a.width:a.height),c=r.pointColors?.[i]??r.color,l=c[3]*s.barOpacity(r,i),u=l<P,d=[{kind:`bar`,...a,seriesIndex:r.index,index:i,color:t.toCss(c,s.barOpacity(r,i)),backdrop:l<.98,ring:u?t.toCss([c[0],c[1],c[2],1]):N(c),grow:o}],f=Math.min(r.barBase?.[i]??NaN,r.barTop?.[i]??NaN),p=Math.max(r.barBase?.[i]??NaN,r.barTop?.[i]??NaN);if(!r.floating||!(p>=f))return d;let m=(p-f)*1e-9;for(let a of e.series)if(a!==r&&!a.hidden&&!a.tooltip&&a.type===`bar`&&a.floating&&a.barOffset===r.barOffset&&a.barBase&&a.barTop)for(let c=0;c<a.cols.count;c++){if(a.cols.x[c]!==r.cols.x[i])continue;let l=Math.min(a.barBase[c],a.barTop[c]),u=Math.max(a.barBase[c],a.barTop[c]);if(!(l>=f-m&&u<=p+m))continue;let h=R(e,n,a,c);if(!h)continue;let g=a.pointColors?.[c]??a.color;d.push({kind:`bar`,...h,seriesIndex:a.index,index:c,color:t.toCss(g,s.barOpacity(a,c)),backdrop:!1,ring:null,grow:o})}return d},B=e=>e.base===`top`||e.base===`bottom`?{x:e.x-e.grow,y:e.y,width:e.width+e.grow*2,height:e.height}:{x:e.x,y:e.y-e.grow,width:e.width,height:e.height+e.grow*2},V=(e,t)=>{let n=e.raw.outliers?.[t.index],r=n?n.indexOf(t.outlier??NaN):-1;return(r>=0?e.cols.outliers?.[t.index]?.[r]:void 0)??t.outlier??0},H=(e,r)=>{let i=[];for(let a of e.series){let e=a.connector;if(!e||a.hidden||a.type!==`bar`||!a.barTop)continue;let{x:o,count:s}=a.cols,c=a.barTop,l=a.barHalfWidth,[u,d]=r.view.x[0]<=r.view.x[1]?r.view.x:[r.view.x[1],r.view.x[0]],f=t.toCss(e.color,.75),p=-1;for(let t=0;t<s&&i.length<1200;t++)if(Number.isFinite(c[t])&&Number.isFinite(o[t])){if(p>=0&&o[t]+l>=u&&o[p]-l<=d){let s=n.toScreen(r,o[p]+a.barOffset+l,c[p]),u=n.toScreen(r,o[t]+a.barOffset-l,c[p]);i.push({x0:s.x,y0:s.y,x1:u.x,y1:u.y,color:f,width:e.width,dash:e.dash})}p=t}}return i},U=(e,n)=>{let r=n.resolve??l,i=t.toCss(n.textMuted,.85);return(e??[]).map(e=>({from:e.from,to:e.to,color:e.color?t.toCss(r(e.color,n.textMuted)):i}))},W={length:6,half:3.5},G=(e,t,n,r)=>{let i={boxes:[],byId:new Map,byRow:new Map,ids:new Set},a=e.x.type===`category`?e.x.categories:null;for(let o of e.series){if(o.type!==`bar`&&o.type!==`scatter`)continue;let e=o.raw.ids;if(e)for(let t of e)t!==void 0&&i.ids.add(t);if(o.hidden||!o.tooltip)continue;let{x:s,y:c,count:l}=o.cols,u=o.type===`bar`&&o.barBase&&o.barTop,d=g(o);for(let f=0;f<l;f++){let l=u?o.barBase[f]:c[f],p=u?o.barTop[f]:c[f];if(!Number.isFinite(s[f])||!Number.isFinite(l)||!Number.isFinite(p))continue;let m=u?o.barHalfWidth/Math.abs(t.xPerPx):x(o,f)/2,h=n(Math.min(l,p)),g=n(Math.max(l,p)),_=u?0:m,v={c:r(s[f]+d),half:m,start:h,end:g,lo:Math.min(h,g)-_,hi:Math.max(h,g)+_,dot:!u};i.boxes.push(v);let y=e?.[f];y!==void 0&&!i.byId.has(y)&&i.byId.set(y,v);let b=a?a[Math.round(s[f])]:String(o.raw.x[f]);b!==void 0&&!i.byRow.has(b)&&i.byRow.set(b,v)}}return i},K=8,q=4,J=e=>{let t=e.map(e=>[e.lo-q,e.hi+q]).sort((e,t)=>e[0]-t[0]),n=[];for(let e of t){let t=n[n.length-1];t&&e[0]<=t[1]?t[1]=Math.max(t[1],e[1]):n.push(e)}return n},Y=(e,t)=>e.some(([e,n])=>t>e+1e-6&&t<n-1e-6),X=(e,t,n,r)=>{let i=[t];for(let[t,n]of e)i.push(t,n);let a=null;for(let o of i){let i=r*(o-t);i<0||r*(n-o)<0||Y(e,o)||(a===null||i<r*(a-t))&&(a=o)}return a},re=(e,t)=>{let n=e.find(([e,n])=>t>e+1e-6&&t<n-1e-6);if(!n)return t;let[r,i]=n;return t-r<=i-t?r:i},Z=e=>{let t=[],n=(e,t)=>Math.abs(e-t)<1e-6;for(let r of e){let e=t[t.length-1];if(e&&n(e[0],r[0])&&n(e[1],r[1]))continue;let i=t[t.length-2];i&&e&&(n(i[0],e[0])&&n(e[0],r[0])||n(i[1],e[1])&&n(e[1],r[1]))&&t.pop(),t.push(r)}return t},ie=(e,t,n,r,i,a)=>{let o=e.c,s=t.c,c=n+i*K,l=i*(r-c)>=0,u=Math.min(o,s),d=Math.max(o,s),f=d-u<.5?[]:a.filter(n=>n!==e&&n!==t&&n.c+n.half>u&&n.c-n.half<d);if(l){let e=X(J(f),c,r,i);if(e!==null)return Z([[n,o],[e,o],[e,s],[r,s]])}let p=Math.sign(s-o)||1,m=new Map;for(let e of f){if(Math.abs(e.c-o)<.5||Math.abs(e.c-s)<.5)continue;let t=Math.round(e.c*2),n=m.get(t);n?(n.half=Math.max(n.half,e.half),n.of.push(e)):m.set(t,{c:e.c,half:e.half,of:[e]})}let h=[{c:o,half:e.half,lanes:[]},...[...m.values()].sort((e,t)=>p*(e.c-t.c)).map(e=>({c:e.c,half:e.half,lanes:J(e.of)})),{c:s,half:t.half,lanes:[]}],g=r-i*K,_=[[n,o],[c,o]],v=c;for(let e=0;e+1<h.length;e++){let t=h[e],n=h[e+1],a=Math.abs(n.c-t.c)<.5?t.c+p*(Math.max(t.half,n.half)+q):(t.c+p*t.half+n.c-p*n.half)/2,o=e+2===h.length?l&&i*(r-v)>=0?v:g:re(n.lanes,l?v:g);o!==v&&(_.push([v,a],[o,a]),v=o)}return _.push([v,s],[r,s]),Z(_)},ae=(e,t,r)=>{if(!r.length)return[];let i=t.horizontal,a=(e,t)=>i?{x:e,y:t}:{x:t,y:e},o=e=>{let r=n.toScreen(t,0,e);return i?r.x:r.y},s=e=>{let r=n.toScreen(t,e,0);return i?r.y:r.x},c=Math.sign(o(t.view.y[1])-o(t.view.y[0]))||1,l=G(e,t,o,s),u=e=>l.byId.get(e)??(l.ids.has(e)?void 0:l.byRow.get(e)),{length:d,half:f}=W,p=[];for(let e of r){let t=u(e.from),n=u(e.to);if(!t||!n||t===n)continue;let r=t.end+(t.dot?c*t.half:0),i=n.start-c*(n.dot?n.half+1:1),o=i-c*d,s=ie(t,n,r,o,c,l.boxes);p.push({points:s.map(([e,t])=>a(e,t)),head:[a(i,n.c),a(o,n.c-f),a(o,n.c+f)],color:e.color,width:1.25})}return p},oe=12,Q=e=>{if(!e.series.length||e.series.some(e=>e.type!==`heatmap`))return null;let n=e.series.find(e=>!e.hidden&&e.colorLut),r=n?.colorLut;if(!n||!r)return null;let i=[];for(let e=0;e<oe;e++){let n=r[Math.round(e/11*(r.length-1))];i.push(t.toCss(t.unpackColor(n??0)))}let a=n.format??e.formatValue,[o,s]=n.valueRange,c=[{at:0,text:a(o)},{at:1,text:a(s)}],l=n.colorMidpoint;return l!==null&&l>o&&l<s&&c.splice(1,0,{at:.5,text:a(l)}),{seriesIndex:n.index,stops:i,labels:c}},se=(e,t,n)=>e===void 0?n>1||Q(t)!==null:!!e,ce=e=>e===`scatter`?`dot`:e===`line`?`line`:`square`,$=(e,t,n)=>n??(e.tooltipMode===`axis`&&t.items.some(t=>{let n=e.series[t.seriesIndex].type;return n===`line`||n===`area`})&&!t.items.some(t=>{let n=e.series[t.seriesIndex].type;return n===`bar`||n===`candlestick`||n===`boxplot`})),le=(e,t,n,r)=>{if(!$(e,n,r))return null;let i=n.items[0],a=t.xToPx(e.series[i.seriesIndex]?.cols.x[i.index]??s.toPlotX(e,i.x)),o=t.horizontal?t.plot.y:t.plot.x,c=o+(t.horizontal?t.plot.height:t.plot.width);return a>=o&&a<=c?a:null};exports.ARROW_HEAD=W,exports.DEFAULT_PADDING=c,exports.collectPointLabels=h,exports.colorLegend=Q,exports.connectorSegments=H,exports.contrastRing=N,exports.crosshairAt=le,exports.dependencyArrows=ae,exports.dotSize=x,exports.fallbackResolve=l,exports.hitTest=D,exports.hoverItemOf=T,exports.hoverMarks=ne,exports.labelCell=m,exports.layoutChart=d,exports.legendShape=ce,exports.legendShown=se,exports.liftedBarRect=B,exports.pointOf=_,exports.resolveAnnotations=u,exports.resolveDependencies=U,exports.sameHover=O,exports.showsCrosshair=$,exports.tooltipContent=j;
|
|
2
2
|
//# sourceMappingURL=scene.cjs.map
|