@carto/ps-react-ui 6.2.0 → 6.4.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 (91) hide show
  1. package/dist/actions-DyWNwvLu.js +1272 -0
  2. package/dist/actions-DyWNwvLu.js.map +1 -0
  3. package/dist/{category-DULnoxvk.js → category-BHBd5Pcc.js} +262 -245
  4. package/dist/category-BHBd5Pcc.js.map +1 -0
  5. package/dist/{option-builders-DQivvvbb.js → item-color-B7xkIpDZ.js} +26 -9
  6. package/dist/item-color-B7xkIpDZ.js.map +1 -0
  7. package/dist/scale-Bhx8HKEB.js +29 -0
  8. package/dist/scale-Bhx8HKEB.js.map +1 -0
  9. package/dist/types/widgets/actions/index.d.ts +1 -1
  10. package/dist/types/widgets/actions/relative-data/index.d.ts +1 -0
  11. package/dist/types/widgets/actions/relative-data/labels.d.ts +3 -0
  12. package/dist/types/widgets/actions/relative-data/relative-data.d.ts +16 -2
  13. package/dist/types/widgets/actions/relative-data/scale.d.ts +26 -0
  14. package/dist/types/widgets/actions/relative-data/style.d.ts +12 -0
  15. package/dist/types/widgets/bar/types.d.ts +6 -0
  16. package/dist/types/widgets/category/category.d.ts +2 -1
  17. package/dist/types/widgets/histogram/bins.d.ts +7 -0
  18. package/dist/types/widgets/histogram/download.d.ts +2 -2
  19. package/dist/types/widgets/histogram/index.d.ts +2 -1
  20. package/dist/types/widgets/histogram/options.d.ts +1 -1
  21. package/dist/types/widgets/histogram/transforms.d.ts +5 -4
  22. package/dist/types/widgets/histogram/types.d.ts +22 -5
  23. package/dist/types/widgets/index.d.ts +2 -2
  24. package/dist/types/widgets/pie/types.d.ts +6 -0
  25. package/dist/types/widgets/scatterplot/download.d.ts +2 -2
  26. package/dist/types/widgets/scatterplot/index.d.ts +2 -1
  27. package/dist/types/widgets/scatterplot/points.d.ts +7 -0
  28. package/dist/types/widgets/scatterplot/transforms.d.ts +4 -3
  29. package/dist/types/widgets/scatterplot/types.d.ts +21 -2
  30. package/dist/types/widgets/timeseries/types.d.ts +6 -0
  31. package/dist/types/widgets/utils/item-color.d.ts +26 -0
  32. package/dist/widgets/actions.js +1 -1
  33. package/dist/widgets/bar.js +87 -78
  34. package/dist/widgets/bar.js.map +1 -1
  35. package/dist/widgets/category.js +1 -1
  36. package/dist/widgets/histogram.js +129 -97
  37. package/dist/widgets/histogram.js.map +1 -1
  38. package/dist/widgets/pie.js +108 -89
  39. package/dist/widgets/pie.js.map +1 -1
  40. package/dist/widgets/scatterplot.js +147 -107
  41. package/dist/widgets/scatterplot.js.map +1 -1
  42. package/dist/widgets/timeseries.js +92 -83
  43. package/dist/widgets/timeseries.js.map +1 -1
  44. package/dist/widgets.js +2 -2
  45. package/dist/widgets.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +77 -13
  48. package/src/widgets/actions/fullscreen/fullscreen.tsx +48 -5
  49. package/src/widgets/actions/index.ts +1 -0
  50. package/src/widgets/actions/relative-data/index.ts +1 -0
  51. package/src/widgets/actions/relative-data/labels.ts +6 -0
  52. package/src/widgets/actions/relative-data/relative-data.test.tsx +78 -1
  53. package/src/widgets/actions/relative-data/relative-data.tsx +137 -20
  54. package/src/widgets/actions/relative-data/scale.ts +48 -0
  55. package/src/widgets/actions/relative-data/style.ts +10 -0
  56. package/src/widgets/bar/options.test.ts +122 -0
  57. package/src/widgets/bar/options.ts +31 -16
  58. package/src/widgets/bar/types.ts +6 -0
  59. package/src/widgets/category/category.relative-data.test.tsx +51 -63
  60. package/src/widgets/category/category.tsx +25 -11
  61. package/src/widgets/histogram/bins.ts +22 -0
  62. package/src/widgets/histogram/download.test.ts +10 -0
  63. package/src/widgets/histogram/download.ts +7 -3
  64. package/src/widgets/histogram/index.ts +3 -0
  65. package/src/widgets/histogram/options.test.ts +62 -0
  66. package/src/widgets/histogram/options.ts +44 -19
  67. package/src/widgets/histogram/transforms.test.ts +21 -7
  68. package/src/widgets/histogram/transforms.ts +26 -12
  69. package/src/widgets/histogram/types.ts +25 -5
  70. package/src/widgets/index.ts +7 -1
  71. package/src/widgets/pie/options.test.ts +91 -0
  72. package/src/widgets/pie/options.ts +50 -20
  73. package/src/widgets/pie/types.ts +6 -0
  74. package/src/widgets/scatterplot/download.test.ts +9 -0
  75. package/src/widgets/scatterplot/download.ts +5 -3
  76. package/src/widgets/scatterplot/index.ts +3 -0
  77. package/src/widgets/scatterplot/options.test.ts +90 -0
  78. package/src/widgets/scatterplot/options.ts +53 -15
  79. package/src/widgets/scatterplot/points.ts +35 -0
  80. package/src/widgets/scatterplot/transforms.test.ts +19 -0
  81. package/src/widgets/scatterplot/transforms.ts +23 -18
  82. package/src/widgets/scatterplot/types.ts +25 -2
  83. package/src/widgets/timeseries/options.test.ts +65 -0
  84. package/src/widgets/timeseries/options.ts +37 -16
  85. package/src/widgets/timeseries/types.ts +6 -0
  86. package/src/widgets/utils/item-color.test.ts +74 -0
  87. package/src/widgets/utils/item-color.ts +55 -0
  88. package/dist/actions-CueYrfVr.js +0 -1150
  89. package/dist/actions-CueYrfVr.js.map +0 -1
  90. package/dist/category-DULnoxvk.js.map +0 -1
  91. package/dist/option-builders-DQivvvbb.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scatterplot.js","names":["{ count = 24 }: ScatterplotSkeletonProps","count = 24","Box","styles.grid","dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))","styles.container","(_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n }","(d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n )","<Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\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 {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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","_c","ZOOM_LAYOUT","buildCsvDownloadItem","withPngItem","resolveThemeColor","buildGridConfig","createTooltipPositioner","buildLegendConfig","niceNum","buildAxisLabelStyle","echarts","scatterplotOptions","theme","buildScatterTooltipFormatter","xFormatter","yFormatter","createScatterplotOptionFactory","options","series","symbolSize","selection","selectionSet","option","structural","optionsOverride","mergeOptions","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","ctx","computeScatterBounds","makeDimColor","base","params","key","seriesIdx","dataZoomLayout","layoutDataZoomForScatter","hasXSlider","hasYSlider","fallbackBottom","baseBottom","gridBottom","fallbackRight","gridRight","s","overrideColor","i","niceMinX","niceMaxX","niceMinY","niceMaxY","buildReactiveScatterTooltipFormatter","dataZoom","entry","dz","reactiveYFormatter","createTooltipFormatter","value","item","x","y","formattedX","formattedY","marker","seriesName","structuralFormatter","minX","maxX","minY","maxY","point","styles","spacing","dotSx","size","ScatterplotSkeleton","$","c","t1","t0","count","T0","T1","t2","t3","t4","dots","_temp","Box","_temp2","t5","t6","_temp3","t7","Skeleton","i_1","d","i_0","top","left","createScatterplotDownloadConfig","args","rows","toRelativeScatterplotData","input","isXyTupleArray","total","acc","v","filterScatterplotByLockedPoints","lockedItems","locked","seriesIndex","dataIndex"],"sources":["../../src/widgets/scatterplot/options.ts","../../src/widgets/scatterplot/skeleton.tsx","../../src/widgets/scatterplot/download.ts","../../src/widgets/scatterplot/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 type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\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 `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\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: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\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: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, 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 * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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 ScatterplotWidgetData) : []\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 baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } =\n computeScatterBounds(seriesArr)\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\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 items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n const makeDimColor =\n (seriesIdx: number) => (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary.\n dataset: seriesArr.map((s) => ({ source: s as unknown as number[][] })),\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(seriesArr: ScatterplotWidgetData): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n const x = point?.[0]\n const y = point?.[1]\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY) ? (maxY <= 0 ? 1 : niceNum(maxY)) : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY) ? (minY < 0 ? niceNum(minY) : 0) : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, 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 position: 'relative',\n flex: '1 1 auto',\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\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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 { ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV item\n * with `series, x, y` columns (one row per point). When `getCaptureEl` is\n * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(\n args: WidgetDownloadArgs<ScatterplotWidgetData> & {\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', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const [x, y] of series) {\n rows.push([seriesName, x, y])\n }\n }\n return rows\n },\n }),\n )\n}\n","/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `[number, number][]` — each series is a list of `[x, y]` tuples.\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `[number, number][]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isXyTupleArray(series)) return series\n const total = series.reduce((acc, [, y]) => acc + Math.abs(y), 0)\n if (total <= 0) return series\n return series.map(([x, y]) => [x, (y / total) * 100] as [number, number])\n })\n}\n\nfunction isXyTupleArray(v: unknown): v is [number, number][] {\n if (!Array.isArray(v)) return false\n return v.every(\n (item) =>\n Array.isArray(item) &&\n item.length === 2 &&\n typeof item[0] === 'number' &&\n Number.isFinite(item[0]) &&\n typeof item[1] === 'number' &&\n Number.isFinite(item[1]),\n )\n}\n\n/**\n * `LockSelection` filter for Scatterplot. Data is `[number, number][][]` —\n * points have no `name`, so selection (and locking) is keyed on a synthetic\n * `${seriesIndex}:${dataIndex}` string (same format `useChartSelection`'s\n * `keyFromClick`/`keysFromBrush` produce for this widget). Unlike Histogram,\n * a point's position carries no external meaning (no `ticks` to desync from),\n * so non-locked points are removed outright rather than zeroed.\n */\nexport function filterScatterplotByLockedPoints(\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<string>(lockedItems.map(String))\n return input.map((series: unknown, seriesIndex: number): unknown => {\n if (!isXyTupleArray(series)) return series\n return series.filter((_, dataIndex) =>\n locked.has(`${seriesIndex}:${dataIndex}`),\n )\n })\n}\n"],"mappings":";;;;;;;;;AAoCA,SAAgBwB,EAAmB,EACjC,UACA,eACA,iBACoD;CACpD,OAAO;EACL,MAAM;GACJ,MAAM,SAASC,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAASA,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAASA,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAGP,EAAgB,IAAOO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GAGP,SAAS;GACT,iBAAiBA,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAASA,EAAM,QAAQ,CAAC,CAAC,GAAG,SAASA,EAAM,QAAQ,CAAC,CAAC,CAAC;GAChE,WAAW;IACT,OAAOA,EAAM,QAAQ,OAAO;IAC5B,UAAU;IACV,YAAYA,EAAM,WAAW,QAAQ;GACvC;GACA,UAAUN,EAAwBM,CAAK;GACvC,WAAWC,EAA6BC,GAAYC,CAAU;EAChE;EAGA,QAAQ,EACN,GAAGR,EAAkB;GAAE,WAAW;GAAO,gBAAgB,KAAA;EAAU,CAA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,MAAM,QAAQG,CAAC,IACbA,EAAE,OACN,MACC,MAAM,QAAQlD,CAAI,KAClBA,EAAK,WAAW,KAChB,OAAOA,EAAK,MAAO,YACnB,OAAO,SAASA,EAAK,EAAE,KACvB,OAAOA,EAAK,MAAO,YACnB,OAAO,SAASA,EAAK,EAAE,CAC3B,IAT8B;AAUhC;AAUA,SAAgBmD,EACd,GACA,GACS;CAET,IADIC,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQN,CAAK,GAAG,OAAOA;CAClC,IAAMO,IAAS,IAAI,IAAYD,EAAY,IAAI,MAAM,CAAC;CACtD,OAAON,EAAM,KAAK,GAAiB,MAC5BC,EAAe9F,CAAM,IACnBA,EAAO,QAAQ,GAAG,MACvBoG,EAAO,IAAI,GAAGC,EAAY,GAAGC,GAAW,CAC1C,IAHoCtG,CAIrC;AACH"}
1
+ {"version":3,"file":"scatterplot.js","names":["{ count = 24 }: ScatterplotSkeletonProps","count = 24","Box","styles.grid","dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n ))","styles.container","(_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n }","(d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\n )","<Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\n />\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 {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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","_c","ZOOM_LAYOUT","fixedAxisBounds","withPngItem","mergeOptions","resolveThemeColor","niceNum","buildLegendConfig","buildAxisLabelStyle","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","getScatterplotXY","isTuple","point","isScatterplotDatum","v","isFiniteNumber","x","y","withScatterplotXY","scatterplotOptions","theme","buildScatterTooltipFormatter","xFormatter","yFormatter","createScatterplotOptionFactory","options","series","symbolSize","selection","selectionSet","option","structural","optionsOverride","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseXAxis","baseYAxis","reactiveFormatter","ctx","computeScatterBounds","seriesTemplates","makeDimColor","baseColor","seriesIdx","params","base","key","dataZoomLayout","layoutDataZoomForScatter","hasXSlider","hasYSlider","fallbackBottom","baseBottom","gridBottom","fallbackRight","gridRight","s","overrideColor","i","niceMinX","niceMaxX","niceMinY","niceMaxY","buildReactiveScatterTooltipFormatter","dataZoom","entry","dz","reactiveYFormatter","value","item","formattedX","formattedY","marker","seriesName","structuralFormatter","minX","maxX","minY","maxY","fixedY","styles","spacing","dotSx","size","ScatterplotSkeleton","$","c","t1","t0","count","T0","T1","t2","t3","t4","dots","_temp","Box","_temp2","t5","t6","_temp3","t7","Skeleton","i_1","d","i_0","top","left","createScatterplotDownloadConfig","args","buildCsvDownloadItem","rows","toRelativeScatterplotData","input","isPointArray","total","acc","p","filterScatterplotByLockedPoints","lockedItems","locked","seriesIndex","dataIndex"],"sources":["../../src/widgets/scatterplot/points.ts","../../src/widgets/scatterplot/options.ts","../../src/widgets/scatterplot/skeleton.tsx","../../src/widgets/scatterplot/download.ts","../../src/widgets/scatterplot/transforms.ts"],"sourcesContent":["import type { ScatterplotItem } from './types'\n\n/** `[x, y]` of a {@link ScatterplotItem}, whichever form it takes. */\nexport function getScatterplotXY(\n point: ScatterplotItem,\n): readonly [number, number] {\n return isTuple(point) ? point : [point.x, point.y]\n}\n\n/** Whether `v` is a valid {@link ScatterplotItem} with finite coordinates. */\nexport function isScatterplotDatum(v: unknown): v is ScatterplotItem {\n if (Array.isArray(v)) {\n return v.length === 2 && isFiniteNumber(v[0]) && isFiniteNumber(v[1])\n }\n if (v == null || typeof v !== 'object') return false\n const { x, y } = v as { x?: unknown; y?: unknown }\n return isFiniteNumber(x) && isFiniteNumber(y)\n}\n\n/** Same point with new coordinates; keeps the object form (and `color`). */\nexport function withScatterplotXY(\n point: ScatterplotItem,\n x: number,\n y: number,\n): ScatterplotItem {\n return isTuple(point) ? [x, y] : { ...point, x, y }\n}\n\nfunction isTuple(point: ScatterplotItem): point is readonly [number, number] {\n return Array.isArray(point)\n}\n\nfunction isFiniteNumber(v: unknown): v is number {\n return typeof v === 'number' && Number.isFinite(v)\n}\n","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 { createItemColorResolver } from '../utils/item-color'\nimport { getScatterplotXY } from './points'\nimport type {\n ScatterplotEChartsOption,\n ScatterplotOptionFactoryInput,\n ScatterplotOptionsInput,\n ScatterplotItem,\n ScatterplotWidgetData,\n} from './types'\nimport { fixedAxisBounds } from '../actions/relative-data/scale'\n\n/**\n * Builds the **structural** ECharts option for a scatterplot widget — both\n * axes `type: 'value'` (not category, unlike Bar/Histogram), grid, tooltip\n * triggered per-item rather than per-axis. Intentionally data-agnostic: no\n * series, no dataset, no `legend.show` (those depend on data and are added\n * by {@link createScatterplotOptionFactory}).\n *\n * Styling parity with v1: dark themed tooltip via `createTooltipFormatter`\n * + `createTooltipPositioner`, `buildGridConfig`-based grid, polished\n * axisLine/Tick/splitLine, `overlineDelicate` axis labels, structural\n * legend wired via `buildLegendConfig` (toggled by the merger), and the\n * CARTO `qualitative.bold + secondary` palette — same pattern bar /\n * histogram / pie already use. {@link createScatterplotOptionFactory}\n * wraps this builder in its structural-phase branch.\n */\nexport function scatterplotOptions({\n theme,\n xFormatter,\n yFormatter,\n}: ScatterplotOptionsInput): ScatterplotEChartsOption {\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 `bottom` when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n // Per-point trigger — different from Bar's 'axis' trigger because\n // points don't share an x-coordinate.\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: buildScatterTooltipFormatter(xFormatter, yFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter: undefined }),\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: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(xFormatter && { formatter: xFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n yAxis: {\n type: 'value',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n hideOverlap: true,\n showMinLabel: true,\n showMaxLabel: true,\n ...(yFormatter && { formatter: yFormatter }),\n },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n },\n } as ScatterplotEChartsOption\n}\n\n/**\n * Returns the scatterplot widget's {@link OptionFactory} — one closure\n * that owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link scatterplotOptions}, 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 * (`ScatterplotWidgetData`) into the option via the dataset API. Each\n * series's `[x, y]` tuples land in `dataset[i].source` as 2-column\n * rows; the series uses positional encoding (`encode: { x: 0, y: 1 }`)\n * and `type: 'scatter'`. niceMin/niceMax are computed over both axes\n * so the chart frames data on rounded extents and numeric jitters\n * don't shift gridlines per render. Reactive `ctx.formatter` (driven\n * by RelativeData) re-derives the y-axis label and tooltip at fusion\n * time; `xFormatter` stays baked at structural-build time (relative\n * is a values-axis concept; x is coordinate-space).\n *\n * When `ZoomToggle` installs a `dataZoom` slider, grid bottom is\n * extended and the slider is positioned above the legend row (if any) —\n * same layout dance bar / histogram / timeseries do.\n */\nexport function createScatterplotOptionFactory(\n options: ScatterplotOptionFactoryInput,\n): OptionFactory {\n const { theme, xFormatter, yFormatter, optionsOverride } = options\n const series = options.series\n const symbolSize = options.symbolSize ?? 8\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0 ? new Set<string>(selection) : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = scatterplotOptions({ theme, xFormatter, yFormatter })\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)\n ? (data as ScatterplotWidgetData<ScatterplotItem>)\n : []\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 baseXAxis =\n typeof option.xAxis === 'object' && !Array.isArray(option.xAxis)\n ? option.xAxis\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const reactiveFormatter = ctx?.formatter\n\n const { niceMinX, niceMaxX, niceMinY, niceMaxY } = computeScatterBounds(\n seriesArr,\n // A config transform (RelativeData's `'total'` scale) may pin the\n // y ends; each applies only on the side the data reaches.\n fixedAxisBounds(baseYAxis),\n )\n\n // Dim non-selected points via `series.itemStyle.color`. The selection\n // key is `${seriesIndex}:${dataIndex}`; we read those off the params\n // ECharts hands to the callback per-data.\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 items would stay dimmed forever after an external clear.\n // Keeping the key always-present means a plain setOption merge swaps\n // the callback in place, no `replaceMerge` and no entry-animation\n // flash on selection on/off.\n //\n // The base colour is the point's own `color` (object points), else the\n // template's `itemStyle.color`, else the series colour / palette.\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const makeDimColor = (seriesIdx: number, datums: readonly unknown[]) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template: seriesTemplates[seriesIdx] ?? seriesTemplates[0],\n fallback: (params) => params.color as string,\n })\n return (params: CallbackDataParams) => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const key = `${seriesIdx}:${params.dataIndex}`\n return selectionSet.has(key)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n }\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`,\n // reserve grid space and lift any x-slider above the legend (if\n // present). Scatter supports 2D zoom via `axes: ['x', 'y']` — in\n // that case there's also a vertical y-slider on the right edge, so\n // we reserve `grid.right` separately. Inside-only dataZoom entries\n // (no `type: 'slider'`) take no grid space.\n const dataZoomLayout = layoutDataZoomForScatter(option.dataZoom, hasLegend)\n const hasXSlider = dataZoomLayout?.hasXSlider ?? false\n const hasYSlider = dataZoomLayout?.hasYSlider ?? false\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = hasXSlider\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n const fallbackRight =\n typeof baseGrid.right === 'number' ? baseGrid.right : 8\n const gridRight = hasYSlider\n ? fallbackRight + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : fallbackRight\n\n return {\n ...option,\n // ECharts dataset.source wants a mutable [number, number][] shape; we\n // hold readonly tuples internally, so cast at the boundary. Object\n // points are flattened to `[x, y]` so the positional encode and the\n // tooltip keep reading tuples.\n dataset: seriesArr.map((s) => ({\n source: (s.every(Array.isArray)\n ? s\n : s.map(getScatterplotXY)) as unknown as number[][],\n })),\n series: seriesArr.map((s, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n type: 'scatter' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n symbolSize,\n emphasis: { focus: 'series' },\n itemStyle: { color: makeDimColor(i, s) },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom, right: gridRight },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout.entries } : {}),\n xAxis: {\n ...baseXAxis,\n min: niceMinX,\n max: niceMaxX,\n } as EChartsOption['xAxis'],\n yAxis: {\n ...baseYAxis,\n min: niceMinY,\n max: niceMaxY,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n // Re-derive the y-axis formatter at fusion time so RelativeData's\n // percent formatter (written to `state.formatter`) flows through\n // without rebuilding the structural option. Falls back to the\n // structural `yFormatter` already baked in `baseYAxis.axisLabel`\n // (which `String(value)` if neither is set).\n ...(reactiveFormatter ? { formatter: reactiveFormatter } : {}),\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n // Rebuild the tooltip formatter so the live y-axis formatter is\n // applied to the y-coordinate in the (x, y) label. xFormatter is\n // structural — relative is a values-axis concept, so xFormatter\n // doesn't change under RelativeData.\n formatter: buildReactiveScatterTooltipFormatter(\n (baseTooltip as { formatter?: unknown }).formatter,\n reactiveFormatter,\n xFormatter,\n ),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Lay out the `dataZoom` array for the scatter chart:\n * - Detect whether any horizontal (x-axis) slider is present — if so\n * lift it above the legend row when a legend is shown.\n * - Detect whether any vertical (y-axis) slider is present — the\n * caller reserves `grid.right` so the slider doesn't overlap the\n * plot area.\n *\n * Returns `null` when there's no `dataZoom` so callers can skip the\n * layout adjustment entirely. An entry is considered an \"x-slider\" if\n * it has `xAxisIndex` set (or no axis index — defaults to x in ECharts).\n * A \"y-slider\" has `yAxisIndex` set.\n */\nfunction layoutDataZoomForScatter(\n dataZoom: unknown,\n hasLegend: boolean,\n): { entries: unknown[]; hasXSlider: boolean; hasYSlider: boolean } | null {\n if (!Array.isArray(dataZoom) || dataZoom.length === 0) return null\n let hasXSlider = false\n let hasYSlider = false\n const entries = dataZoom.map((entry: unknown) => {\n if (entry == null || typeof entry !== 'object') return entry\n const dz = entry as {\n type?: string\n xAxisIndex?: unknown\n yAxisIndex?: unknown\n bottom?: number\n }\n if (dz.type !== 'slider') return dz\n const targetsY = dz.yAxisIndex !== undefined\n if (targetsY) {\n hasYSlider = true\n return dz\n }\n // Either explicit x or defaulted (ECharts defaults sliders to xAxis\n // when no axis index is provided).\n hasXSlider = true\n if (hasLegend) {\n return { ...dz, bottom: ZOOM_LAYOUT.sliderBottomWithLegend }\n }\n return dz\n })\n return { entries, hasXSlider, hasYSlider }\n}\n\n/**\n * If a reactive (store-driven) y formatter is provided, re-build the\n * scatter tooltip formatter using it. Otherwise, return the structural\n * formatter unchanged so the original `xFormatter` / `yFormatter`\n * baked into `scatterplotOptions` still applies. The structural\n * formatter has stable identity per `scatterplotOptions` call, so this\n * path doesn't churn ECharts on every render.\n */\nfunction buildReactiveScatterTooltipFormatter(\n structuralFormatter: unknown,\n reactiveYFormatter: ((value: number) => string) | undefined,\n xFormatter: ((value: number) => string) | undefined,\n) {\n if (!reactiveYFormatter) return structuralFormatter\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? reactiveYFormatter(y) : String(y ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction buildScatterTooltipFormatter(\n xFormatter: ((value: number) => string) | undefined,\n yFormatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const value = item.value as readonly [number, number] | undefined\n const x = value?.[0]\n const y = value?.[1]\n const formattedX =\n typeof x === 'number' ? (xFormatter ? xFormatter(x) : String(x)) : ''\n const formattedY =\n typeof y === 'number' ? (yFormatter ? yFormatter(y) : String(y)) : ''\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: `(${formattedX}, ${formattedY})`,\n seriesName,\n marker,\n value: '',\n }\n })\n}\n\nfunction computeScatterBounds(\n seriesArr: ScatterplotWidgetData<ScatterplotItem>,\n fixedY: { min?: number; max?: number } = {},\n): {\n niceMinX: number\n niceMaxX: number\n niceMinY: number\n niceMaxY: number\n} {\n let minX = Infinity\n let maxX = -Infinity\n let minY = Infinity\n let maxY = -Infinity\n for (const series of seriesArr) {\n for (const point of series) {\n if (point == null) continue\n const [x, y] = getScatterplotXY(point)\n if (typeof x === 'number' && Number.isFinite(x)) {\n if (x < minX) minX = x\n if (x > maxX) maxX = x\n }\n if (typeof y === 'number' && Number.isFinite(y)) {\n if (y < minY) minY = y\n if (y > maxY) maxY = y\n }\n }\n }\n // Mirror bar's `computeNiceBounds`: clamp min to 0 when data is\n // non-negative (gridline reads cleanly from zero), apply `niceNum` to\n // negative mins, and floor max=0 to 1 so the chart always has range.\n // Scatter can have free coordinates so we apply this per-axis.\n const niceMaxX = Number.isFinite(maxX) ? (maxX <= 0 ? 1 : niceNum(maxX)) : 1\n const niceMaxY = Number.isFinite(maxY)\n ? maxY <= 0\n ? 1\n : (fixedY.max ?? niceNum(maxY))\n : 1\n const niceMinX = Number.isFinite(minX) ? (minX < 0 ? niceNum(minX) : 0) : 0\n const niceMinY = Number.isFinite(minY)\n ? minY < 0\n ? (fixedY.min ?? niceNum(minY))\n : 0\n : 0\n return { niceMinX, niceMaxX, niceMinY, niceMaxY }\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, 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 position: 'relative',\n flex: '1 1 auto',\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\n// `sx` callback that needs runtime args — extracted at module scope so the\n// `styles` object can satisfy `Record<string, SxProps<Theme>>` cleanly\n// (function `sx`-with-args isn't assignable to plain `SxProps<Theme>`).\nconst dotSx = (top: string, left: string, size: number): SxProps<Theme> => ({\n position: 'absolute',\n top,\n left,\n width: size,\n height: size,\n borderRadius: '50%',\n})\n\nexport interface ScatterplotSkeletonProps {\n /** Number of dots to render. */\n count?: number\n}\n\n/**\n * Loading state for the Scatterplot widget. Mirrors a scatter chart's\n * silhouette — a deterministic spread of small circular dots in the plot\n * area plus a legend stub — so the skeleton reads as \"a scatter chart\"\n * rather than a generic list. Matches bar/histogram/pie skeleton structure\n * (grid stub + legend stub in a flex column).\n */\nexport function ScatterplotSkeleton({ count = 24 }: ScatterplotSkeletonProps) {\n // Deterministic pseudo-scatter positions so the skeleton doesn't flicker.\n const dots = Array.from({ length: count }, (_, i) => {\n const top = 10 + ((i * 37) % 80)\n const left = 5 + ((i * 53) % 90)\n const size = 8 + ((i * 7) % 6)\n return { top: `${top}%`, left: `${left}%`, size }\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {dots.map((d, i) => (\n <Skeleton\n key={`dot-${i}`}\n variant='circular'\n sx={dotSx(d.top, d.left, d.size)}\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 { getScatterplotXY } from './points'\nimport type { ScatterplotItem, ScatterplotWidgetData } from './types'\n\n/**\n * Download menu items for the Scatterplot widget. Always includes a CSV item\n * with `series, x, y` columns (one row per point). When `getCaptureEl` is\n * given, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createScatterplotDownloadConfig(\n args: WidgetDownloadArgs<ScatterplotWidgetData<ScatterplotItem>> & {\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', 'x', 'y']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const point of series) {\n const [x, y] = getScatterplotXY(point)\n rows.push([seriesName, x, y])\n }\n }\n return rows\n },\n }),\n )\n}\n","import {\n getScatterplotXY,\n isScatterplotDatum,\n withScatterplotXY,\n} from './points'\nimport type { ScatterplotItem } from './types'\n\n/**\n * Scatterplot-specific `RelativeData` transform. Scatter data is\n * `ScatterplotItem[][]` — each series is a list of `[x, y]` tuples or\n * `{ x, y, color? }` points (whose shape is kept).\n * Relative is a values-axis concept, so this rewrites `y` to its\n * share of the series's total `y` (0–100) and leaves `x` raw — x is\n * coordinate space, not part of the cohort total.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeScatterplotData} />`.\n *\n * The denominator is the sum of |y| across the series so mixed-sign\n * y values produce sane signed shares-of-magnitude. A series whose\n * total y-magnitude is zero (all-zero or empty input) is returned\n * unchanged so a stalled or empty data set doesn't show misleading 0%\n * values. Inputs whose shape isn't `ScatterplotItem[]` fall through\n * untouched.\n */\nexport const toRelativeScatterplotData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isPointArray(series)) return series\n const total = series.reduce(\n (acc, p) => acc + Math.abs(getScatterplotXY(p)[1]),\n 0,\n )\n if (total <= 0) return series\n return series.map((p) => {\n const [x, y] = getScatterplotXY(p)\n return withScatterplotXY(p, x, (y / total) * 100)\n })\n })\n}\n\nfunction isPointArray(v: unknown): v is ScatterplotItem[] {\n return Array.isArray(v) && v.every(isScatterplotDatum)\n}\n\n/**\n * `LockSelection` filter for Scatterplot. Data is `ScatterplotItem[][]` —\n * points have no `name`, so selection (and locking) is keyed on a synthetic\n * `${seriesIndex}:${dataIndex}` string (same format `useChartSelection`'s\n * `keyFromClick`/`keysFromBrush` produce for this widget). Unlike Histogram,\n * a point's position carries no external meaning (no `ticks` to desync from),\n * so non-locked points are removed outright rather than zeroed.\n */\nexport function filterScatterplotByLockedPoints(\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<string>(lockedItems.map(String))\n return input.map((series: unknown, seriesIndex: number): unknown => {\n if (!isPointArray(series)) return series\n return series.filter((_, dataIndex) =>\n locked.has(`${seriesIndex}:${dataIndex}`),\n )\n })\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB2B,EACd,GAC2B;CAC3B,OAAOC,EAAQC,CAAK,IAAIA,IAAQ,CAACA,EAAM,GAAGA,EAAM,CAAC;AACnD;AAGA,SAAgBC,EAAmB,GAAkC;CACnE,IAAI,MAAM,QAAQC,CAAC,GACjB,OAAOA,EAAE,WAAW,KAAKC,EAAeD,EAAE,EAAE,KAAKC,EAAeD,EAAE,EAAE;CAEtE,IAAiB,OAAOA,KAAM,aAA1BA,GAAoC,OAAO;CAC/C,IAAM,EAAE,MAAG,SAAMA;CACjB,OAAOC,EAAeC,CAAC,KAAKD,EAAeE,CAAC;AAC9C;AAGA,SAAgBC,EACd,GACA,GACA,GACiB;CACjB,OAAOP,EAAQC,CAAK,IAAI,CAACI,GAAGC,CAAC,IAAI;EAAE,GAAGL;EAAO;EAAG;CAAE;AACpD;AAEA,SAASD,EAAQ,GAA4D;CAC3E,OAAO,MAAM,QAAQC,CAAK;AAC5B;AAEA,SAASG,EAAe,GAAyB;CAC/C,OAAO,OAAOD,KAAM,YAAY,OAAO,SAASA,CAAC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AkB;AACvD;AAUA,SAAgB8G,EACd,GACA,GACS;CAET,IADIC,EAAY,WAAW,KACvB,CAAC,MAAM,QAAQN,CAAK,GAAG,OAAOA;CAClC,IAAMO,IAAS,IAAI,IAAYD,EAAY,IAAI,MAAM,CAAC;CACtD,OAAON,EAAM,KAAK,GAAiB,MAC5BC,EAAa7F,CAAM,IACjBA,EAAO,QAAQ,GAAG,MACvBmG,EAAO,IAAI,GAAGC,EAAY,GAAGC,GAAW,CAC1C,IAHkCrG,CAInC;AACH"}
@@ -1,20 +1,21 @@
1
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
- 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
- import { c as f } from "react/compiler-runtime";
6
- import { Box as p, Skeleton as m } from "@mui/material";
7
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
- import * as _ from "echarts";
2
+ import { n as t } from "../scale-Bhx8HKEB.js";
3
+ import { n, t as r } from "../download-B4sykOFm.js";
4
+ import { n as i, r as a, t as o } from "../utils-C-eWwOhE.js";
5
+ import { c as s, i as c, n as l, o as u, r as d, s as f, t as p } from "../item-color-B7xkIpDZ.js";
6
+ import { c as m } from "react/compiler-runtime";
7
+ import { Box as h, Skeleton as g } from "@mui/material";
8
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
9
+ import * as y from "echarts";
9
10
  //#region src/widgets/timeseries/options.ts
10
- function v({ theme: e, formatter: t, labelFormatter: n }) {
11
+ function b({ theme: e, formatter: t, labelFormatter: n }) {
11
12
  let r = 0, i = 1;
12
13
  return {
13
14
  grid: {
14
15
  left: parseInt(e.spacing(1)),
15
16
  top: parseInt(e.spacing(3)),
16
17
  right: parseInt(e.spacing(1)),
17
- ...s(!1, e),
18
+ ...d(!1, e),
18
19
  containLabel: !0
19
20
  },
20
21
  tooltip: {
@@ -28,10 +29,10 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
28
29
  fontFamily: e.typography.caption.fontFamily
29
30
  },
30
31
  axisPointer: { type: "line" },
31
- position: c(e),
32
- formatter: b(t, n)
32
+ position: f(e),
33
+ formatter: S(t, n)
33
34
  },
34
- legend: { ...l({ hasLegend: !1 }) },
35
+ legend: { ...c({ hasLegend: !1 }) },
35
36
  axisPointer: { lineStyle: { color: e.palette.grey[400] } },
36
37
  color: [e.palette.secondary.main, ...Object.values(e.palette.qualitative?.bold ?? {})],
37
38
  xAxis: {
@@ -39,7 +40,7 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
39
40
  axisLine: { show: !1 },
40
41
  axisTick: { show: !1 },
41
42
  axisLabel: {
42
- ...d(e),
43
+ ...l(e),
43
44
  padding: [
44
45
  parseInt(e.spacing(.5)),
45
46
  0,
@@ -53,8 +54,8 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
53
54
  },
54
55
  yAxis: {
55
56
  type: "value",
56
- min: (e) => (r = e.min < 0 ? u(e.min) : 0, r),
57
- max: (e) => (i = e.max <= 0 ? 1 : u(e.max), i),
57
+ min: (e) => (r = e.min < 0 ? s(e.min) : 0, r),
58
+ max: (e) => (i = e.max <= 0 ? 1 : s(e.max), i),
58
59
  axisLine: { show: !1 },
59
60
  axisTick: { show: !1 },
60
61
  splitLine: {
@@ -62,7 +63,7 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
62
63
  lineStyle: { color: e.palette.black?.[4] ?? e.palette.divider }
63
64
  },
64
65
  axisLabel: {
65
- ...d(e),
66
+ ...l(e),
66
67
  margin: parseInt(e.spacing(1)),
67
68
  show: !0,
68
69
  showMaxLabel: !0,
@@ -74,46 +75,54 @@ function v({ theme: e, formatter: t, labelFormatter: n }) {
74
75
  }
75
76
  };
76
77
  }
77
- function y(t) {
78
- let { theme: n, formatter: o, labelFormatter: s, optionsOverride: c } = t, l = t.series, d = t.smooth ?? !0, f = t.area ?? !1, p = t.selection, m = p && p.length > 0 ? new Set(p) : null, h = (e) => e instanceof Date ? e.getTime() : e;
79
- return (t, p, g) => {
80
- if (t == null) {
81
- let e = v({
82
- theme: n,
83
- formatter: o,
84
- labelFormatter: s
78
+ function x(n) {
79
+ let { theme: r, formatter: c, labelFormatter: l, optionsOverride: u } = n, d = n.series, f = n.smooth ?? !0, m = n.area ?? !1, h = n.selection, g = h && h.length > 0 ? new Set(h) : null, _ = (e) => e instanceof Date ? e.getTime() : e;
80
+ return (n, h, v) => {
81
+ if (n == null) {
82
+ let e = b({
83
+ theme: r,
84
+ formatter: c,
85
+ labelFormatter: l
85
86
  });
86
- return c ? i(e, c) : e;
87
+ return u ? a(e, u) : e;
87
88
  }
88
- let y = Array.isArray(p) ? p : [];
89
- if (y.length === 0) return {
90
- ...t,
89
+ let x = Array.isArray(h) ? h : [];
90
+ if (x.length === 0) return {
91
+ ...n,
91
92
  dataset: [],
92
93
  series: []
93
94
  };
94
- let x = y.length > 1, S = Array.isArray(t.series) ? t.series : [], C = S[0] ?? {}, w = typeof t.yAxis == "object" && !Array.isArray(t.yAxis) ? t.yAxis : {}, T = typeof t.grid == "object" && !Array.isArray(t.grid) ? t.grid : {}, E = typeof t.tooltip == "object" && !Array.isArray(t.tooltip) ? t.tooltip : {}, D = typeof t.legend == "object" && !Array.isArray(t.legend) ? t.legend : {}, O = g?.formatter, k = 0, A = 1, j = r(t.dataZoom, x), M = typeof T.bottom == "number" ? T.bottom : 24, N = x ? 56 : M, P = j ? N + e.sliderHeight + e.sliderGap : N, F = { color: (e) => {
95
- let t = e.value?.name, n = e.color;
96
- return !m || t == null || m.has(h(t)) ? n : _.color.modifyAlpha(n, .15);
97
- } };
95
+ let C = x.length > 1, w = Array.isArray(n.series) ? n.series : [], T = w[0] ?? {}, E = typeof n.yAxis == "object" && !Array.isArray(n.yAxis) ? n.yAxis : {}, D = t(E), O = typeof n.grid == "object" && !Array.isArray(n.grid) ? n.grid : {}, k = typeof n.tooltip == "object" && !Array.isArray(n.tooltip) ? n.tooltip : {}, A = typeof n.legend == "object" && !Array.isArray(n.legend) ? n.legend : {}, j = v?.formatter, M = 0, N = 1, P = i(n.dataZoom, C), F = typeof O.bottom == "number" ? O.bottom : 24, I = C ? 56 : F, L = P ? I + e.sliderHeight + e.sliderGap : I, R = (e, t) => {
96
+ let n = p({
97
+ theme: r,
98
+ datums: e,
99
+ template: t,
100
+ fallback: (e) => e.color
101
+ });
102
+ return { color: (e) => {
103
+ let t = e.value?.name, r = n(e);
104
+ return !g || t == null || g.has(_(t)) ? r : y.color.modifyAlpha(r, .15);
105
+ } };
106
+ }, z = x.some((e) => e.some((e) => typeof e?.color == "string" && e.color !== ""));
98
107
  return {
99
- ...t,
100
- dataset: y.map((e) => ({ source: e })),
101
- series: y.map((e, t) => {
102
- let r = S[t] ?? C, i = a(n, l?.[t]?.color);
108
+ ...n,
109
+ dataset: x.map((e) => ({ source: e })),
110
+ series: x.map((e, t) => {
111
+ let n = w[t] ?? T, i = o(r, d?.[t]?.color);
103
112
  return {
104
- ...typeof r == "object" ? r : {},
113
+ ...typeof n == "object" ? n : {},
105
114
  type: "line",
106
115
  datasetIndex: t,
107
- name: l?.[t]?.name ?? `Series ${t + 1}`,
116
+ name: d?.[t]?.name ?? `Series ${t + 1}`,
108
117
  encode: {
109
118
  x: "name",
110
119
  y: "value"
111
120
  },
112
- smooth: d,
113
- showSymbol: m != null,
114
- ...f ? { areaStyle: {} } : {},
121
+ smooth: f,
122
+ showSymbol: g != null || z,
123
+ ...m ? { areaStyle: {} } : {},
115
124
  emphasis: { focus: "series" },
116
- itemStyle: F,
125
+ itemStyle: R(e, n),
117
126
  ...i ? {
118
127
  color: i,
119
128
  lineStyle: { color: i }
@@ -121,32 +130,32 @@ function y(t) {
121
130
  };
122
131
  }),
123
132
  legend: {
124
- ...D,
125
- show: x
133
+ ...A,
134
+ show: C
126
135
  },
127
136
  grid: {
128
- ...T,
129
- bottom: P
137
+ ...O,
138
+ bottom: L
130
139
  },
131
- ...j ? { dataZoom: j } : {},
140
+ ...P ? { dataZoom: P } : {},
132
141
  yAxis: {
133
- ...w,
134
- min: (e) => (k = e.min < 0 ? u(e.min) : 0, k),
135
- max: (e) => (A = e.max <= 0 ? 1 : u(e.max), A),
142
+ ...E,
143
+ min: (e) => (M = e.min < 0 ? D.min ?? s(e.min) : 0, M),
144
+ max: (e) => (N = e.max <= 0 ? 1 : D.max ?? s(e.max), N),
136
145
  axisLabel: {
137
- ...w.axisLabel ?? {},
138
- formatter: (e) => e !== A && e !== k || e === 0 ? "" : O ? O(e) : String(e)
146
+ ...E.axisLabel ?? {},
147
+ formatter: (e) => e !== N && e !== M || e === 0 ? "" : j ? j(e) : String(e)
139
148
  }
140
149
  },
141
150
  tooltip: {
142
- ...E,
143
- formatter: b(O, s)
151
+ ...k,
152
+ formatter: S(j, l)
144
153
  }
145
154
  };
146
155
  };
147
156
  }
148
- function b(e, t) {
149
- return o((n) => {
157
+ function S(e, t) {
158
+ return u((n) => {
150
159
  let r = n.value, i = r?.value, a = typeof i == "number" && e ? e(i) : i ?? "", o = typeof n.marker == "string" ? n.marker : "", s = n.seriesName ? `${n.seriesName}: ` : "", c = r?.name ?? n.name, l = t && c != null ? t(c instanceof Date ? c : new Date(c)) : c ?? "";
151
160
  return {
152
161
  name: String(l),
@@ -158,7 +167,7 @@ function b(e, t) {
158
167
  }
159
168
  //#endregion
160
169
  //#region src/widgets/timeseries/skeleton.tsx
161
- var x = {
170
+ var C = {
162
171
  container: {
163
172
  display: "flex",
164
173
  flexDirection: "column",
@@ -204,42 +213,42 @@ var x = {
204
213
  gap: ({ spacing: e }) => e(1.5)
205
214
  }
206
215
  };
207
- function S() {
208
- let e = f(2), t;
209
- e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ g(p, {
210
- sx: x.graph,
216
+ function w() {
217
+ let e = m(2), t;
218
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ v(h, {
219
+ sx: C.graph,
211
220
  children: [
212
- /* @__PURE__ */ h(m, {
221
+ /* @__PURE__ */ _(g, {
213
222
  variant: "rectangular",
214
- sx: x.segmentA
223
+ sx: C.segmentA
215
224
  }),
216
- /* @__PURE__ */ h(m, {
225
+ /* @__PURE__ */ _(g, {
217
226
  variant: "rectangular",
218
- sx: x.segmentB
227
+ sx: C.segmentB
219
228
  }),
220
- /* @__PURE__ */ h(m, {
229
+ /* @__PURE__ */ _(g, {
221
230
  variant: "rectangular",
222
- sx: x.segmentC
231
+ sx: C.segmentC
223
232
  })
224
233
  ]
225
234
  }), e[0] = t) : t = e[0];
226
235
  let n;
227
- return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ g(p, {
228
- sx: x.container,
229
- children: [t, /* @__PURE__ */ h(p, {
230
- sx: x.legend,
231
- children: [0, 1].map(C)
236
+ return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ v(h, {
237
+ sx: C.container,
238
+ children: [t, /* @__PURE__ */ _(h, {
239
+ sx: C.legend,
240
+ children: [0, 1].map(T)
232
241
  })]
233
242
  }), e[1] = n) : n = e[1], n;
234
243
  }
235
- function C(e) {
236
- return /* @__PURE__ */ g(p, {
237
- sx: x.legendItem,
238
- children: [/* @__PURE__ */ h(m, {
244
+ function T(e) {
245
+ return /* @__PURE__ */ v(h, {
246
+ sx: C.legendItem,
247
+ children: [/* @__PURE__ */ _(g, {
239
248
  variant: "circular",
240
249
  width: 8,
241
250
  height: 8
242
- }), /* @__PURE__ */ h(m, {
251
+ }), /* @__PURE__ */ _(g, {
243
252
  width: 48,
244
253
  height: 8
245
254
  })]
@@ -247,8 +256,8 @@ function C(e) {
247
256
  }
248
257
  //#endregion
249
258
  //#region src/widgets/timeseries/download.ts
250
- function w(e) {
251
- return n(e, t({
259
+ function E(e) {
260
+ return r(e, n({
252
261
  filename: e.filename,
253
262
  getRows: (t) => {
254
263
  let n = e.getData(t), r = n.length, i = [], a = /* @__PURE__ */ new Set();
@@ -260,7 +269,7 @@ function w(e) {
260
269
  for (let t = 0; t < r; t++) s.push(e.seriesNames?.[t] ?? `series_${t + 1}`);
261
270
  let c = [s];
262
271
  for (let e of i) {
263
- let t = [T(e)], n = String(e);
272
+ let t = [D(e)], n = String(e);
264
273
  for (let e of o) t.push(e.get(n) ?? "");
265
274
  c.push(t);
266
275
  }
@@ -268,12 +277,12 @@ function w(e) {
268
277
  }
269
278
  }));
270
279
  }
271
- function T(e) {
280
+ function D(e) {
272
281
  return e instanceof Date ? e.toISOString() : typeof e == "number" ? new Date(e).toISOString() : e;
273
282
  }
274
283
  //#endregion
275
284
  //#region src/widgets/timeseries/transforms.ts
276
- function E(e, t) {
285
+ function O(e, t) {
277
286
  if (t.length === 0 || !Array.isArray(e)) return e;
278
287
  let n = new Set(t);
279
288
  return e.map((e) => Array.isArray(e) ? e.filter((e) => {
@@ -283,6 +292,6 @@ function E(e, t) {
283
292
  }) : e);
284
293
  }
285
294
  //#endregion
286
- export { S as TimeseriesSkeleton, w as createTimeseriesDownloadConfig, y as createTimeseriesOptionFactory, E as filterTimeseriesByLockedItems, v as timeseriesOptions };
295
+ export { w as TimeseriesSkeleton, E as createTimeseriesDownloadConfig, x as createTimeseriesOptionFactory, O as filterTimeseriesByLockedItems, b as timeseriesOptions };
287
296
 
288
297
  //# sourceMappingURL=timeseries.js.map