@carto/ps-react-ui 6.0.0 → 6.1.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 (135) hide show
  1. package/dist/actions-BWlS5tpP.js +1150 -0
  2. package/dist/actions-BWlS5tpP.js.map +1 -0
  3. package/dist/category-alzjKzvQ.js +839 -0
  4. package/dist/category-alzjKzvQ.js.map +1 -0
  5. package/dist/{download-Vlzn2jzb.js → download-B4sykOFm.js} +94 -83
  6. package/dist/download-B4sykOFm.js.map +1 -0
  7. package/dist/{echart-DjcbtKgi.js → echart-CV8F50gn.js} +6 -5
  8. package/dist/echart-CV8F50gn.js.map +1 -0
  9. package/dist/{formula-CdHWtepq.js → formula-DJS-JLpk.js} +10 -16
  10. package/dist/{formula-CdHWtepq.js.map → formula-DJS-JLpk.js.map} +1 -1
  11. package/dist/legend.js +34 -21
  12. package/dist/legend.js.map +1 -1
  13. package/dist/{markdown-CY-67NRE.js → markdown-Bn2nKCbn.js} +12 -18
  14. package/dist/{markdown-CY-67NRE.js.map → markdown-Bn2nKCbn.js.map} +1 -1
  15. package/dist/{range-DHQSsl2_.js → range-BpU2zBmq.js} +2 -2
  16. package/dist/{range-DHQSsl2_.js.map → range-BpU2zBmq.js.map} +1 -1
  17. package/dist/{spread-DuM5oTI1.js → spread-CQwFIwuz.js} +10 -16
  18. package/dist/{spread-DuM5oTI1.js.map → spread-CQwFIwuz.js.map} +1 -1
  19. package/dist/{stores-B8CHbgw-.js → stores-DcBOZlU3.js} +30 -24
  20. package/dist/stores-DcBOZlU3.js.map +1 -0
  21. package/dist/{table-BE4uO9pp.js → table-DEdW_fDj.js} +7 -13
  22. package/dist/{table-BE4uO9pp.js.map → table-DEdW_fDj.js.map} +1 -1
  23. package/dist/types/legend/stores/types.d.ts +4 -2
  24. package/dist/types/widgets/actions/download/csv-item.d.ts +3 -3
  25. package/dist/types/widgets/actions/download/index.d.ts +2 -1
  26. package/dist/types/widgets/actions/download/png-item.d.ts +2 -2
  27. package/dist/types/widgets/actions/download/types.d.ts +12 -1
  28. package/dist/types/widgets/actions/download/widget-download.d.ts +26 -0
  29. package/dist/types/widgets/actions/fullscreen/fullscreen.d.ts +20 -13
  30. package/dist/types/widgets/actions/index.d.ts +1 -1
  31. package/dist/types/widgets/actions/searcher/filter.d.ts +3 -2
  32. package/dist/types/widgets/actions/searcher/searcher-toggle.d.ts +3 -0
  33. package/dist/types/widgets/bar/download.d.ts +6 -20
  34. package/dist/types/widgets/category/category-ui.d.ts +9 -1
  35. package/dist/types/widgets/category/download.d.ts +5 -10
  36. package/dist/types/widgets/category/helpers.d.ts +10 -0
  37. package/dist/types/widgets/echart/style.d.ts +1 -0
  38. package/dist/types/widgets/formula/download.d.ts +5 -15
  39. package/dist/types/widgets/histogram/download.d.ts +3 -8
  40. package/dist/types/widgets/index.d.ts +1 -1
  41. package/dist/types/widgets/markdown/download.d.ts +5 -11
  42. package/dist/types/widgets/pie/download.d.ts +3 -8
  43. package/dist/types/widgets/scatterplot/download.d.ts +6 -11
  44. package/dist/types/widgets/spread/download.d.ts +6 -12
  45. package/dist/types/widgets/stores/index.d.ts +1 -1
  46. package/dist/types/widgets/stores/widget-store-registry.d.ts +14 -0
  47. package/dist/types/widgets/table/download.d.ts +7 -13
  48. package/dist/types/widgets/timeseries/download.d.ts +7 -12
  49. package/dist/types/widgets/toolbox/toolbox.d.ts +1 -1
  50. package/dist/{utils-BStJWhZN.js → utils-C-eWwOhE.js} +2 -2
  51. package/dist/{utils-BStJWhZN.js.map → utils-C-eWwOhE.js.map} +1 -1
  52. package/dist/widgets/actions.js +4 -4
  53. package/dist/widgets/bar.js +11 -17
  54. package/dist/widgets/bar.js.map +1 -1
  55. package/dist/widgets/category.js +1 -1
  56. package/dist/widgets/echart.js +1 -1
  57. package/dist/widgets/formula.js +1 -1
  58. package/dist/widgets/histogram.js +14 -20
  59. package/dist/widgets/histogram.js.map +1 -1
  60. package/dist/widgets/markdown.js +1 -1
  61. package/dist/widgets/pie.js +13 -19
  62. package/dist/widgets/pie.js.map +1 -1
  63. package/dist/widgets/range.js +1 -1
  64. package/dist/widgets/scatterplot.js +13 -19
  65. package/dist/widgets/scatterplot.js.map +1 -1
  66. package/dist/widgets/spread.js +1 -1
  67. package/dist/widgets/stores.js +2 -2
  68. package/dist/widgets/table.js +1 -1
  69. package/dist/widgets/timeseries.js +16 -22
  70. package/dist/widgets/timeseries.js.map +1 -1
  71. package/dist/widgets/utils.js +1 -1
  72. package/dist/widgets.js +274 -333
  73. package/dist/widgets.js.map +1 -1
  74. package/dist/{zoom-toggle-D_VuA01l.js → zoom-toggle-MmLjMTEw.js} +2 -2
  75. package/dist/{zoom-toggle-D_VuA01l.js.map → zoom-toggle-MmLjMTEw.js.map} +1 -1
  76. package/package.json +1 -1
  77. package/src/legend/components/legend-item/legend-item-ui.test.tsx +22 -1
  78. package/src/legend/components/legend-ramp/legend-ramp-ui.tsx +22 -6
  79. package/src/legend/stores/types.ts +4 -2
  80. package/src/widgets/actions/download/csv-item.test.tsx +3 -3
  81. package/src/widgets/actions/download/csv-item.tsx +6 -6
  82. package/src/widgets/actions/download/download.tsx +5 -3
  83. package/src/widgets/actions/download/index.ts +2 -1
  84. package/src/widgets/actions/download/png-item.test.tsx +5 -3
  85. package/src/widgets/actions/download/png-item.tsx +4 -4
  86. package/src/widgets/actions/download/types.ts +15 -1
  87. package/src/widgets/actions/download/widget-download.test.ts +30 -0
  88. package/src/widgets/actions/download/widget-download.ts +41 -0
  89. package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +155 -0
  90. package/src/widgets/actions/fullscreen/fullscreen.test.tsx +39 -41
  91. package/src/widgets/actions/fullscreen/fullscreen.tsx +198 -96
  92. package/src/widgets/actions/index.ts +3 -0
  93. package/src/widgets/actions/searcher/filter.test.ts +28 -0
  94. package/src/widgets/actions/searcher/filter.ts +22 -4
  95. package/src/widgets/actions/searcher/searcher-toggle.tsx +16 -8
  96. package/src/widgets/actions/searcher/searcher.test.tsx +22 -0
  97. package/src/widgets/actions/searcher/searcher.tsx +17 -7
  98. package/src/widgets/bar/download.test.tsx +5 -3
  99. package/src/widgets/bar/download.tsx +11 -35
  100. package/src/widgets/category/category-ui.tsx +26 -14
  101. package/src/widgets/category/category.tsx +37 -2
  102. package/src/widgets/category/components/category-legend.tsx +1 -2
  103. package/src/widgets/category/download.test.ts +4 -2
  104. package/src/widgets/category/download.ts +14 -27
  105. package/src/widgets/category/helpers.test.ts +17 -0
  106. package/src/widgets/category/helpers.ts +16 -0
  107. package/src/widgets/echart/style.ts +6 -0
  108. package/src/widgets/formula/download.test.tsx +3 -1
  109. package/src/widgets/formula/download.tsx +10 -30
  110. package/src/widgets/histogram/download.test.ts +6 -4
  111. package/src/widgets/histogram/download.ts +13 -26
  112. package/src/widgets/index.ts +1 -0
  113. package/src/widgets/markdown/download.test.ts +2 -2
  114. package/src/widgets/markdown/download.tsx +11 -26
  115. package/src/widgets/pie/download.test.ts +7 -3
  116. package/src/widgets/pie/download.ts +12 -25
  117. package/src/widgets/scatterplot/download.test.ts +4 -2
  118. package/src/widgets/scatterplot/download.ts +15 -28
  119. package/src/widgets/spread/download.test.ts +3 -1
  120. package/src/widgets/spread/download.ts +13 -27
  121. package/src/widgets/stores/index.ts +2 -0
  122. package/src/widgets/stores/widget-store-registry.test.ts +25 -0
  123. package/src/widgets/stores/widget-store-registry.ts +22 -0
  124. package/src/widgets/table/download.test.ts +5 -3
  125. package/src/widgets/table/download.ts +15 -29
  126. package/src/widgets/timeseries/download.test.ts +6 -4
  127. package/src/widgets/timeseries/download.ts +16 -29
  128. package/src/widgets/toolbox/toolbox.tsx +1 -1
  129. package/dist/actions-KsX1xdDM.js +0 -1024
  130. package/dist/actions-KsX1xdDM.js.map +0 -1
  131. package/dist/category-CsdDqDzo.js +0 -833
  132. package/dist/category-CsdDqDzo.js.map +0 -1
  133. package/dist/download-Vlzn2jzb.js.map +0 -1
  134. package/dist/echart-DjcbtKgi.js.map +0 -1
  135. package/dist/stores-B8CHbgw-.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bar.js","names":["<Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>","(height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\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>","(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 )","i"],"sources":["../../src/widgets/bar/options.ts","../../src/widgets/bar/skeleton.tsx","../../src/widgets/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\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 axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n // `interval: 0` makes every category label a candidate so `hideOverlap`\n // can pack the maximum number that physically fit; the category-axis\n // default (`'auto'`) sub-samples first and shows fewer than fit.\n interval: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\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 axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ 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 BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\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 baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = 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\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 // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\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 : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\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 DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: () => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: () => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\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: () => {\n const data = args.getData()\n const rows: unknown[][] = []\n for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n return rows\n },\n }),\n )\n return items\n}\n"],"mappings":";;;;;;;;;AAsCA,SAAgB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAO,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAY,EAAM,WAAW,QAAQ;GACvC;GACA,aAAa,EAAE,MAAM,OAAO;GAC5B,UAAU,EAAwB,CAAK;GACvC,WAAW,EAAyB,GAAW,CAAc;EAC/D;EAGA,QAAQ,EACN,GAAG,EAAkB;GAAE,WAAW;GAAO;EAAe,CAAC,EAC3D;EACA,aAAa,EAAE,WAAW,EAAE,OAAO,EAAM,QAAQ,KAAK,KAAK,EAAE;EAC7D,OAAO,CACL,EAAM,QAAQ,UAAU,MACxB,GAAG,OAAO,OACP,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B,CACF;EACA,OAAO;GACL,MAAM;GACN,UAAU,EAAE,MAAM,GAAM;GACxB,UA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;;;AC1BX,SAAgB,EACd,GACgB;CAChB,IAAM,IAAwB,CAAC;CA0B/B,OAzBI,EAAK,gBACP,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,cAAc,EAAK;EACnB,YAAY,EAAK;EACjB,iBAAiB,EAAK;CACxB,CAAC,CACH,GAEF,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,eAAe;GACb,IAAM,IAAO,EAAK,QAAQ,GACpB,IAAoB,CAAC;GAC3B,KAAK,IAAM,CAAC,GAAG,MAAW,EAAK,QAAQ,GAAG;IAExC,AADI,IAAI,KAAG,EAAK,KAAK,CAAC,CAAC,GACvB,EAAK,KAAK,CAAC,QAAQ,OAAO,CAAC;IAC3B,KAAK,IAAM,KAAK,GAAQ,EAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;GACrD;GACA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT"}
1
+ {"version":3,"file":"bar.js","names":["<Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>","(height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\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>","(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 )","i"],"sources":["../../src/widgets/bar/options.ts","../../src/widgets/bar/skeleton.tsx","../../src/widgets/bar/download.tsx"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\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 axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n // `interval: 0` makes every category label a candidate so `hideOverlap`\n // can pack the maximum number that physically fit; the category-axis\n // default (`'auto'`) sub-samples first and shows fewer than fit.\n interval: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\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 axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ 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 BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\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 baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = 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\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 // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\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 : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport type BarDownloadConfigArgs = WidgetDownloadArgs<BarWidgetData>\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item with\n * one `name,value` block per series, separated by an empty row when there\n * are multiple. When `getCaptureEl` is given, also prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n return withPngItem(\n args,\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const rows: unknown[][] = []\n for (const [i, series] of data.entries()) {\n if (i > 0) rows.push([])\n rows.push(['name', 'value'])\n for (const d of series) rows.push([d.name, d.value])\n }\n return rows\n },\n }),\n )\n}\n"],"mappings":";;;;;;;;;AAsCA,SAAgB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAO,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAY,EAAM,WAAW,QAAQ;GACvC;GACA,aAAa,EAAE,MAAM,OAAO;GAC5B,UAAU,EAAwB,CAAK;GACvC,WAAW,EAAyB,GAAW,CAAc;EAC/D;EAGA,QAAQ,EACN,GAAG,EAAkB;GAAE,WAAW;GAAO;EAAe,CAAC,EAC3D;EACA,aAAa,EAAE,WAAW,EAAE,OAAO,EAAM,QAAQ,KAA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AO;GAAI,QAAQ;EAAI,CAAA,CAC9B;CAHK,GAAA,UAAUE,GAGf;;AAdU,SAAA,EAAC,GAAQ,GAAA;CACxB,OAAA,kBAAC,GAAD;EAEE,IAAI,EAAO;EACX,SAAQ;EACA;CACT,GAJM,OAAO,GAIb;;;;ACvCX,SAAgB,EACd,GACgB;CAChB,OAAO,EACL,GACA,EAAqB;EACnB,UAAU,EAAK;EACf,UAAU,MAAQ;GAChB,IAAM,IAAO,EAAK,QAAQ,CAAG,GACvB,IAAoB,CAAC;GAC3B,KAAK,IAAM,CAAC,GAAG,MAAW,EAAK,QAAQ,GAAG;IAExC,AADI,IAAI,KAAG,EAAK,KAAK,CAAC,CAAC,GACvB,EAAK,KAAK,CAAC,QAAQ,OAAO,CAAC;IAC3B,KAAK,IAAM,KAAK,GAAQ,EAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;GACrD;GACA,OAAO;EACT;CACF,CAAC,CACH;AACF"}
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../category-CsdDqDzo.js";
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../category-alzjKzvQ.js";
2
2
  export { o as Category, r as CategoryBar, e as CategoryLegend, s as CategoryRowMulti, a as CategoryRowOther, t as CategoryRowSingle, i as CategorySkeleton, n as CategoryUI, c as createCategoryDownloadConfig };
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "../echart-DjcbtKgi.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "../echart-CV8F50gn.js";
2
2
  export { i as DEFAULT_INIT_OPTS, n as Echart, t as EchartUI, e as __resetSharedResizeObserver, r as observeResize, a as useChartSelection };
@@ -1,2 +1,2 @@
1
- import { c as e, d as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "../formula-CdHWtepq.js";
1
+ import { c as e, d as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "../formula-DJS-JLpk.js";
2
2
  export { t as Delta, o as Formula, i as FormulaSkeleton, n as FormulaUI, l as Note, r as Prefix, e as Series, s as Suffix, a as Value, c as createFormulaDownloadConfig };
@@ -1,6 +1,6 @@
1
- import { r as e } from "../zoom-toggle-D_VuA01l.js";
2
- import { n as t, t as n } from "../download-Vlzn2jzb.js";
3
- import { n as r, r as i, t as a } from "../utils-BStJWhZN.js";
1
+ import { r as e } from "../zoom-toggle-MmLjMTEw.js";
2
+ import { n as t, t as n } from "../download-B4sykOFm.js";
3
+ import { n as r, r as i, t as a } from "../utils-C-eWwOhE.js";
4
4
  import { a as o, n as s, o as c, r as l, s as u, t as d } from "../option-builders-DQivvvbb.js";
5
5
  import { c as f } from "react/compiler-runtime";
6
6
  import { Box as p, Skeleton as m } from "@mui/material";
@@ -255,26 +255,20 @@ function E(e, t) {
255
255
  //#endregion
256
256
  //#region src/widgets/histogram/download.ts
257
257
  function D(e) {
258
- let r = [];
259
- return e.getCaptureEl && r.push(t({
258
+ return n(e, t({
260
259
  filename: e.filename,
261
- getCaptureEl: e.getCaptureEl,
262
- pixelRatio: e.pngPixelRatio,
263
- backgroundColor: e.pngBackgroundColor
264
- })), r.push(n({
265
- filename: e.filename,
266
- getRows: () => {
267
- let t = e.getData(), n = e.getTicks(), r = t.length, i = ["bin_low", "bin_high"];
268
- for (let t = 0; t < r; t++) i.push(e.seriesNames?.[t] ?? `series_${t + 1}`);
269
- let a = [i];
270
- for (let e = 0; e < Math.max(0, n.length - 1); e++) {
271
- let i = [n[e], n[e + 1]];
272
- for (let n = 0; n < r; n++) i.push(t[n]?.[e] ?? 0);
273
- a.push(i);
260
+ getRows: (t) => {
261
+ let n = e.getData(t), r = e.getTicks(), i = n.length, a = ["bin_low", "bin_high"];
262
+ for (let t = 0; t < i; t++) a.push(e.seriesNames?.[t] ?? `series_${t + 1}`);
263
+ let o = [a];
264
+ for (let e = 0; e < Math.max(0, r.length - 1); e++) {
265
+ let t = [r[e], r[e + 1]];
266
+ for (let r = 0; r < i; r++) t.push(n[r]?.[e] ?? 0);
267
+ o.push(t);
274
268
  }
275
- return a;
269
+ return o;
276
270
  }
277
- })), r;
271
+ }));
278
272
  }
279
273
  //#endregion
280
274
  //#region src/widgets/histogram/transforms.ts
@@ -1 +1 @@
1
- {"version":3,"file":"histogram.js","names":["{ bins = 12 }: HistogramSkeletonProps","bins = 12","Box","styles.grid","heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))","styles.container","(h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n )","<Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>","<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>","(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 )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\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>","i"],"sources":["../../src/widgets/histogram/options.ts","../../src/widgets/histogram/skeleton.tsx","../../src/widgets/histogram/download.ts","../../src/widgets/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\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 axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n // `interval: 0` makes every bin label a candidate so `hideOverlap`\n // can pack the maximum number that physically fit. The category-axis\n // default (`'auto'`) sub-samples first and leaves only one/two labels\n // even when there's room for more.\n interval: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\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 axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const lockedItems = options.lockedItems\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n // Locked range → x-axis crop. `min`/`max` on a category axis accept a\n // category value (the bin label string), bounding the visible window\n // without touching `dataset`/`series` — the zeroed-out bins from\n // `filterHistogramByLockedBins` stay in the data, just scrolled out of\n // view. `null` (not omitted) on unlock, since ECharts' option merge skips\n // `undefined` keys and would otherwise leave a stale crop in place.\n const lockedRange =\n lockedItems && lockedItems.length > 0\n ? (() => {\n const indices = lockedItems.map(Number)\n const min = binLabels[Math.min(...indices)]\n const max = binLabels[Math.max(...indices)]\n return min != null && max != null ? { min, max } : null\n })()\n : null\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\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: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\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 // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1 +\n // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw counts) keeps stacked bins inside the plot:\n // when StackToggle marks the series, ECharts feeds the *post-stack*\n // extent to these callbacks, so `niceNum` rounds the stacked total.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n // A consumer's `optionsOverride.xAxis` may legitimately be an array\n // (ECharts supports multiple x-axes on one grid). Merge the locked-range\n // crop into the primary (first) axis instead of discarding the rest via\n // an object fallback — `min`/`max` here bound a category axis by label\n // string, which is only ambiguous if `labelFormatter` produces duplicate\n // labels across bins (a structural limitation of label-string bounds,\n // not fixed here).\n //\n // `min`/`max` are ALWAYS written explicitly below (never omitted) —\n // ECharts' merge silently keeps whatever value it last received for an\n // omitted key, so omitting them while unlocked would leave a stale crop\n // in place from a previous locked render. But the fallback when there's\n // no active crop must be the CONSUMER's own `optionsOverride.xAxis.min/max`\n // (if they set one), not an unconditional `null` — `option.xAxis` here\n // is the post-structural-phase axis, which only ever carries the\n // consumer's static override (never our own prior crop — the structural\n // phase is rebuilt from scratch on every factory recreation, so it can't\n // have picked up a merge-phase write from a previous render).\n const currentAxis = (\n Array.isArray(option.xAxis) ? option.xAxis[0] : option.xAxis\n ) as { min?: unknown; max?: unknown } | undefined\n const lockedRangeAxis = {\n min: lockedRange?.min ?? currentAxis?.min ?? null,\n max: lockedRange?.max ?? currentAxis?.max ?? null,\n }\n const nextXAxis = Array.isArray(option.xAxis)\n ? [{ ...option.xAxis[0], ...lockedRangeAxis }, ...option.xAxis.slice(1)]\n : {\n ...(typeof option.xAxis === 'object' ? option.xAxis : {}),\n ...lockedRangeAxis,\n }\n\n return {\n ...option,\n xAxis: nextXAxis,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\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 return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\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 DownloadItem,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(args: {\n filename: string\n getData: () => HistogramWidgetData\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n getCaptureEl?: () => 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: () => {\n const data = args.getData()\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n return rows\n },\n }),\n )\n return items\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n\n/**\n * `LockSelection` filter for Histogram. Data is `number[][]` — a flat list\n * of bin counts per series, positionally paired with `ticks` (bin `i` covers\n * `[ticks[i], ticks[i+1])`). Unlike name-keyed widgets, locked-out bins can't\n * be REMOVED — that would shift every later bin's index and desync it from\n * its `ticks` range. Zeroing them out instead preserves array length/position,\n * so locked bins just render as empty (height 0) rather than disappearing.\n *\n * `lockedItems` holds bin indices (numbers, from Histogram's `selection`).\n */\nexport function filterHistogramByLockedBins(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<number>(lockedItems.map(Number))\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n return series.map((count, i) => (locked.has(i) ? count : 0))\n })\n}\n"],"mappings":";;;;;;;;;AA2CA,SAAgB,EAAiB,EAC/B,UACA,gBACgD;CAGhD,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAA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,KAAK,IAAI,GAAG,EAAM,SAAS,CAAC,GAAG,KAAO;IAC5D,IAAM,IAAiB,CAAC,EAAM,IAAM,EAAM,IAAM,EAAE;IAClD,KAAK,IAAI,IAAI,GAAG,IAAI,GAAa,KAAK,EAAI,KAAK,EAAK,EAAE,GAAG,MAAQ,CAAC;IAClE,EAAK,KAAK,CAAG;GACf;GACA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT;;;ACvCA,IAAa,KAA2B,MACjC,MAAM,QAAQ,CAAK,IACjB,EAAM,KAAK,MAA6B;CAC7C,IAAI,CAAC,EAAkB,CAAM,GAAG,OAAO;CACvC,IAAM,IAAQ,EAAO,QAAQ,GAAK,MAAM,IAAM,KAAK,IAAI,CAAC,GAAG,CAAC;CAE5D,OADI,KAAS,IAAU,IAChB,EAAO,KAAK,MAAO,IAAI,IAAS,GAAG;AAC5C,CAAC,IANiC;AASpC,SAAS,EAAkB,GAA2B;CAEpD,OADK,MAAM,QAAQ,CAAC,IACb,EAAE,OAAO,MAAS,OAAO,KAAS,YAAY,OAAO,SAAS,CAAI,CAAC,IAD5C;AAEhC;AAYA,SAAgB,EACd,GACA,GACS;CAET,IADI,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQ,CAAK,GAAG,OAAO;CAClC,IAAM,IAAS,IAAI,IAAY,EAAY,IAAI,MAAM,CAAC;CACtD,OAAO,EAAM,KAAK,MACX,EAAkB,CAAM,IACtB,EAAO,KAAK,GAAO,MAAO,EAAO,IAAI,CAAC,IAAI,IAAQ,CAAE,IADpB,CAExC;AACH"}
1
+ {"version":3,"file":"histogram.js","names":["{ bins = 12 }: HistogramSkeletonProps","bins = 12","Box","styles.grid","heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))","styles.container","(h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n )","<Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>","<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>","(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 )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\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>","i"],"sources":["../../src/widgets/histogram/options.ts","../../src/widgets/histogram/skeleton.tsx","../../src/widgets/histogram/download.ts","../../src/widgets/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildAxisLabelStyle,\n buildGridConfig,\n buildLegendConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../utils/option-builders'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\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 axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n // `interval: 0` makes every bin label a candidate so `hideOverlap`\n // can pack the maximum number that physically fit. The category-axis\n // default (`'auto'`) sub-samples first and leaves only one/two labels\n // even when there's room for more.\n interval: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\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 axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const lockedItems = options.lockedItems\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n // Locked range → x-axis crop. `min`/`max` on a category axis accept a\n // category value (the bin label string), bounding the visible window\n // without touching `dataset`/`series` — the zeroed-out bins from\n // `filterHistogramByLockedBins` stay in the data, just scrolled out of\n // view. `null` (not omitted) on unlock, since ECharts' option merge skips\n // `undefined` keys and would otherwise leave a stale crop in place.\n const lockedRange =\n lockedItems && lockedItems.length > 0\n ? (() => {\n const indices = lockedItems.map(Number)\n const min = binLabels[Math.min(...indices)]\n const max = binLabels[Math.max(...indices)]\n return min != null && max != null ? { min, max } : null\n })()\n : null\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\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: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\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 // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1 +\n // bar). Delegating the extent to ECharts (rather than precomputing\n // scalars from the raw counts) keeps stacked bins inside the plot:\n // when StackToggle marks the series, ECharts feeds the *post-stack*\n // extent to these callbacks, so `niceNum` rounds the stacked total.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n // A consumer's `optionsOverride.xAxis` may legitimately be an array\n // (ECharts supports multiple x-axes on one grid). Merge the locked-range\n // crop into the primary (first) axis instead of discarding the rest via\n // an object fallback — `min`/`max` here bound a category axis by label\n // string, which is only ambiguous if `labelFormatter` produces duplicate\n // labels across bins (a structural limitation of label-string bounds,\n // not fixed here).\n //\n // `min`/`max` are ALWAYS written explicitly below (never omitted) —\n // ECharts' merge silently keeps whatever value it last received for an\n // omitted key, so omitting them while unlocked would leave a stale crop\n // in place from a previous locked render. But the fallback when there's\n // no active crop must be the CONSUMER's own `optionsOverride.xAxis.min/max`\n // (if they set one), not an unconditional `null` — `option.xAxis` here\n // is the post-structural-phase axis, which only ever carries the\n // consumer's static override (never our own prior crop — the structural\n // phase is rebuilt from scratch on every factory recreation, so it can't\n // have picked up a merge-phase write from a previous render).\n const currentAxis = (\n Array.isArray(option.xAxis) ? option.xAxis[0] : option.xAxis\n ) as { min?: unknown; max?: unknown } | undefined\n const lockedRangeAxis = {\n min: lockedRange?.min ?? currentAxis?.min ?? null,\n max: lockedRange?.max ?? currentAxis?.max ?? null,\n }\n const nextXAxis = Array.isArray(option.xAxis)\n ? [{ ...option.xAxis[0], ...lockedRangeAxis }, ...option.xAxis.slice(1)]\n : {\n ...(typeof option.xAxis === 'object' ? option.xAxis : {}),\n ...lockedRangeAxis,\n }\n\n return {\n ...option,\n xAxis: nextXAxis,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\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 return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is given, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(\n args: WidgetDownloadArgs<HistogramWidgetData> & {\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n },\n): DownloadItem[] {\n return withPngItem(\n args,\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (ctx) => {\n const data = args.getData(ctx)\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n return rows\n },\n }),\n )\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n\n/**\n * `LockSelection` filter for Histogram. Data is `number[][]` — a flat list\n * of bin counts per series, positionally paired with `ticks` (bin `i` covers\n * `[ticks[i], ticks[i+1])`). Unlike name-keyed widgets, locked-out bins can't\n * be REMOVED — that would shift every later bin's index and desync it from\n * its `ticks` range. Zeroing them out instead preserves array length/position,\n * so locked bins just render as empty (height 0) rather than disappearing.\n *\n * `lockedItems` holds bin indices (numbers, from Histogram's `selection`).\n */\nexport function filterHistogramByLockedBins(\n input: unknown,\n lockedItems: readonly (string | number)[],\n): unknown {\n if (lockedItems.length === 0) return input\n if (!Array.isArray(input)) return input\n const locked = new Set<number>(lockedItems.map(Number))\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n return series.map((count, i) => (locked.has(i) ? count : 0))\n })\n}\n"],"mappings":";;;;;;;;;AA2CA,SAAgB,EAAiB,EAC/B,UACA,gBACgD;CAGhD,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,SAAS,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAO,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAY,EAAM,WAAW,QAAQ;GACvC;GACA,aAAa,EAAE,MAAM,OAAO;GAC5B,UAAU,EAAwB,CAAK;GACvC,WAAW,EAA+B,CAAS;EACrD;EAKA,QAAQ,EACN,GAAG,EAAkB,EAAE,WAAW,GAAM,CAAC,EAC3C;EACA,aAAa,EAAE,WAAW,EAAE,OAAO,EAAM,QAAQ,KAAK,KAAK,EAAE;EAC7D,OAAO,CACL,EAAM,QAAQ,UAAU,MACxB,GAAG,OAAO,OACP,EAAM,QACJ,aAAa,QAAQ,CAAC,CAC3B,CACF;EACA,OAAO;GACL,MAAM;GACN,UAAU,EAAE,MAAM,GAAM;GACxB,UAAU,EAAE,MAAM,GAAM;GACxB,WAAW;IACT,GAAG,EAAoB,CAAK;IAC5B,SAAS;KAAC,SAAS,EAAM,QAAQ,EAAG,CAAC;KAAG;KAAG;KAAG;IAAC;IAC/C,QAAQ;IAKR,UAAU;IACV,aAAa;GACf;EACF;EACA,OAAO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M,IAAS,IAAI,IAAY,EAAY,IAAI,MAAM,CAAC;CACtD,OAAO,EAAM,KAAK,MACX,EAAkB,CAAM,IACtB,EAAO,KAAK,GAAO,MAAO,EAAO,IAAI,CAAC,IAAI,IAAQ,CAAE,IADpB,CAExC;AACH"}
@@ -1,3 +1,3 @@
1
1
  import { t as e } from "../markdown-content-kYNLOX0T.js";
2
- import { i as t, n, r, t as i } from "../markdown-CY-67NRE.js";
2
+ import { i as t, n, r, t as i } from "../markdown-Bn2nKCbn.js";
3
3
  export { r as Markdown, e as MarkdownContent, n as MarkdownSkeleton, t as MarkdownUI, i as createMarkdownDownloadConfig };
@@ -1,5 +1,5 @@
1
- import { n as e, t } from "../download-Vlzn2jzb.js";
2
- import { r as n, t as r } from "../utils-BStJWhZN.js";
1
+ import { n as e, t } from "../download-B4sykOFm.js";
2
+ import { r as n, t as r } from "../utils-C-eWwOhE.js";
3
3
  import { a as i, i as a, n as o, o as s, r as c, s as l } from "../option-builders-DQivvvbb.js";
4
4
  import { c as u } from "react/compiler-runtime";
5
5
  import { Box as d, Skeleton as f } from "@mui/material";
@@ -341,31 +341,25 @@ function O(e) {
341
341
  //#endregion
342
342
  //#region src/widgets/pie/download.ts
343
343
  function k(n) {
344
- let r = [];
345
- return n.getCaptureEl && r.push(e({
344
+ return t(n, e({
346
345
  filename: n.filename,
347
- getCaptureEl: n.getCaptureEl,
348
- pixelRatio: n.pngPixelRatio,
349
- backgroundColor: n.pngBackgroundColor
350
- })), r.push(t({
351
- filename: n.filename,
352
- getRows: () => {
353
- let e = n.getData(), t = [[
346
+ getRows: (e) => {
347
+ let t = n.getData(e), r = [[
354
348
  "series",
355
349
  "name",
356
350
  "value"
357
351
  ]];
358
- for (let [r, i] of e.entries()) {
359
- let e = n.seriesNames?.[r] ?? `series_${r + 1}`;
360
- for (let n of i) t.push([
361
- e,
362
- n.name,
363
- n.value
352
+ for (let [e, i] of t.entries()) {
353
+ let t = n.seriesNames?.[e] ?? `series_${e + 1}`;
354
+ for (let e of i) r.push([
355
+ t,
356
+ e.name,
357
+ e.value
364
358
  ]);
365
359
  }
366
- return t;
360
+ return r;
367
361
  }
368
- })), r;
362
+ }));
369
363
  }
370
364
  //#endregion
371
365
  export { D as PieSkeleton, k as createPieDownloadConfig, v as createPieOptionFactory, _ as pieOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"pie.js","names":["<Skeleton variant='circular' sx={styles.ring} />","<Box sx={styles.hole} />","<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>","<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>","(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 )"],"sources":["../../src/widgets/pie/options.ts","../../src/widgets/pie/skeleton.tsx","../../src/widgets/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 '../utils/option-builders'\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 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: () => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => 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: () => {\n const data = args.getData()\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,IAAM,IAA4C,CAAC,OAAO,KAAK;AAiB/D,SAAgB,EAAW,EACzB,UACA,cACA,qBACoC;CACpC,OAAO;EACL,QAAQ;GACN,GAAG,EAAkB;IAAE,WAAW;IAAM;GAAe,CAAC;GAIxD,MAAM;GACN,SAAS;GAOT,cAAc;EAChB;EACA,SAAS;GAKP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAA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OAAO;GAAG,QAAQ;EAAI,CAAA,GACnD,kBAAC,GAAD;GAAU,OAAO;GAAI,QAAQ;EAAI,CAAA,CAC9B;CAHK,GAAA,UAAU,GAGf;;;;AC1Ef,SAAgB,EAAwB,GAOrB;CACjB,IAAM,IAAwB,CAAC;CA2B/B,OA1BI,EAAK,gBACP,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,cAAc,EAAK;EACnB,YAAY,EAAK;EACjB,iBAAiB,EAAK;CACxB,CAAC,CACH,GAEF,EAAM,KACJ,EAAqB;EACnB,UAAU,EAAK;EACf,eAAe;GACb,IAAM,IAAO,EAAK,QAAQ,GACpB,IAAoB,CAAC;IAAC;IAAU;IAAQ;GAAO,CAAC;GACtD,KAAK,IAAM,CAAC,GAAG,MAAW,EAAK,QAAQ,GAAG;IACxC,IAAM,IAAa,EAAK,cAAc,MAAM,UAAU,IAAI;IAC1D,KAAK,IAAM,KAAS,GAClB,EAAK,KAAK;KAAC;KAAY,EAAM;KAAM,EAAM;IAAK,CAAC;GAEnD;GACA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT"}
1
+ {"version":3,"file":"pie.js","names":["<Skeleton variant='circular' sx={styles.ring} />","<Box sx={styles.hole} />","<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>","<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>","(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 )"],"sources":["../../src/widgets/pie/options.ts","../../src/widgets/pie/skeleton.tsx","../../src/widgets/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 '../utils/option-builders'\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 withPngItem,\n type DownloadItem,\n type WidgetDownloadArgs,\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 * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(\n args: WidgetDownloadArgs<PieWidgetData> & {\n seriesNames?: readonly string[]\n },\n): DownloadItem[] {\n return withPngItem(\n args,\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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