@carto/ps-react-ui 4.25.0 → 4.26.0

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.
Files changed (67) hide show
  1. package/dist/{actions-B1ss030_.js → actions-DXfQMrll.js} +56 -46
  2. package/dist/actions-DXfQMrll.js.map +1 -0
  3. package/dist/item-color-C1cu6EJd.js +20 -0
  4. package/dist/item-color-C1cu6EJd.js.map +1 -0
  5. package/dist/types/widgets-v2/bar/types.d.ts +6 -0
  6. package/dist/types/widgets-v2/histogram/bins.d.ts +7 -0
  7. package/dist/types/widgets-v2/histogram/download.d.ts +2 -2
  8. package/dist/types/widgets-v2/histogram/index.d.ts +2 -1
  9. package/dist/types/widgets-v2/histogram/options.d.ts +1 -1
  10. package/dist/types/widgets-v2/histogram/transforms.d.ts +5 -4
  11. package/dist/types/widgets-v2/histogram/types.d.ts +22 -5
  12. package/dist/types/widgets-v2/index.d.ts +1 -1
  13. package/dist/types/widgets-v2/pie/types.d.ts +6 -0
  14. package/dist/types/widgets-v2/scatterplot/download.d.ts +2 -2
  15. package/dist/types/widgets-v2/scatterplot/index.d.ts +2 -1
  16. package/dist/types/widgets-v2/scatterplot/points.d.ts +7 -0
  17. package/dist/types/widgets-v2/scatterplot/transforms.d.ts +4 -3
  18. package/dist/types/widgets-v2/scatterplot/types.d.ts +21 -2
  19. package/dist/types/widgets-v2/timeseries/types.d.ts +6 -0
  20. package/dist/types/widgets-v2/utils/item-color.d.ts +26 -0
  21. package/dist/widgets-v2/actions.js +1 -1
  22. package/dist/widgets-v2/bar.js +66 -57
  23. package/dist/widgets-v2/bar.js.map +1 -1
  24. package/dist/widgets-v2/histogram.js +103 -71
  25. package/dist/widgets-v2/histogram.js.map +1 -1
  26. package/dist/widgets-v2/pie.js +98 -78
  27. package/dist/widgets-v2/pie.js.map +1 -1
  28. package/dist/widgets-v2/scatterplot.js +119 -79
  29. package/dist/widgets-v2/scatterplot.js.map +1 -1
  30. package/dist/widgets-v2/timeseries.js +70 -61
  31. package/dist/widgets-v2/timeseries.js.map +1 -1
  32. package/dist/widgets-v2.js +1 -1
  33. package/dist/widgets-v2.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/widgets-v2/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  36. package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +48 -5
  37. package/src/widgets-v2/bar/options.test.ts +106 -0
  38. package/src/widgets-v2/bar/options.ts +25 -14
  39. package/src/widgets-v2/bar/types.ts +6 -0
  40. package/src/widgets-v2/histogram/bins.ts +22 -0
  41. package/src/widgets-v2/histogram/download.test.ts +10 -0
  42. package/src/widgets-v2/histogram/download.ts +7 -3
  43. package/src/widgets-v2/histogram/index.ts +3 -0
  44. package/src/widgets-v2/histogram/options.test.ts +62 -0
  45. package/src/widgets-v2/histogram/options.ts +38 -17
  46. package/src/widgets-v2/histogram/transforms.test.ts +21 -7
  47. package/src/widgets-v2/histogram/transforms.ts +26 -12
  48. package/src/widgets-v2/histogram/types.ts +25 -5
  49. package/src/widgets-v2/index.ts +6 -1
  50. package/src/widgets-v2/pie/options.test.ts +91 -0
  51. package/src/widgets-v2/pie/options.ts +50 -20
  52. package/src/widgets-v2/pie/types.ts +6 -0
  53. package/src/widgets-v2/scatterplot/download.test.ts +9 -0
  54. package/src/widgets-v2/scatterplot/download.ts +5 -3
  55. package/src/widgets-v2/scatterplot/index.ts +3 -0
  56. package/src/widgets-v2/scatterplot/options.test.ts +78 -0
  57. package/src/widgets-v2/scatterplot/options.ts +35 -11
  58. package/src/widgets-v2/scatterplot/points.ts +35 -0
  59. package/src/widgets-v2/scatterplot/transforms.test.ts +19 -0
  60. package/src/widgets-v2/scatterplot/transforms.ts +23 -18
  61. package/src/widgets-v2/scatterplot/types.ts +25 -2
  62. package/src/widgets-v2/timeseries/options.test.ts +65 -0
  63. package/src/widgets-v2/timeseries/options.ts +32 -17
  64. package/src/widgets-v2/timeseries/types.ts +6 -0
  65. package/src/widgets-v2/utils/item-color.test.ts +74 -0
  66. package/src/widgets-v2/utils/item-color.ts +55 -0
  67. package/dist/actions-B1ss030_.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pie.js","names":["Theme","EChartsOption","echarts","CallbackDataParams","buildGridConfig","buildLegendConfig","buildSeriesLabelConfig","createTooltipFormatter","createTooltipPositioner","niceNum","OptionFactory","OptionFactoryContext","mergeOptions","resolveThemeColor","WidgetSeries","PieEChartsOption","PieOptionFactoryInput","PieOptionsInput","PieWidgetData","DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","hasLegend","type","itemGap","selectedMode","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","buildPieTooltipFormatter","Object","values","qualitative","bold","Record","series","colorBy","avoidLabelOverlap","selectedOffset","legendHoverLink","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","undefined","length","Set","option","data","ctx","structural","Partial","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","swatch","dataIndex","colorFn","base","datum","value","name","has","modifyAlpha","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","Infinity","d","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","separator","map","s","source","_","i","template","templateObj","templateLabel","templateItemStyle","const","datasetIndex","center","itemName","selected","fromEntries","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","barColorFn","seriesIdx","seriesIndex","seriesSwatch","right","containLabel","overrideColor","barMaxWidth","focus","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","buildHorizontalBarTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","Number","isFinite","Box","Skeleton","SxProps","Theme","OUTER_SIZE","HOLE_SIZE","styles","root","display","flexDirection","alignItems","justifyContent","minHeight","py","gap","spacing","donut","position","ring","width","height","hole","zIndex","borderRadius","bgcolor","label","legend","legendItem","Record","PieSkeletonProps","count","PieSkeleton","t0","$","_c","t1","t2","Symbol","for","t3","t4","map","_temp","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadContext","DownloadItem","PieWidgetData","createPieDownloadConfig","args","filename","getData","ctx","seriesNames","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","i","series","entries","seriesName","slice","name","value"],"sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Bottom-left, same as every other widget — `buildLegendConfig`'s\n // `left: 0` is kept deliberately. The wider `itemGap` gives chips\n // breathing room in the typical 3–6 category case.\n type: 'scroll',\n itemGap: 16,\n // The legend is presentational only here — the pie has its own\n // click-to-select affordance on the slices themselves, so legend\n // clicks toggling series visibility would be a second, redundant/\n // conflicting interaction model. Hover-highlight is disabled per\n // series via `legendHoverLink` (ECharts has no legend-level knob\n // for it).\n selectedMode: false,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n legendHoverLink: false,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n // An explicit `[]` (deselected down to zero via chart clicks) is treated\n // the same as no selection: the pie has no bar/histogram-style \"nothing\n // selected\" affordance, so dimming every slice would just look broken —\n // it renders fully active, same as the no-interaction state.\n const selectionSet =\n selection === undefined || selection === null || selection.length === 0\n ? null\n : new Set<string | number>(selection)\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n //\n // `selectionSet` is the *included* set, same direct semantics as\n // bar/histogram/timeseries (no ADR-014 exclusion inversion). Dim a slice\n // when its name is NOT in the set. `selectionSet` is never a non-null\n // empty Set — the collapse above (`selection.length === 0 → null`) rules\n // that out — so there's no \"dim everything\" case here, unlike a widget\n // that gives `[]` its own \"selected down to nothing\" meaning.\n const colorFn = (params: CallbackDataParams): string => {\n const base = resolvePaletteColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // ECharts anchors EVERY slice's `position: 'center'` label at the same\n // point, so at most one of them can ever be legible — the donut design\n // leans into that (one KPI inside the ring) and picks a single slice\n // below. A consumer that moves the labels off the centre gives each\n // slice its own anchor (`'outside'` with leader lines is what the PDF\n // export uses, `'inside'` / `'insideTop'` … likewise), and there the\n // single-label rule is simply wrong: every slice must render its own\n // label. Read the position off the structural template, which already\n // carries the consumer's `optionsOverride`.\n const templateLabelPosition = (\n broadcastTemplate as { label?: { position?: unknown } }\n ).label?.position\n const isCenterLabel =\n templateLabelPosition === undefined || templateLabelPosition === 'center'\n\n // Which slice renders the centre value+name: the greatest value among\n // the *included* slices (all of them when there's no active\n // selection), computed locally — no query round-trip. Only that one\n // slice's formatter call returns text; every other slice returns ''\n // so exactly one label ever renders at the shared centre anchor. Only\n // `typeof value === 'number'` participates — if every included slice's\n // value is non-numeric, `centerMaxName` stays `undefined` and no slice\n // matches it in `labelTextFormatter` below, so the chart renders with no\n // centre label at all (graceful no-op, not a crash). Skipped entirely\n // for off-centre labels, where every slice labels itself.\n const centerData = seriesArr[0] ?? []\n let centerMaxName: string | number | undefined\n let centerMaxValue = -Infinity\n for (const d of centerData) {\n if (selectionSet && !selectionSet.has(d.name)) continue\n if (typeof d.value === 'number' && d.value > centerMaxValue) {\n centerMaxValue = d.value\n centerMaxName = d.name\n }\n }\n\n // Slice label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n if (name == null) return ''\n if (isCenterLabel && name !== centerMaxName) return ''\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n // The blank line is what separates the big centre KPI from its\n // caption. Off-centre labels sit next to their own slice and are\n // laid out against their neighbours, so the spacer only inflates\n // each label's bounding box — enough, with a hidden `{b|…}` block,\n // to make ECharts drop colliding labels altogether.\n const separator = isCenterLabel ? '\\n\\n' : '\\n'\n return `{c|${formattedValue}}${separator}{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n legendHoverLink: false,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: colorFn,\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n //\n // Exclusion is conveyed purely via `colorFn`/`labelTextFormatter`\n // dimming above, never via the legend's `selected` map: for a pie\n // series, ECharts treats `legend.selected[name] = false` as \"remove\n // this data point,\" which recomputes every remaining slice's angle —\n // the excluded slice disappears instead of rendering dimmed. Forcing\n // every name to `true` on every render also overrides ECharts' own\n // internal toggle state from a native legend click (which flips a\n // name to `false` and hides it before our `legendselectchanged`\n // handler gets a chance to react), so a legend click never leaves a\n // slice structurally removed — only the color/label dimming reflects\n // exclusion, and it stays in sync with the slice itself since both\n // read `selectionSet` on the same render.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n (seriesArr[0] ?? []).map((d) => [String(d.name), true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const barColorFn = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n const base = (seriesSwatch ?? params.color) as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n legendHoverLink: false,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: { color: barColorFn },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n // Mirrors the donut branch's `selected` reset above — `selectedMode:\n // false` blocks the native legend click that would otherwise undo an\n // ECharts-internal toggle, so without forcing every entry back to\n // `true` here a prior native toggle (from before `selectedMode` took\n // effect, or a stale `keepAlive` instance) would stay hidden forever\n // with no way to restore it.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n seriesArr.map((_, i) => [series?.[i]?.name ?? `Series ${i + 1}`, true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst OUTER_SIZE = 160\nconst HOLE_SIZE = 96\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: ({ spacing }) => spacing(2),\n },\n donut: {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n ring: {\n width: OUTER_SIZE,\n height: OUTER_SIZE,\n },\n hole: {\n position: 'absolute',\n zIndex: 1,\n width: HOLE_SIZE,\n height: HOLE_SIZE,\n borderRadius: '50%',\n bgcolor: 'background.paper',\n },\n label: {\n position: 'absolute',\n zIndex: 2,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: ({ spacing }) => spacing(0.5),\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\n/**\n * Loading state for the Pie widget. Mirrors the donut silhouette — a ring\n * (gray circle with a background-coloured hole punched out), a stacked\n * value/name stub in the centre, and a centered legend stub below — so the\n * skeleton reads as \"a donut chart\" rather than a solid disc.\n *\n * Single donut only: multi-series pie loads as a horizontal bar chart, so\n * rendering one ring stays honest regardless of `count`.\n */\nexport function PieSkeleton({ count }: PieSkeletonProps) {\n // `count` is accepted for API compatibility but intentionally unused: the\n // skeleton always renders a single donut, since multi-series pie loads as a\n // horizontal bar chart rather than multiple donuts.\n void count\n return (\n <Box sx={styles.root}>\n <Box sx={styles.donut}>\n <Skeleton variant='circular' sx={styles.ring} />\n <Box sx={styles.hole} />\n <Box sx={styles.label}>\n <Skeleton width={56} height={18} />\n <Skeleton width={36} height={8} />\n </Box>\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;AAsBA,IAAMmB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzBC,UACAC,cACAC,qBACoC;CACpC,OAAO;EACLC,QAAQ;GACN,GAAGnB,EAAkB;IAAEoB,WAAW;IAAMF;GAAe,CAAC;GAIxDG,MAAM;GACNC,SAAS;GAOTC,cAAc;EAChB;EACAC,SAAS;GAKPC,SAAS;GACTC,iBAAiBV,EAAMW,QAAQC,KAAK;GACpCC,aAAa;GACbC,SAAS,CAACC,SAASf,EAAMgB,QAAQ,CAAC,CAAC,GAAGD,SAASf,EAAMgB,QAAQ,CAAC,CAAC,CAAC;GAChEC,WAAW;IACTC,OAAOlB,EAAMW,QAAQQ,OAAOC;IAC5BC,UAAU;IACVC,YAAYtB,EAAMuB,WAAWC,QAAQF;GACvC;GACAG,UAAUtC,EAAwBa,CAAK;GACvCC,WAAWyB,EAAyBzB,GAAWC,CAAc;EAC/D;EAIAgB,OAAOS,OAAOC,OACX5B,EAAMW,QACJkB,aAAaC,QAAQ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A,OAiBG,kBAAC,GAAD;EAA6B,IAAArC,EAAMqB;EAAnC,UAAA,CACE,kBAAC,GAAD;GAAkB,SAAA;GAAkB,OAAA;GAAW,QAAA;EAAC,CAAA,GAChD,kBAAC,GAAD;GAAiB,OAAA;GAAY,QAAA;EAAC,CAAA,CAF5B;CAAM,GAAA,UAAUgB,GAAhB;AAGE;;;ACzEhB,SAAgBM,EAAwBC,GAOrB;CACjB,IAAMS,IAAwB,CAAA;CA2B9B,OA1BIT,EAAKK,gBACPI,EAAMC,KACJf,EAAqB;EACnBM,UAAUD,EAAKC;EACfI,cAAcL,EAAKK;EACnBM,YAAYX,EAAKO;EACjBK,iBAAiBZ,EAAKQ;CACxB,CAAC,CACH,GAEFC,EAAMC,KACJhB,EAAqB;EACnBO,UAAUD,EAAKC;EACfY,UAAUV,MAAQ;GAChB,IAAMW,IAAOd,EAAKE,QAAQC,CAAG,GACvBY,IAAoB,CAAC;IAAC;IAAU;IAAQ;GAAO,CAAC;GACtD,KAAK,IAAM,CAACC,GAAGC,MAAWH,EAAKI,QAAQ,GAAG;IACxC,IAAMC,IAAanB,EAAKI,cAAcY,MAAM,UAAUA,IAAI;IAC1D,KAAK,IAAMI,KAASH,GAClBF,EAAKL,KAAK;KAACS;KAAYC,EAAMC;KAAMD,EAAME;IAAK,CAAC;GAEnD;GACA,OAAOP;EACT;CACF,CAAC,CACH,GACON;AACT"}
1
+ {"version":3,"file":"pie.js","names":["Theme","EChartsOption","echarts","CallbackDataParams","buildGridConfig","buildLegendConfig","buildSeriesLabelConfig","createTooltipFormatter","createTooltipPositioner","niceNum","OptionFactory","OptionFactoryContext","mergeOptions","resolveThemeColor","createItemColorResolver","WidgetSeries","PieEChartsOption","PieOptionFactoryInput","PieOptionsInput","PieWidgetData","DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","hasLegend","type","itemGap","selectedMode","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","buildPieTooltipFormatter","Object","values","qualitative","bold","Record","series","colorBy","avoidLabelOverlap","selectedOffset","legendHoverLink","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","undefined","length","Set","option","data","ctx","structural","Partial","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","swatch","dataIndex","makeColorFn","datums","template","baseColor","fallback","base","datum","value","name","has","modifyAlpha","templateLabelPosition","isCenterLabel","centerData","centerMaxName","centerMaxValue","Infinity","d","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","separator","map","s","source","i","templateObj","templateLabel","templateItemStyle","const","datasetIndex","center","itemName","selected","fromEntries","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","paletteColor","seriesIdx","seriesIndex","seriesSwatch","makeBarColorFn","right","containLabel","overrideColor","barMaxWidth","focus","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","_","buildHorizontalBarTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","Number","isFinite","Box","Skeleton","SxProps","Theme","OUTER_SIZE","HOLE_SIZE","styles","root","display","flexDirection","alignItems","justifyContent","minHeight","py","gap","spacing","donut","position","ring","width","height","hole","zIndex","borderRadius","bgcolor","label","legend","legendItem","Record","PieSkeletonProps","count","PieSkeleton","t0","$","_c","t1","t2","Symbol","for","t3","t4","map","_temp","i","buildCsvDownloadItem","buildPngDownloadItem","DownloadContext","DownloadItem","PieWidgetData","createPieDownloadConfig","args","filename","getData","ctx","seriesNames","getCaptureEl","HTMLElement","pngPixelRatio","pngBackgroundColor","items","push","pixelRatio","backgroundColor","getRows","data","rows","i","series","entries","seriesName","slice","name","value"],"sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { createItemColorResolver } from '../utils/item-color'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Bottom-left, same as every other widget — `buildLegendConfig`'s\n // `left: 0` is kept deliberately. The wider `itemGap` gives chips\n // breathing room in the typical 3–6 category case.\n type: 'scroll',\n itemGap: 16,\n // The legend is presentational only here — the pie has its own\n // click-to-select affordance on the slices themselves, so legend\n // clicks toggling series visibility would be a second, redundant/\n // conflicting interaction model. Hover-highlight is disabled per\n // series via `legendHoverLink` (ECharts has no legend-level knob\n // for it).\n selectedMode: false,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n legendHoverLink: false,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n // An explicit `[]` (deselected down to zero via chart clicks) is treated\n // the same as no selection: the pie has no bar/histogram-style \"nothing\n // selected\" affordance, so dimming every slice would just look broken —\n // it renders fully active, same as the no-interaction state.\n const selectionSet =\n selection === undefined || selection === null || selection.length === 0\n ? null\n : new Set<string | number>(selection)\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n theme,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n //\n // `selectionSet` is the *included* set, same direct semantics as\n // bar/histogram/timeseries (no ADR-014 exclusion inversion). Dim a slice\n // when its name is NOT in the set. `selectionSet` is never a non-null\n // empty Set — the collapse above (`selection.length === 0 → null`) rules\n // that out — so there's no \"dim everything\" case here, unlike a widget\n // that gives `[]` its own \"selected down to nothing\" meaning.\n //\n // The base colour is the slice's own `color`, else the template's\n // `itemStyle.color`, else the per-data palette swatch.\n const makeColorFn = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: resolvePaletteColor,\n })\n return (params: CallbackDataParams): string => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n // ECharts anchors EVERY slice's `position: 'center'` label at the same\n // point, so at most one of them can ever be legible — the donut design\n // leans into that (one KPI inside the ring) and picks a single slice\n // below. A consumer that moves the labels off the centre gives each\n // slice its own anchor (`'outside'` with leader lines is what the PDF\n // export uses, `'inside'` / `'insideTop'` … likewise), and there the\n // single-label rule is simply wrong: every slice must render its own\n // label. Read the position off the structural template, which already\n // carries the consumer's `optionsOverride`.\n const templateLabelPosition = (\n broadcastTemplate as { label?: { position?: unknown } }\n ).label?.position\n const isCenterLabel =\n templateLabelPosition === undefined || templateLabelPosition === 'center'\n\n // Which slice renders the centre value+name: the greatest value among\n // the *included* slices (all of them when there's no active\n // selection), computed locally — no query round-trip. Only that one\n // slice's formatter call returns text; every other slice returns ''\n // so exactly one label ever renders at the shared centre anchor. Only\n // `typeof value === 'number'` participates — if every included slice's\n // value is non-numeric, `centerMaxName` stays `undefined` and no slice\n // matches it in `labelTextFormatter` below, so the chart renders with no\n // centre label at all (graceful no-op, not a crash). Skipped entirely\n // for off-centre labels, where every slice labels itself.\n const centerData = seriesArr[0] ?? []\n let centerMaxName: string | number | undefined\n let centerMaxValue = -Infinity\n for (const d of centerData) {\n if (selectionSet && !selectionSet.has(d.name)) continue\n if (typeof d.value === 'number' && d.value > centerMaxValue) {\n centerMaxValue = d.value\n centerMaxName = d.name\n }\n }\n\n // Slice label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n if (name == null) return ''\n if (isCenterLabel && name !== centerMaxName) return ''\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n // The blank line is what separates the big centre KPI from its\n // caption. Off-centre labels sit next to their own slice and are\n // laid out against their neighbours, so the spacer only inflates\n // each label's bounding box — enough, with a hidden `{b|…}` block,\n // to make ECharts drop colliding labels altogether.\n const separator = isCenterLabel ? '\\n\\n' : '\\n'\n return `{c|${formattedValue}}${separator}{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n legendHoverLink: false,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: makeColorFn(s, templateObj),\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n //\n // Exclusion is conveyed purely via `colorFn`/`labelTextFormatter`\n // dimming above, never via the legend's `selected` map: for a pie\n // series, ECharts treats `legend.selected[name] = false` as \"remove\n // this data point,\" which recomputes every remaining slice's angle —\n // the excluded slice disappears instead of rendering dimmed. Forcing\n // every name to `true` on every render also overrides ECharts' own\n // internal toggle state from a native legend click (which flips a\n // name to `false` and hides it before our `legendselectchanged`\n // handler gets a chance to react), so a legend click never leaves a\n // slice structurally removed — only the color/label dimming reflects\n // exclusion, and it stays in sync with the slice itself since both\n // read `selectionSet` on the same render.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n (seriesArr[0] ?? []).map((d) => [String(d.name), true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n // The base colour is the datum's own `color`, else the template's\n // `itemStyle.color`, else the per-series palette swatch.\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const paletteColor = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n return (seriesSwatch ?? params.color) as string\n }\n const makeBarColorFn = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: paletteColor,\n })\n return (params: CallbackDataParams): string => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((s, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n legendHoverLink: false,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: {\n color: makeBarColorFn(s, seriesTemplates[i] ?? seriesTemplates[0]),\n },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n // Mirrors the donut branch's `selected` reset above — `selectedMode:\n // false` blocks the native legend click that would otherwise undo an\n // ECharts-internal toggle, so without forcing every entry back to\n // `true` here a prior native toggle (from before `selectedMode` took\n // effect, or a stale `keepAlive` instance) would stay hidden forever\n // with no way to restore it.\n legend: {\n ...baseLegend,\n show: true,\n selectedMode: false,\n selected: Object.fromEntries(\n seriesArr.map((_, i) => [series?.[i]?.name ?? `Series ${i + 1}`, true]),\n ),\n },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst OUTER_SIZE = 160\nconst HOLE_SIZE = 96\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: ({ spacing }) => spacing(2),\n },\n donut: {\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n ring: {\n width: OUTER_SIZE,\n height: OUTER_SIZE,\n },\n hole: {\n position: 'absolute',\n zIndex: 1,\n width: HOLE_SIZE,\n height: HOLE_SIZE,\n borderRadius: '50%',\n bgcolor: 'background.paper',\n },\n label: {\n position: 'absolute',\n zIndex: 2,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: ({ spacing }) => spacing(0.5),\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\n/**\n * Loading state for the Pie widget. Mirrors the donut silhouette — a ring\n * (gray circle with a background-coloured hole punched out), a stacked\n * value/name stub in the centre, and a centered legend stub below — so the\n * skeleton reads as \"a donut chart\" rather than a solid disc.\n *\n * Single donut only: multi-series pie loads as a horizontal bar chart, so\n * rendering one ring stays honest regardless of `count`.\n */\nexport function PieSkeleton({ count }: PieSkeletonProps) {\n // `count` is accepted for API compatibility but intentionally unused: the\n // skeleton always renders a single donut, since multi-series pie loads as a\n // horizontal bar chart rather than multiple donuts.\n void count\n return (\n <Box sx={styles.root}>\n <Box sx={styles.donut}>\n <Skeleton variant='circular' sx={styles.ring} />\n <Box sx={styles.hole} />\n <Box sx={styles.label}>\n <Skeleton width={56} height={18} />\n <Skeleton width={36} height={8} />\n </Box>\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: (ctx: DownloadContext) => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAMoB,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgBC,EAAW,EACzBC,UACAC,cACAC,qBACoC;CACpC,OAAO;EACLC,QAAQ;GACN,GAAGpB,EAAkB;IAAEqB,WAAW;IAAMF;GAAe,CAAC;GAIxDG,MAAM;GACNC,SAAS;GAOTC,cAAc;EAChB;EACAC,SAAS;GAKPC,SAAS;GACTC,iBAAiBV,EAAMW,QAAQC,KAAK;GACpCC,aAAa;GACbC,SAAS,CAACC,SAASf,EAAMgB,QAAQ,CAAC,CAAC,GAAGD,SAASf,EAAMgB,QAAQ,CAAC,CAAC,CAAC;GAChEC,WAAW;IACTC,OAAOlB,EAAMW,QAAQQ,OAAOC;IAC5BC,UAAU;IACVC,YAAYtB,EAAMuB,WAAWC,QAAQF;GACvC;GACAG,UAAUvC,EAAwBc,CAAK;GACvCC,WAAWyB,EAAyBzB,GAAWC,CAAc;EAC/D;EAIAgB,OAAOS,OA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KAAK,IAAMI,KAASH,GAClBF,EAAKL,KAAK;KAACS;KAAYC,EAAMC;KAAMD,EAAME;IAAK,CAAC;GAEnD;GACA,OAAOP;EACT;CACF,CAAC,CACH,GACON;AACT"}
@@ -2,12 +2,37 @@ import { r as e } from "../zoom-toggle-KA63b6-J.js";
2
2
  import { n as t, t as n } from "../download--wRRnf19.js";
3
3
  import { r, t as i } from "../utils-ClB6nn4w.js";
4
4
  import { a, d as o, f as s, i as c, s as l, u } from "../chart-config-BWxjodlt.js";
5
- import { c as d } from "react/compiler-runtime";
6
- import { Box as f, Skeleton as p } from "@mui/material";
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
- import * as g from "echarts";
5
+ import { t as d } from "../item-color-C1cu6EJd.js";
6
+ import { c as f } from "react/compiler-runtime";
7
+ import { Box as p, Skeleton as m } from "@mui/material";
8
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
9
+ import * as _ from "echarts";
10
+ //#region src/widgets-v2/scatterplot/points.ts
11
+ function v(e) {
12
+ return x(e) ? e : [e.x, e.y];
13
+ }
14
+ function y(e) {
15
+ if (Array.isArray(e)) return e.length === 2 && S(e[0]) && S(e[1]);
16
+ if (typeof e != "object" || !e) return !1;
17
+ let { x: t, y: n } = e;
18
+ return S(t) && S(n);
19
+ }
20
+ function b(e, t, n) {
21
+ return x(e) ? [t, n] : {
22
+ ...e,
23
+ x: t,
24
+ y: n
25
+ };
26
+ }
27
+ function x(e) {
28
+ return Array.isArray(e);
29
+ }
30
+ function S(e) {
31
+ return typeof e == "number" && Number.isFinite(e);
32
+ }
33
+ //#endregion
9
34
  //#region src/widgets-v2/scatterplot/options.ts
10
- function _({ theme: e, xFormatter: t, yFormatter: n }) {
35
+ function C({ theme: e, xFormatter: t, yFormatter: n }) {
11
36
  return {
12
37
  grid: {
13
38
  left: parseInt(e.spacing(1)),
@@ -27,7 +52,7 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
27
52
  fontFamily: e.typography.caption.fontFamily
28
53
  },
29
54
  position: o(e),
30
- formatter: x(t, n)
55
+ formatter: D(t, n)
31
56
  },
32
57
  legend: { ...l({
33
58
  hasLegend: !1,
@@ -71,33 +96,41 @@ function _({ theme: e, xFormatter: t, yFormatter: n }) {
71
96
  }
72
97
  };
73
98
  }
74
- function v(t) {
75
- let { theme: n, xFormatter: a, yFormatter: o, optionsOverride: s } = t, c = t.series, l = t.symbolSize ?? 8, u = t.selection, d = u && u.length > 0 ? new Set(u) : null;
76
- return (t, u, f) => {
99
+ function w(t) {
100
+ let { theme: n, xFormatter: a, yFormatter: o, optionsOverride: s } = t, c = t.series, l = t.symbolSize ?? 8, u = t.selection, f = u && u.length > 0 ? new Set(u) : null;
101
+ return (t, u, p) => {
77
102
  if (t == null) {
78
- let e = _({
103
+ let e = C({
79
104
  theme: n,
80
105
  xFormatter: a,
81
106
  yFormatter: o
82
107
  });
83
108
  return s ? r(e, s) : e;
84
109
  }
85
- let p = Array.isArray(u) ? u : [];
86
- if (p.length === 0) return {
110
+ let m = Array.isArray(u) ? u : [];
111
+ if (m.length === 0) return {
87
112
  ...t,
88
113
  dataset: [],
89
114
  series: []
90
115
  };
91
- let m = p.length > 1, h = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, v = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, x = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, C = typeof t.xAxis == "object" && !Array.isArray(t.xAxis) ? t.xAxis : {}, w = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, T = f?.formatter, { niceMinX: E, niceMaxX: D, niceMinY: O, niceMaxY: k } = S(p), A = (e) => (t) => {
92
- let n = t.color;
93
- if (!d) return n;
94
- let r = `${e}:${t.dataIndex}`;
95
- return d.has(r) ? n : g.color.modifyAlpha(n, .15);
96
- }, j = y(t.dataZoom, m), M = j?.hasXSlider ?? !1, N = j?.hasYSlider ?? !1, P = typeof v.bottom == "number" ? v.bottom : 24, F = m ? 56 : P, I = M ? F + e.sliderHeight + e.sliderGap : F, L = typeof v.right == "number" ? v.right : 8, R = N ? L + e.sliderHeight + e.sliderGap : L;
116
+ let h = m.length > 1, g = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, y = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, b = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, x = typeof t.xAxis == "object" && !Array.isArray(t.xAxis) ? t.xAxis : {}, S = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, w = p?.formatter, { niceMinX: D, niceMaxX: k, niceMinY: A, niceMaxY: j } = O(m), M = Array.isArray(t.series) ? t.series : [], N = (e, t) => {
117
+ let r = d({
118
+ theme: n,
119
+ datums: t,
120
+ template: M[e] ?? M[0],
121
+ fallback: (e) => e.color
122
+ });
123
+ return (t) => {
124
+ let n = r(t);
125
+ if (!f) return n;
126
+ let i = `${e}:${t.dataIndex}`;
127
+ return f.has(i) ? n : _.color.modifyAlpha(n, .15);
128
+ };
129
+ }, P = T(t.dataZoom, h), F = P?.hasXSlider ?? !1, I = P?.hasYSlider ?? !1, L = typeof y.bottom == "number" ? y.bottom : 24, R = h ? 56 : L, z = F ? R + e.sliderHeight + e.sliderGap : R, B = typeof y.right == "number" ? y.right : 8, V = I ? B + e.sliderHeight + e.sliderGap : B;
97
130
  return {
98
131
  ...t,
99
- dataset: p.map((e) => ({ source: e })),
100
- series: p.map((e, t) => {
132
+ dataset: m.map((e) => ({ source: e.every(Array.isArray) ? e : e.map(v) })),
133
+ series: m.map((e, t) => {
101
134
  let r = i(n, c?.[t]?.color);
102
135
  return {
103
136
  type: "scatter",
@@ -109,42 +142,42 @@ function v(t) {
109
142
  },
110
143
  symbolSize: l,
111
144
  emphasis: { focus: "series" },
112
- itemStyle: { color: A(t) },
145
+ itemStyle: { color: N(t, e) },
113
146
  ...r ? { color: r } : {}
114
147
  };
115
148
  }),
116
149
  legend: {
117
- ...h,
118
- show: m
150
+ ...g,
151
+ show: h
119
152
  },
120
153
  grid: {
121
- ...v,
122
- bottom: I,
123
- right: R
154
+ ...y,
155
+ bottom: z,
156
+ right: V
124
157
  },
125
- ...j ? { dataZoom: j.entries } : {},
158
+ ...P ? { dataZoom: P.entries } : {},
126
159
  xAxis: {
127
- ...C,
128
- min: E,
129
- max: D
160
+ ...x,
161
+ min: D,
162
+ max: k
130
163
  },
131
164
  yAxis: {
132
- ...w,
133
- min: O,
134
- max: k,
165
+ ...S,
166
+ min: A,
167
+ max: j,
135
168
  axisLabel: {
136
- ...w.axisLabel ?? {},
137
- ...T ? { formatter: T } : {}
169
+ ...S.axisLabel ?? {},
170
+ ...w ? { formatter: w } : {}
138
171
  }
139
172
  },
140
173
  tooltip: {
141
- ...x,
142
- formatter: b(x.formatter, T, a)
174
+ ...b,
175
+ formatter: E(b.formatter, w, a)
143
176
  }
144
177
  };
145
178
  };
146
179
  }
147
- function y(t, n) {
180
+ function T(t, n) {
148
181
  if (!Array.isArray(t) || t.length === 0) return null;
149
182
  let r = !1, i = !1;
150
183
  return {
@@ -160,7 +193,7 @@ function y(t, n) {
160
193
  hasYSlider: i
161
194
  };
162
195
  }
163
- function b(e, t, n) {
196
+ function E(e, t, n) {
164
197
  return t ? u((e) => {
165
198
  let r = e.value, i = r?.[0], a = r?.[1], o = typeof i == "number" ? n ? n(i) : String(i) : "", s = typeof a == "number" ? t(a) : String(a ?? ""), c = typeof e.marker == "string" ? e.marker : "", l = e.seriesName ? `${e.seriesName}: ` : "";
166
199
  return {
@@ -171,7 +204,7 @@ function b(e, t, n) {
171
204
  };
172
205
  }) : e;
173
206
  }
174
- function x(e, t) {
207
+ function D(e, t) {
175
208
  return u((n) => {
176
209
  let r = n.value, i = r?.[0], a = r?.[1], o = typeof i == "number" ? e ? e(i) : String(i) : "", s = typeof a == "number" ? t ? t(a) : String(a) : "", c = typeof n.marker == "string" ? n.marker : "", l = n.seriesName ? `${n.seriesName}: ` : "";
177
210
  return {
@@ -182,10 +215,11 @@ function x(e, t) {
182
215
  };
183
216
  });
184
217
  }
185
- function S(e) {
218
+ function O(e) {
186
219
  let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity;
187
220
  for (let a of e) for (let e of a) {
188
- let a = e?.[0], o = e?.[1];
221
+ if (e == null) continue;
222
+ let [a, o] = v(e);
189
223
  typeof a == "number" && Number.isFinite(a) && (a < t && (t = a), a > n && (n = a)), typeof o == "number" && Number.isFinite(o) && (o < r && (r = o), o > i && (i = o));
190
224
  }
191
225
  let a = Number.isFinite(n) ? n <= 0 ? 1 : s(n) : 1, o = Number.isFinite(i) ? i <= 0 ? 1 : s(i) : 1;
@@ -198,7 +232,7 @@ function S(e) {
198
232
  }
199
233
  //#endregion
200
234
  //#region src/widgets-v2/scatterplot/skeleton.tsx
201
- var C = {
235
+ var k = {
202
236
  container: {
203
237
  display: "flex",
204
238
  alignItems: "center",
@@ -223,7 +257,7 @@ var C = {
223
257
  alignItems: "center",
224
258
  gap: ({ spacing: e }) => e(1.5)
225
259
  }
226
- }, w = (e, t, n) => ({
260
+ }, A = (e, t, n) => ({
227
261
  position: "absolute",
228
262
  top: e,
229
263
  left: t,
@@ -231,48 +265,48 @@ var C = {
231
265
  height: n,
232
266
  borderRadius: "50%"
233
267
  });
234
- function T(e) {
235
- let t = d(15), { count: n } = e, r = n === void 0 ? 24 : n, i, a, o, s, c;
268
+ function j(e) {
269
+ let t = f(15), { count: n } = e, r = n === void 0 ? 24 : n, i, a, o, s, c;
236
270
  if (t[0] !== r) {
237
- let e = Array.from({ length: r }, O);
238
- a = f, c = C.container, i = f, o = C.grid, s = e.map(D), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
271
+ let e = Array.from({ length: r }, P);
272
+ a = p, c = k.container, i = p, o = k.grid, s = e.map(N), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
239
273
  } else i = t[1], a = t[2], o = t[3], s = t[4], c = t[5];
240
274
  let l;
241
- t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ m(i, {
275
+ t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ h(i, {
242
276
  sx: o,
243
277
  children: s
244
278
  }), t[6] = i, t[7] = o, t[8] = s, t[9] = l) : l = t[9];
245
279
  let u;
246
- t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ m(f, {
247
- sx: C.legend,
248
- children: [0, 1].map(E)
280
+ t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ h(p, {
281
+ sx: k.legend,
282
+ children: [0, 1].map(M)
249
283
  }), t[10] = u) : u = t[10];
250
- let p;
251
- return t[11] !== a || t[12] !== c || t[13] !== l ? (p = /* @__PURE__ */ h(a, {
284
+ let d;
285
+ return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */ g(a, {
252
286
  sx: c,
253
287
  children: [l, u]
254
- }), t[11] = a, t[12] = c, t[13] = l, t[14] = p) : p = t[14], p;
288
+ }), t[11] = a, t[12] = c, t[13] = l, t[14] = d) : d = t[14], d;
255
289
  }
256
- function E(e) {
257
- return /* @__PURE__ */ h(f, {
258
- sx: C.legendItem,
259
- children: [/* @__PURE__ */ m(p, {
290
+ function M(e) {
291
+ return /* @__PURE__ */ g(p, {
292
+ sx: k.legendItem,
293
+ children: [/* @__PURE__ */ h(m, {
260
294
  variant: "circular",
261
295
  width: 8,
262
296
  height: 8
263
- }), /* @__PURE__ */ m(p, {
297
+ }), /* @__PURE__ */ h(m, {
264
298
  width: 48,
265
299
  height: 8
266
300
  })]
267
301
  }, `legend-${e}`);
268
302
  }
269
- function D(e, t) {
270
- return /* @__PURE__ */ m(p, {
303
+ function N(e, t) {
304
+ return /* @__PURE__ */ h(m, {
271
305
  variant: "circular",
272
- sx: w(e.top, e.left, e.size)
306
+ sx: A(e.top, e.left, e.size)
273
307
  }, `dot-${t}`);
274
308
  }
275
- function O(e, t) {
309
+ function P(e, t) {
276
310
  let n = 10 + t * 37 % 80, r = 5 + t * 53 % 90, i = 8 + t * 7 % 6;
277
311
  return {
278
312
  top: `${n}%`,
@@ -282,7 +316,7 @@ function O(e, t) {
282
316
  }
283
317
  //#endregion
284
318
  //#region src/widgets-v2/scatterplot/download.ts
285
- function k(e) {
319
+ function F(e) {
286
320
  let r = [];
287
321
  return e.getCaptureEl && r.push(t({
288
322
  filename: e.filename,
@@ -299,11 +333,14 @@ function k(e) {
299
333
  ]];
300
334
  for (let [t, i] of n.entries()) {
301
335
  let n = e.seriesNames?.[t] ?? `series_${t + 1}`;
302
- for (let [e, t] of i) r.push([
303
- n,
304
- e,
305
- t
306
- ]);
336
+ for (let e of i) {
337
+ let [t, i] = v(e);
338
+ r.push([
339
+ n,
340
+ t,
341
+ i
342
+ ]);
343
+ }
307
344
  }
308
345
  return r;
309
346
  }
@@ -311,20 +348,23 @@ function k(e) {
311
348
  }
312
349
  //#endregion
313
350
  //#region src/widgets-v2/scatterplot/transforms.ts
314
- var A = (e) => Array.isArray(e) ? e.map((e) => {
315
- if (!j(e)) return e;
316
- let t = e.reduce((e, [, t]) => e + Math.abs(t), 0);
317
- return t <= 0 ? e : e.map(([e, n]) => [e, n / t * 100]);
351
+ var I = (e) => Array.isArray(e) ? e.map((e) => {
352
+ if (!L(e)) return e;
353
+ let t = e.reduce((e, t) => e + Math.abs(v(t)[1]), 0);
354
+ return t <= 0 ? e : e.map((e) => {
355
+ let [n, r] = v(e);
356
+ return b(e, n, r / t * 100);
357
+ });
318
358
  }) : e;
319
- function j(e) {
320
- return Array.isArray(e) ? e.every((e) => Array.isArray(e) && e.length === 2 && typeof e[0] == "number" && Number.isFinite(e[0]) && typeof e[1] == "number" && Number.isFinite(e[1])) : !1;
359
+ function L(e) {
360
+ return Array.isArray(e) && e.every(y);
321
361
  }
322
- function M(e, t) {
362
+ function R(e, t) {
323
363
  if (t.length === 0 || !Array.isArray(e)) return e;
324
364
  let n = new Set(t.map(String));
325
- return e.map((e, t) => j(e) ? e.filter((e, r) => n.has(`${t}:${r}`)) : e);
365
+ return e.map((e, t) => L(e) ? e.filter((e, r) => n.has(`${t}:${r}`)) : e);
326
366
  }
327
367
  //#endregion
328
- export { T as ScatterplotSkeleton, k as createScatterplotDownloadConfig, v as createScatterplotOptionFactory, M as filterScatterplotByLockedPoints, _ as scatterplotOptions, A as toRelativeScatterplotData };
368
+ export { j as ScatterplotSkeleton, F as createScatterplotDownloadConfig, w as createScatterplotOptionFactory, R as filterScatterplotByLockedPoints, v as getScatterplotXY, C as scatterplotOptions, I as toRelativeScatterplotData };
329
369
 
330
370
  //# sourceMappingURL=scatterplot.js.map