@carto/ps-react-ui 6.3.0 → 6.5.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.
- package/dist/actions-D_PVFZaM.js +1272 -0
- package/dist/actions-D_PVFZaM.js.map +1 -0
- package/dist/{category-DULnoxvk.js → category-UIGvFN3D.js} +263 -246
- package/dist/category-UIGvFN3D.js.map +1 -0
- package/dist/chat.js +472 -470
- package/dist/chat.js.map +1 -1
- package/dist/{components-CTUpdQuj.js → components-DDJU4m0t.js} +8 -8
- package/dist/components-DDJU4m0t.js.map +1 -0
- package/dist/components.js +2 -2
- package/dist/{download-B4sykOFm.js → download-DIj1Iz0t.js} +2 -2
- package/dist/{download-B4sykOFm.js.map → download-DIj1Iz0t.js.map} +1 -1
- package/dist/{formula-DJS-JLpk.js → formula-CSHhAoyW.js} +4 -4
- package/dist/{formula-DJS-JLpk.js.map → formula-CSHhAoyW.js.map} +1 -1
- package/dist/{item-color-B7xkIpDZ.js → item-color-7o7pFBR2.js} +26 -18
- package/dist/item-color-7o7pFBR2.js.map +1 -0
- package/dist/markdown-B8lLR-NY.js +106 -0
- package/dist/markdown-B8lLR-NY.js.map +1 -0
- package/dist/scale-Bhx8HKEB.js +29 -0
- package/dist/scale-Bhx8HKEB.js.map +1 -0
- package/dist/{spread-CQwFIwuz.js → spread-BRfPPIep.js} +3 -3
- package/dist/{spread-CQwFIwuz.js.map → spread-BRfPPIep.js.map} +1 -1
- package/dist/style-DTLuIo84.js +87 -0
- package/dist/style-DTLuIo84.js.map +1 -0
- package/dist/{styles-BCEBm7xh.js → styles-yKcpfyNV.js} +5 -5
- package/dist/styles-yKcpfyNV.js.map +1 -0
- package/dist/{table-DEdW_fDj.js → table-Col_FRvb.js} +2 -2
- package/dist/{table-DEdW_fDj.js.map → table-Col_FRvb.js.map} +1 -1
- package/dist/theme/tailwind.css +373 -0
- package/dist/theme.js +123 -0
- package/dist/theme.js.map +1 -0
- package/dist/types/components/lasso-tool/styles.d.ts +4 -4
- package/dist/types/theme/create-carto-theme.d.ts +7 -0
- package/dist/types/theme/deep-merge.d.ts +6 -0
- package/dist/types/theme/generate-tailwind-css.d.ts +8 -0
- package/dist/types/theme/index.d.ts +2 -0
- package/dist/types/widgets/actions/index.d.ts +1 -1
- package/dist/types/widgets/actions/relative-data/index.d.ts +1 -0
- package/dist/types/widgets/actions/relative-data/labels.d.ts +3 -0
- package/dist/types/widgets/actions/relative-data/relative-data.d.ts +16 -2
- package/dist/types/widgets/actions/relative-data/scale.d.ts +26 -0
- package/dist/types/widgets/actions/relative-data/style.d.ts +12 -0
- package/dist/types/widgets/category/category.d.ts +2 -1
- package/dist/types/widgets/index.d.ts +1 -1
- package/dist/types/widgets/markdown/style.d.ts +74 -0
- package/dist/types/widgets/utils/spacing-px.d.ts +13 -0
- package/dist/{utils-C-eWwOhE.js → utils-Dw4y8tiq.js} +2 -2
- package/dist/{utils-C-eWwOhE.js.map → utils-Dw4y8tiq.js.map} +1 -1
- package/dist/widgets/actions.js +3 -3
- package/dist/widgets/bar.js +85 -84
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +1 -1
- package/dist/widgets/formula.js +1 -1
- package/dist/widgets/histogram.js +109 -108
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/markdown.js +1 -1
- package/dist/widgets/pie.js +78 -78
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/scatterplot.js +121 -120
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/spread.js +1 -1
- package/dist/widgets/table.js +1 -1
- package/dist/widgets/timeseries.js +91 -90
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/utils.js +1 -1
- package/dist/widgets.js +283 -279
- package/dist/widgets.js.map +1 -1
- package/dist/{zoom-toggle-MmLjMTEw.js → zoom-toggle-DqrV_0Ji.js} +2 -2
- package/dist/{zoom-toggle-MmLjMTEw.js.map → zoom-toggle-DqrV_0Ji.js.map} +1 -1
- package/package.json +8 -1
- package/src/chat/bubbles/styles.ts +2 -0
- package/src/components/lasso-tool/lasso-tool-inline.test.tsx +4 -4
- package/src/components/lasso-tool/lasso-tool-inline.tsx +6 -6
- package/src/components/lasso-tool/styles.ts +4 -4
- package/src/theme/create-carto-theme.test.ts +53 -0
- package/src/theme/create-carto-theme.ts +21 -0
- package/src/theme/deep-merge.test.ts +25 -0
- package/src/theme/deep-merge.ts +22 -0
- package/src/theme/generate-tailwind-css.test.ts +87 -0
- package/src/theme/generate-tailwind-css.ts +178 -0
- package/src/theme/index.ts +2 -0
- package/src/theme/tailwind-compile.test.ts +71 -0
- package/src/theme/tailwind.css +373 -0
- package/src/widgets/actions/index.ts +1 -0
- package/src/widgets/actions/relative-data/index.ts +1 -0
- package/src/widgets/actions/relative-data/labels.ts +6 -0
- package/src/widgets/actions/relative-data/relative-data.test.tsx +78 -1
- package/src/widgets/actions/relative-data/relative-data.tsx +137 -20
- package/src/widgets/actions/relative-data/scale.ts +48 -0
- package/src/widgets/actions/relative-data/style.ts +10 -0
- package/src/widgets/bar/options.test.ts +16 -0
- package/src/widgets/bar/options.ts +13 -8
- package/src/widgets/category/category.relative-data.test.tsx +51 -63
- package/src/widgets/category/category.tsx +25 -11
- package/src/widgets/histogram/options.ts +13 -8
- package/src/widgets/index.ts +1 -0
- package/src/widgets/markdown/style.ts +40 -0
- package/src/widgets/note/widget-note.tsx +4 -1
- package/src/widgets/pie/options.ts +5 -4
- package/src/widgets/scatterplot/options.test.ts +12 -0
- package/src/widgets/scatterplot/options.ts +25 -10
- package/src/widgets/timeseries/options.ts +13 -8
- package/src/widgets/utils/css-variables-theme.test.ts +32 -0
- package/src/widgets/utils/option-builders.ts +4 -6
- package/src/widgets/utils/spacing-px.test.ts +42 -0
- package/src/widgets/utils/spacing-px.ts +24 -0
- package/dist/actions-CkxKe8-J.js +0 -1160
- package/dist/actions-CkxKe8-J.js.map +0 -1
- package/dist/category-DULnoxvk.js.map +0 -1
- package/dist/components-CTUpdQuj.js.map +0 -1
- package/dist/item-color-B7xkIpDZ.js.map +0 -1
- package/dist/markdown-DmvLi3vx.js +0 -159
- package/dist/markdown-DmvLi3vx.js.map +0 -1
- package/dist/styles-BCEBm7xh.js.map +0 -1
package/dist/widgets/bar.js.map
CHANGED
|
@@ -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","_c","ZOOM_LAYOUT","buildCsvDownloadItem","withPngItem","positionDataZoomForLegend","mergeOptions","resolveThemeColor","niceNum","buildLegendConfig","buildAxisLabelStyle","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","barOptions","niceMin","niceMax","theme","buildBarTooltipFormatter","formatter","labelFormatter","v","extent","value","createBarOptionFactory","options","series","selection","selectionSet","option","structural","optionsOverride","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseYAxis","seriesTemplates","broadcastTemplate","liveFormatter","ctx","liveLabelFormatter","dataZoomLayout","fallbackBottom","baseBottom","gridBottom","makeDimItemStyle","baseColor","params","base","name","s","template","i","overrideColor","raw","item","formattedValue","marker","seriesName","styles","spacing","BAR_HEIGHTS","BarSkeleton","$","c","t0","Box","_temp","t1","_temp2","Skeleton","i_0","createBarDownloadConfig","args","rows","d"],"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 { createItemColorResolver } from '../utils/item-color'\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 // item's base colour 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. The base colour is the\n // datum's `color`, else the template's `itemStyle.color`, else the\n // series colour / palette (`params.color`).\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 makeDimItemStyle = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: (params) => params.color as string,\n })\n return {\n color: (params: CallbackDataParams) => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // 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: makeDimItemStyle(s, template),\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":";;;;;;;;;AAuCA,SAAgBoB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAIC,IAAU,GACVC,IAAU;CAEd,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;GACP,SAAS;GACT,iBAAiBA,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAASA,EAAM,QAAQ,CA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I,KAAGsB,EAAK,KAAK,CAAC,CAAC,GACvBA,EAAK,KAAK,CAAC,QAAQ,OAAO,CAAC;IAC3B,KAAK,IAAMC,KAAKpD,GAAQ,EAAK,KAAK,CAACoD,EAAE,MAAMA,EAAE,KAAK,CAAC;GACrD;GACA,OAAOD;EACT;CACF,CAAC,CACH;AACF"}
|
|
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","_c","ZOOM_LAYOUT","fixedAxisBounds","withPngItem","positionDataZoomForLegend","mergeOptions","resolveThemeColor","niceNum","buildLegendConfig","buildAxisLabelStyle","createTooltipFormatter","buildGridConfig","createTooltipPositioner","createItemColorResolver","echarts","barOptions","niceMin","niceMax","spacingPx","theme","buildBarTooltipFormatter","formatter","labelFormatter","v","extent","value","createBarOptionFactory","options","series","selection","selectionSet","option","structural","optionsOverride","seriesArr","data","hasLegend","baseLegend","baseGrid","baseTooltip","baseYAxis","fixedY","seriesTemplates","broadcastTemplate","liveFormatter","ctx","liveLabelFormatter","dataZoomLayout","fallbackBottom","baseBottom","gridBottom","makeDimItemStyle","baseColor","params","base","name","s","template","i","overrideColor","raw","item","formattedValue","marker","seriesName","styles","spacing","BAR_HEIGHTS","BarSkeleton","$","c","t0","Box","_temp","t1","_temp2","Skeleton","i_0","createBarDownloadConfig","args","buildCsvDownloadItem","rows","d"],"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 { spacingPx } from '../utils/spacing-px'\nimport { createItemColorResolver } from '../utils/item-color'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\nimport { fixedAxisBounds } from '../actions/relative-data/scale'\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: spacingPx(theme, 1),\n top: spacingPx(theme, 3),\n right: spacingPx(theme, 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: [spacingPx(theme, 1), spacingPx(theme, 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: [spacingPx(theme, 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: spacingPx(theme, 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 const fixedY = fixedAxisBounds(baseYAxis)\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 // item's base colour 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. The base colour is the\n // datum's `color`, else the template's `itemStyle.color`, else the\n // series colour / palette (`params.color`).\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 makeDimItemStyle = (datums: readonly object[], template: unknown) => {\n const baseColor = createItemColorResolver({\n theme,\n datums,\n template,\n fallback: (params) => params.color as string,\n })\n return {\n color: (params: CallbackDataParams) => {\n const base = baseColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((s, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // 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: makeDimItemStyle(s, template),\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 // A config transform (RelativeData's `'total'` scale) may pin the\n // ends; each applies only on the side the data reaches.\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? (fixedY.min ?? niceNum(extent.min)) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : (fixedY.max ?? 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":";;;;;;;;;;AAyCA,SAAgBoB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAIC,IAAU,GACVC,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAMC,EAAUC,GAAO,CAAC;GACxB,KAAKD,EAAUC,GAAO,CAAC;GACvB,OAAOD,EAAUC,GAAO,CA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,UAAUD,EAAK;EACf,UAAU,MAAQ;GAChB,IAAM5C,IAAO4C,EAAK,QAAQlC,CAAG,GACvBoC,IAAoB,CAAC;GAC3B,KAAK,IAAM,CAACvB,GAAG9B,MAAWO,EAAK,QAAQ,GAAG;IAExC,AADIuB,IAAI,KAAGuB,EAAK,KAAK,CAAC,CAAC,GACvBA,EAAK,KAAK,CAAC,QAAQ,OAAO,CAAC;IAC3B,KAAK,IAAMC,KAAKtD,GAAQ,EAAK,KAAK,CAACsD,EAAE,MAAMA,EAAE,KAAK,CAAC;GACrD;GACA,OAAOD;EACT;CACF,CAAC,CACH;AACF"}
|
package/dist/widgets/category.js
CHANGED
|
@@ -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-
|
|
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-UIGvFN3D.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 };
|
package/dist/widgets/formula.js
CHANGED
|
@@ -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-
|
|
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-CSHhAoyW.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,22 +1,23 @@
|
|
|
1
|
-
import { r as e } from "../zoom-toggle-
|
|
2
|
-
import { n as t
|
|
3
|
-
import { n
|
|
4
|
-
import {
|
|
5
|
-
import { c as p } from "
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import { r as e } from "../zoom-toggle-DqrV_0Ji.js";
|
|
2
|
+
import { n as t } from "../scale-Bhx8HKEB.js";
|
|
3
|
+
import { n, t as r } from "../download-DIj1Iz0t.js";
|
|
4
|
+
import { n as i, r as a, t as o } from "../utils-Dw4y8tiq.js";
|
|
5
|
+
import { c as s, i as c, l, n as u, o as d, r as f, s as p, t as m } from "../item-color-7o7pFBR2.js";
|
|
6
|
+
import { c as h } from "react/compiler-runtime";
|
|
7
|
+
import { Box as g, Skeleton as _ } from "@mui/material";
|
|
8
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
9
|
+
import * as b from "echarts";
|
|
9
10
|
//#region src/widgets/histogram/bins.ts
|
|
10
|
-
function
|
|
11
|
+
function x(e) {
|
|
11
12
|
return typeof e == "number" ? e : e.value;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function S(e) {
|
|
14
15
|
if (typeof e == "number") return Number.isFinite(e);
|
|
15
16
|
if (typeof e != "object" || !e) return !1;
|
|
16
17
|
let t = e.value;
|
|
17
18
|
return typeof t == "number" && Number.isFinite(t);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function C(e, t) {
|
|
20
21
|
return typeof e == "number" ? t : {
|
|
21
22
|
...e,
|
|
22
23
|
value: t
|
|
@@ -24,31 +25,31 @@ function x(e, t) {
|
|
|
24
25
|
}
|
|
25
26
|
//#endregion
|
|
26
27
|
//#region src/widgets/histogram/options.ts
|
|
27
|
-
function
|
|
28
|
+
function w({ theme: e, formatter: t }) {
|
|
28
29
|
let n = 0, r = 1;
|
|
29
30
|
return {
|
|
30
31
|
grid: {
|
|
31
|
-
left:
|
|
32
|
-
top:
|
|
33
|
-
right:
|
|
34
|
-
...
|
|
32
|
+
left: l(e, 1),
|
|
33
|
+
top: l(e, 3),
|
|
34
|
+
right: l(e, 1),
|
|
35
|
+
...f(!1, e),
|
|
35
36
|
containLabel: !0
|
|
36
37
|
},
|
|
37
38
|
tooltip: {
|
|
38
39
|
trigger: "axis",
|
|
39
40
|
backgroundColor: e.palette.grey[900],
|
|
40
41
|
borderWidth: 0,
|
|
41
|
-
padding: [
|
|
42
|
+
padding: [l(e, 1), l(e, 1)],
|
|
42
43
|
textStyle: {
|
|
43
44
|
color: e.palette.common.white,
|
|
44
45
|
fontSize: 11,
|
|
45
46
|
fontFamily: e.typography.caption.fontFamily
|
|
46
47
|
},
|
|
47
48
|
axisPointer: { type: "line" },
|
|
48
|
-
position:
|
|
49
|
-
formatter:
|
|
49
|
+
position: p(e),
|
|
50
|
+
formatter: E(t)
|
|
50
51
|
},
|
|
51
|
-
legend: { ...
|
|
52
|
+
legend: { ...c({ hasLegend: !1 }) },
|
|
52
53
|
axisPointer: { lineStyle: { color: e.palette.grey[400] } },
|
|
53
54
|
color: [e.palette.secondary.main, ...Object.values(e.palette.qualitative?.bold ?? {})],
|
|
54
55
|
xAxis: {
|
|
@@ -56,9 +57,9 @@ function S({ theme: e, formatter: t }) {
|
|
|
56
57
|
axisLine: { show: !1 },
|
|
57
58
|
axisTick: { show: !1 },
|
|
58
59
|
axisLabel: {
|
|
59
|
-
...
|
|
60
|
+
...u(e),
|
|
60
61
|
padding: [
|
|
61
|
-
|
|
62
|
+
l(e, .5),
|
|
62
63
|
0,
|
|
63
64
|
0,
|
|
64
65
|
0
|
|
@@ -70,8 +71,8 @@ function S({ theme: e, formatter: t }) {
|
|
|
70
71
|
},
|
|
71
72
|
yAxis: {
|
|
72
73
|
type: "value",
|
|
73
|
-
min: (e) => (n = e.min < 0 ?
|
|
74
|
-
max: (e) => (r = e.max <= 0 ? 1 :
|
|
74
|
+
min: (e) => (n = e.min < 0 ? s(e.min) : 0, n),
|
|
75
|
+
max: (e) => (r = e.max <= 0 ? 1 : s(e.max), r),
|
|
75
76
|
axisLine: { show: !1 },
|
|
76
77
|
axisTick: { show: !1 },
|
|
77
78
|
splitLine: {
|
|
@@ -79,8 +80,8 @@ function S({ theme: e, formatter: t }) {
|
|
|
79
80
|
lineStyle: { color: e.palette.black?.[4] ?? e.palette.divider }
|
|
80
81
|
},
|
|
81
82
|
axisLabel: {
|
|
82
|
-
...
|
|
83
|
-
margin:
|
|
83
|
+
...u(e),
|
|
84
|
+
margin: l(e, 1),
|
|
84
85
|
show: !0,
|
|
85
86
|
showMaxLabel: !0,
|
|
86
87
|
showMinLabel: !0,
|
|
@@ -91,105 +92,105 @@ function S({ theme: e, formatter: t }) {
|
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
-
let { theme:
|
|
96
|
-
for (let e = 0; e <
|
|
97
|
-
let t =
|
|
98
|
-
|
|
95
|
+
function T(n) {
|
|
96
|
+
let { theme: r, formatter: c, ticks: l, series: u, labelFormatter: d, selection: f } = n, p = n.optionsOverride, h = n.lockedItems, g = f && f.length > 0 ? new Set(f) : null, _ = [];
|
|
97
|
+
for (let e = 0; e < l.length - 1; e++) {
|
|
98
|
+
let t = l[e], n = l[e + 1], r = `${D(t)}–${D(n)}`;
|
|
99
|
+
_.push(d ? d(r) : r);
|
|
99
100
|
}
|
|
100
|
-
let
|
|
101
|
-
let e =
|
|
101
|
+
let v = h && h.length > 0 ? (() => {
|
|
102
|
+
let e = h.map(Number), t = _[Math.min(...e)], n = _[Math.max(...e)];
|
|
102
103
|
return t != null && n != null ? {
|
|
103
104
|
min: t,
|
|
104
105
|
max: n
|
|
105
106
|
} : null;
|
|
106
107
|
})() : null;
|
|
107
|
-
return (
|
|
108
|
-
if (
|
|
109
|
-
let e =
|
|
110
|
-
theme:
|
|
111
|
-
formatter:
|
|
108
|
+
return (n, l, d) => {
|
|
109
|
+
if (n == null) {
|
|
110
|
+
let e = w({
|
|
111
|
+
theme: r,
|
|
112
|
+
formatter: c
|
|
112
113
|
});
|
|
113
|
-
return p ?
|
|
114
|
+
return p ? a(e, p) : e;
|
|
114
115
|
}
|
|
115
|
-
let
|
|
116
|
-
if (
|
|
117
|
-
...
|
|
116
|
+
let f = Array.isArray(l) ? l : [];
|
|
117
|
+
if (f.length === 0 || _.length === 0) return {
|
|
118
|
+
...n,
|
|
118
119
|
dataset: [],
|
|
119
120
|
series: []
|
|
120
121
|
};
|
|
121
|
-
let
|
|
122
|
-
let
|
|
123
|
-
theme:
|
|
122
|
+
let h = f.length > 1, y = Array.isArray(n.series) ? n.series : [], S = y[0] ?? {}, C = typeof n.yAxis == "object" && !Array.isArray(n.yAxis) ? n.yAxis : {}, T = t(C), D = typeof n.grid == "object" && !Array.isArray(n.grid) ? n.grid : {}, O = typeof n.tooltip == "object" && !Array.isArray(n.tooltip) ? n.tooltip : {}, k = typeof n.legend == "object" && !Array.isArray(n.legend) ? n.legend : {}, A = d?.formatter, j = 0, M = 1, N = i(n.dataZoom, h), P = typeof D.bottom == "number" ? D.bottom : 24, F = h ? 56 : P, I = N ? F + e.sliderHeight + e.sliderGap : F, L = (e, t) => {
|
|
123
|
+
let n = m({
|
|
124
|
+
theme: r,
|
|
124
125
|
datums: e,
|
|
125
126
|
template: t,
|
|
126
127
|
fallback: (e) => e.color
|
|
127
128
|
});
|
|
128
129
|
return { color: (e) => {
|
|
129
|
-
let t =
|
|
130
|
-
return
|
|
130
|
+
let t = n(e);
|
|
131
|
+
return g ? g.has(e.dataIndex) ? t : b.color.modifyAlpha(t, .15) : t;
|
|
131
132
|
} };
|
|
132
|
-
},
|
|
133
|
-
min:
|
|
134
|
-
max:
|
|
135
|
-
},
|
|
136
|
-
...
|
|
137
|
-
...
|
|
138
|
-
}, ...
|
|
139
|
-
...typeof
|
|
140
|
-
...
|
|
133
|
+
}, R = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, z = {
|
|
134
|
+
min: v?.min ?? R?.min ?? null,
|
|
135
|
+
max: v?.max ?? R?.max ?? null
|
|
136
|
+
}, B = Array.isArray(n.xAxis) ? [{
|
|
137
|
+
...n.xAxis[0],
|
|
138
|
+
...z
|
|
139
|
+
}, ...n.xAxis.slice(1)] : {
|
|
140
|
+
...typeof n.xAxis == "object" ? n.xAxis : {},
|
|
141
|
+
...z
|
|
141
142
|
};
|
|
142
143
|
return {
|
|
143
|
-
...
|
|
144
|
-
xAxis:
|
|
145
|
-
dataset:
|
|
144
|
+
...n,
|
|
145
|
+
xAxis: B,
|
|
146
|
+
dataset: f.map((e) => ({ source: _.map((t, n) => {
|
|
146
147
|
let r = e[n];
|
|
147
|
-
return [t, r == null ? 0 :
|
|
148
|
+
return [t, r == null ? 0 : x(r)];
|
|
148
149
|
}) })),
|
|
149
|
-
series:
|
|
150
|
-
let
|
|
150
|
+
series: f.map((e, t) => {
|
|
151
|
+
let n = y[t] ?? S, i = o(r, u?.[t]?.color);
|
|
151
152
|
return {
|
|
152
|
-
...typeof
|
|
153
|
+
...typeof n == "object" ? n : {},
|
|
153
154
|
type: "bar",
|
|
154
155
|
datasetIndex: t,
|
|
155
|
-
name:
|
|
156
|
+
name: u?.[t]?.name ?? `Series ${t + 1}`,
|
|
156
157
|
encode: {
|
|
157
158
|
x: 0,
|
|
158
159
|
y: 1
|
|
159
160
|
},
|
|
160
161
|
barCategoryGap: "0%",
|
|
161
162
|
emphasis: { focus: "series" },
|
|
162
|
-
itemStyle:
|
|
163
|
+
itemStyle: L(e, n),
|
|
163
164
|
...i ? { color: i } : {}
|
|
164
165
|
};
|
|
165
166
|
}),
|
|
166
167
|
legend: {
|
|
167
|
-
...
|
|
168
|
-
show:
|
|
168
|
+
...k,
|
|
169
|
+
show: h
|
|
169
170
|
},
|
|
170
171
|
grid: {
|
|
171
|
-
...
|
|
172
|
-
bottom:
|
|
172
|
+
...D,
|
|
173
|
+
bottom: I
|
|
173
174
|
},
|
|
174
|
-
...
|
|
175
|
+
...N ? { dataZoom: N } : {},
|
|
175
176
|
yAxis: {
|
|
176
177
|
...C,
|
|
177
|
-
min: (e) => (
|
|
178
|
-
max: (e) => (
|
|
178
|
+
min: (e) => (j = e.min < 0 ? T.min ?? s(e.min) : 0, j),
|
|
179
|
+
max: (e) => (M = e.max <= 0 ? 1 : T.max ?? s(e.max), M),
|
|
179
180
|
axisLabel: {
|
|
180
181
|
...C.axisLabel ?? {},
|
|
181
|
-
formatter: (e) => e !==
|
|
182
|
+
formatter: (e) => e !== M && e !== j || e === 0 ? "" : A ? A(e) : String(e)
|
|
182
183
|
}
|
|
183
184
|
},
|
|
184
185
|
tooltip: {
|
|
185
|
-
...
|
|
186
|
-
formatter:
|
|
186
|
+
...O,
|
|
187
|
+
formatter: E(A)
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
192
|
+
function E(e) {
|
|
193
|
+
return d((t) => {
|
|
193
194
|
let n = t.value?.[1], r = typeof n == "number" && e ? e(n) : n ?? "", i = typeof t.marker == "string" ? t.marker : "", a = t.seriesName ? `${t.seriesName}: ` : "";
|
|
194
195
|
return {
|
|
195
196
|
name: String(t.name ?? ""),
|
|
@@ -199,12 +200,12 @@ function w(e) {
|
|
|
199
200
|
};
|
|
200
201
|
});
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function D(e) {
|
|
203
204
|
return Number.isInteger(e) ? String(e) : Number(e.toFixed(2)).toString();
|
|
204
205
|
}
|
|
205
206
|
//#endregion
|
|
206
207
|
//#region src/widgets/histogram/skeleton.tsx
|
|
207
|
-
var
|
|
208
|
+
var O = {
|
|
208
209
|
container: {
|
|
209
210
|
display: "flex",
|
|
210
211
|
alignItems: "center",
|
|
@@ -231,59 +232,59 @@ var E = {
|
|
|
231
232
|
alignItems: "center",
|
|
232
233
|
gap: ({ spacing: e }) => e(1.5)
|
|
233
234
|
}
|
|
234
|
-
},
|
|
235
|
+
}, k = (e) => ({
|
|
235
236
|
flex: 1,
|
|
236
237
|
height: `${e}%`,
|
|
237
238
|
minWidth: 8
|
|
238
239
|
});
|
|
239
|
-
function
|
|
240
|
-
let t =
|
|
240
|
+
function A(e) {
|
|
241
|
+
let t = h(15), { bins: n } = e, r = n === void 0 ? 12 : n, i, a, o, s, c;
|
|
241
242
|
if (t[0] !== r) {
|
|
242
243
|
let e = Array.from({ length: r }, (e, t) => {
|
|
243
244
|
let n = t / Math.max(1, r - 1);
|
|
244
245
|
return Math.round(20 + 80 * Math.exp(-((n - .5) ** 2) * 8));
|
|
245
246
|
});
|
|
246
|
-
a =
|
|
247
|
+
a = g, c = O.container, i = g, o = O.grid, s = e.map(M), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
|
|
247
248
|
} else i = t[1], a = t[2], o = t[3], s = t[4], c = t[5];
|
|
248
249
|
let l;
|
|
249
|
-
t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */
|
|
250
|
+
t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ v(i, {
|
|
250
251
|
sx: o,
|
|
251
252
|
children: s
|
|
252
253
|
}), t[6] = i, t[7] = o, t[8] = s, t[9] = l) : l = t[9];
|
|
253
254
|
let u;
|
|
254
|
-
t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ g
|
|
255
|
-
sx:
|
|
256
|
-
children: [0, 1].map(
|
|
255
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ v(g, {
|
|
256
|
+
sx: O.legend,
|
|
257
|
+
children: [0, 1].map(j)
|
|
257
258
|
}), t[10] = u) : u = t[10];
|
|
258
259
|
let d;
|
|
259
|
-
return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */
|
|
260
|
+
return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */ y(a, {
|
|
260
261
|
sx: c,
|
|
261
262
|
children: [l, u]
|
|
262
263
|
}), t[11] = a, t[12] = c, t[13] = l, t[14] = d) : d = t[14], d;
|
|
263
264
|
}
|
|
264
|
-
function
|
|
265
|
-
return /* @__PURE__ */
|
|
266
|
-
sx:
|
|
267
|
-
children: [/* @__PURE__ */
|
|
265
|
+
function j(e) {
|
|
266
|
+
return /* @__PURE__ */ y(g, {
|
|
267
|
+
sx: O.legendItem,
|
|
268
|
+
children: [/* @__PURE__ */ v(_, {
|
|
268
269
|
variant: "circular",
|
|
269
270
|
width: 8,
|
|
270
271
|
height: 8
|
|
271
|
-
}), /* @__PURE__ */
|
|
272
|
+
}), /* @__PURE__ */ v(_, {
|
|
272
273
|
width: 48,
|
|
273
274
|
height: 8
|
|
274
275
|
})]
|
|
275
276
|
}, `legend-${e}`);
|
|
276
277
|
}
|
|
277
|
-
function
|
|
278
|
-
return /* @__PURE__ */
|
|
278
|
+
function M(e, t) {
|
|
279
|
+
return /* @__PURE__ */ v(_, {
|
|
279
280
|
variant: "rectangular",
|
|
280
|
-
sx:
|
|
281
|
+
sx: k(e)
|
|
281
282
|
}, `bar-${t}`);
|
|
282
283
|
}
|
|
283
284
|
//#endregion
|
|
284
285
|
//#region src/widgets/histogram/download.ts
|
|
285
|
-
function
|
|
286
|
-
return
|
|
286
|
+
function N(e) {
|
|
287
|
+
return r(e, n({
|
|
287
288
|
filename: e.filename,
|
|
288
289
|
getRows: (t) => {
|
|
289
290
|
let n = e.getData(t), r = e.getTicks(), i = n.length, a = ["bin_low", "bin_high"];
|
|
@@ -293,7 +294,7 @@ function j(e) {
|
|
|
293
294
|
let t = [r[e], r[e + 1]];
|
|
294
295
|
for (let r = 0; r < i; r++) {
|
|
295
296
|
let i = n[r]?.[e];
|
|
296
|
-
t.push(i == null ? 0 :
|
|
297
|
+
t.push(i == null ? 0 : x(i));
|
|
297
298
|
}
|
|
298
299
|
o.push(t);
|
|
299
300
|
}
|
|
@@ -303,20 +304,20 @@ function j(e) {
|
|
|
303
304
|
}
|
|
304
305
|
//#endregion
|
|
305
306
|
//#region src/widgets/histogram/transforms.ts
|
|
306
|
-
var
|
|
307
|
-
if (!
|
|
308
|
-
let t = e.reduce((e, t) => e + Math.abs(
|
|
309
|
-
return t <= 0 ? e : e.map((e) =>
|
|
307
|
+
var P = (e) => Array.isArray(e) ? e.map((e) => {
|
|
308
|
+
if (!F(e)) return e;
|
|
309
|
+
let t = e.reduce((e, t) => e + Math.abs(x(t)), 0);
|
|
310
|
+
return t <= 0 ? e : e.map((e) => C(e, x(e) / t * 100));
|
|
310
311
|
}) : e;
|
|
311
|
-
function
|
|
312
|
-
return Array.isArray(e) && e.every(
|
|
312
|
+
function F(e) {
|
|
313
|
+
return Array.isArray(e) && e.every(S);
|
|
313
314
|
}
|
|
314
|
-
function
|
|
315
|
+
function I(e, t) {
|
|
315
316
|
if (t.length === 0 || !Array.isArray(e)) return e;
|
|
316
317
|
let n = new Set(t.map(Number));
|
|
317
|
-
return e.map((e) =>
|
|
318
|
+
return e.map((e) => F(e) ? e.map((e, t) => n.has(t) ? e : C(e, 0)) : e);
|
|
318
319
|
}
|
|
319
320
|
//#endregion
|
|
320
|
-
export {
|
|
321
|
+
export { A as HistogramSkeleton, N as createHistogramDownloadConfig, T as createHistogramOptionFactory, I as filterHistogramByLockedBins, x as getHistogramBinValue, w as histogramOptions, P as toRelativeHistogramData };
|
|
321
322
|
|
|
322
323
|
//# sourceMappingURL=histogram.js.map
|