@carto/ps-react-ui 5.4.0 → 5.6.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-5-dVhroJ.js +1289 -0
- package/dist/actions-5-dVhroJ.js.map +1 -0
- package/dist/{category-C6myUFUJ.js → category-DBUD2ZBo.js} +267 -250
- package/dist/category-DBUD2ZBo.js.map +1 -0
- package/dist/item-color-ZYxH3NM5.js +20 -0
- package/dist/item-color-ZYxH3NM5.js.map +1 -0
- package/dist/scale-0elCv3tk.js +29 -0
- package/dist/scale-0elCv3tk.js.map +1 -0
- package/dist/types/widgets-v2/actions/index.d.ts +1 -1
- package/dist/types/widgets-v2/actions/relative-data/index.d.ts +1 -0
- package/dist/types/widgets-v2/actions/relative-data/labels.d.ts +3 -0
- package/dist/types/widgets-v2/actions/relative-data/relative-data.d.ts +16 -2
- package/dist/types/widgets-v2/actions/relative-data/scale.d.ts +26 -0
- package/dist/types/widgets-v2/actions/relative-data/style.d.ts +12 -0
- package/dist/types/widgets-v2/bar/types.d.ts +6 -0
- package/dist/types/widgets-v2/category/category.d.ts +2 -1
- package/dist/types/widgets-v2/histogram/bins.d.ts +7 -0
- package/dist/types/widgets-v2/histogram/download.d.ts +2 -2
- package/dist/types/widgets-v2/histogram/index.d.ts +2 -1
- package/dist/types/widgets-v2/histogram/options.d.ts +1 -1
- package/dist/types/widgets-v2/histogram/transforms.d.ts +5 -4
- package/dist/types/widgets-v2/histogram/types.d.ts +22 -5
- package/dist/types/widgets-v2/index.d.ts +2 -2
- package/dist/types/widgets-v2/pie/types.d.ts +6 -0
- package/dist/types/widgets-v2/scatterplot/download.d.ts +2 -2
- package/dist/types/widgets-v2/scatterplot/index.d.ts +2 -1
- package/dist/types/widgets-v2/scatterplot/points.d.ts +7 -0
- package/dist/types/widgets-v2/scatterplot/transforms.d.ts +4 -3
- package/dist/types/widgets-v2/scatterplot/types.d.ts +21 -2
- package/dist/types/widgets-v2/timeseries/types.d.ts +6 -0
- package/dist/types/widgets-v2/utils/item-color.d.ts +26 -0
- package/dist/widgets-v2/actions.js +1 -1
- package/dist/widgets-v2/bar.js +91 -81
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +1 -1
- package/dist/widgets-v2/histogram.js +133 -100
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/pie.js +98 -78
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +151 -110
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +96 -86
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2.js +2 -2
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +1 -1
- package/src/widgets-v2/actions/fullscreen/fullscreen-store.test.tsx +77 -13
- package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +48 -5
- package/src/widgets-v2/actions/index.ts +1 -0
- package/src/widgets-v2/actions/relative-data/index.ts +1 -0
- package/src/widgets-v2/actions/relative-data/labels.ts +6 -0
- package/src/widgets-v2/actions/relative-data/relative-data.test.tsx +78 -1
- package/src/widgets-v2/actions/relative-data/relative-data.tsx +137 -20
- package/src/widgets-v2/actions/relative-data/scale.ts +48 -0
- package/src/widgets-v2/actions/relative-data/style.ts +10 -0
- package/src/widgets-v2/bar/options.test.ts +122 -0
- package/src/widgets-v2/bar/options.ts +31 -16
- package/src/widgets-v2/bar/types.ts +6 -0
- package/src/widgets-v2/category/category.relative-data.test.tsx +51 -63
- package/src/widgets-v2/category/category.tsx +25 -11
- package/src/widgets-v2/histogram/bins.ts +22 -0
- package/src/widgets-v2/histogram/download.test.ts +10 -0
- package/src/widgets-v2/histogram/download.ts +7 -3
- package/src/widgets-v2/histogram/index.ts +3 -0
- package/src/widgets-v2/histogram/options.test.ts +62 -0
- package/src/widgets-v2/histogram/options.ts +44 -19
- package/src/widgets-v2/histogram/transforms.test.ts +21 -7
- package/src/widgets-v2/histogram/transforms.ts +26 -12
- package/src/widgets-v2/histogram/types.ts +25 -5
- package/src/widgets-v2/index.ts +7 -1
- package/src/widgets-v2/pie/options.test.ts +91 -0
- package/src/widgets-v2/pie/options.ts +50 -20
- package/src/widgets-v2/pie/types.ts +6 -0
- package/src/widgets-v2/scatterplot/download.test.ts +9 -0
- package/src/widgets-v2/scatterplot/download.ts +5 -3
- package/src/widgets-v2/scatterplot/index.ts +3 -0
- package/src/widgets-v2/scatterplot/options.test.ts +90 -0
- package/src/widgets-v2/scatterplot/options.ts +53 -15
- package/src/widgets-v2/scatterplot/points.ts +35 -0
- package/src/widgets-v2/scatterplot/transforms.test.ts +19 -0
- package/src/widgets-v2/scatterplot/transforms.ts +23 -18
- package/src/widgets-v2/scatterplot/types.ts +25 -2
- package/src/widgets-v2/timeseries/options.test.ts +65 -0
- package/src/widgets-v2/timeseries/options.ts +37 -16
- package/src/widgets-v2/timeseries/types.ts +6 -0
- package/src/widgets-v2/utils/item-color.test.ts +74 -0
- package/src/widgets-v2/utils/item-color.ts +55 -0
- package/dist/actions-Dhlz_adK.js +0 -1167
- package/dist/actions-Dhlz_adK.js.map +0 -1
- package/dist/category-C6myUFUJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.js","names":["<Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>","(height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>","(i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n )","i"],"sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/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 '../../widgets/utils/chart-config'\nimport { ZOOM_LAYOUT } from '../actions/zoom-toggle'\nimport type { OptionFactory } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport { positionDataZoomForLegend } from '../utils/data-zoom-layout'\nimport type {\n BarEChartsOption,\n BarOptionFactoryInput,\n BarOptionsInput,\n BarWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a bar widget — axes, grid,\n * tooltip styling, themed legend. Intentionally data-agnostic: no series,\n * no dataset, no `legend.show` (those depend on data and are added by the\n * option factory's merge phase). This separation is what lets data-side\n * pipeline transforms (Searcher, RelativeData) drive the rendered chart —\n * the merge happens at render time inside the Echart bridge.\n *\n * Styling matches the v1 `barConfig` look-and-feel: minimal axes (only\n * min/max y-labels rendered inside the plot via `niceNum`), themed tooltip,\n * scroll legend, and CARTO color palette. The y-axis min/max + label\n * formatter and the tooltip formatter are wired here for the no-data case;\n * {@link createBarOptionFactory} re-derives them at fusion time so reactive\n * formatter changes (RelativeData) and stack templates (StackToggle) flow\n * through to the chart.\n */\nexport function barOptions({\n theme,\n formatter,\n labelFormatter,\n}: BarOptionsInput): BarEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildBarTooltipFormatter(formatter, labelFormatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count.\n legend: {\n ...buildLegendConfig({ hasLegend: false, labelFormatter }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n // `interval: 0` makes every category label a candidate so `hideOverlap`\n // can pack the maximum number that physically fit; the category-axis\n // default (`'auto'`) sub-samples first and shows fewer than fit.\n interval: 0,\n hideOverlap: true,\n ...(labelFormatter && {\n formatter: (v: string | number) => String(labelFormatter(v)),\n }),\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n ...buildAxisLabelStyle(theme),\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as BarEChartsOption\n}\n\n/**\n * Returns the bar widget's {@link OptionFactory} — a single closure that\n * handles BOTH option-construction phases:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link barOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store; configTransforms (StackToggle /\n * ZoomToggle / BrushToggle) then mutate it via the pipeline middleware.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`BarWidgetData`) into the option via the dataset API: one dataset\n * per series, each series referencing its dataset by index, encoded\n * by `name` (x) and `value` (y). Spreads any series-template fields\n * already on the incoming option (e.g. `{ stack: 'total' }` from\n * `addStack`) into every emitted series so configTransforms compose\n * end-to-end. Reactive `ctx.formatter` / `ctx.labelFormatter` drive\n * the y-axis min/max-only label and the tooltip formatter at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n *\n * Stable identity when the inputs don't change (consumers should wrap the\n * call in `useMemo` keyed on the same inputs).\n */\nexport function createBarOptionFactory(\n options: BarOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride } = options\n const series = options.series\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n // Structural phase: Provider seeds rawOptions with this branch. No data\n // is read; we just emit the theme-aware base (optionally with override).\n if (option == null) {\n const structural = barOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as BarWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n const hasLegend = seriesArr.length > 1\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n\n // Reactive (live store) formatters from ctx — distinct from the\n // closure-time `formatter` / `labelFormatter` captured for the\n // structural-build branch above. RelativeData can install a percent\n // formatter on the store after the factory was constructed; the merge\n // phase reads `ctx` to pick that up.\n const liveFormatter = ctx?.formatter\n const liveLabelFormatter = ctx?.labelFormatter\n\n // Closure shared between the yAxis min/max callbacks and the label\n // formatter, so only the rounded extents are labelled (matches v1).\n // Delegating the extent to ECharts (rather than precomputing scalars\n // from the raw data) is what keeps stacked bars inside the plot: when\n // StackToggle marks the series, ECharts feeds the *post-stack* extent\n // to these callbacks, so `niceNum` rounds the stacked total instead of\n // a single series.\n let niceMin = 0\n let niceMax = 1\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push the\n // slider above the legend (if any) and reserve room in the grid below.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // When a selection is active, dim non-selected bars by routing the\n // resolved palette color through `modifyAlpha`. Per-row `itemStyle` on\n // dataset object-rows is silently ignored when `series.encode` is in\n // play — the callback approach is the standard ECharts pattern for\n // per-data styling derived from a dataset.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bars would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n // Per-series `color` override: ECharts sets `params.color` from\n // `series[i].color` when resolving styles, so the dim callback\n // above keeps working — it just dims the user's colour rather\n // than the palette default.\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 'name', y: 'value' },\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: {\n ...baseGrid,\n bottom: gridBottom,\n },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildBarTooltipFormatter(liveFormatter, liveLabelFormatter),\n },\n } as EChartsOption\n }\n}\n\nfunction buildBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as { name?: string | number; value?: number }\n const raw = row?.value\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : (item.name ?? '')\n return { name: String(name), seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: '1 1 auto',\n alignItems: 'flex-end',\n width: '100%',\n },\n bar: {\n flex: 1,\n maxWidth: ({ spacing }) => spacing(12),\n '& + &': {\n marginLeft: ({ spacing }) => spacing(1),\n },\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst BAR_HEIGHTS = ['20%', '40%', '60%', '20%', '80%'] as const\n\n/**\n * Loading state for the Bar widget. Mirrors a bar chart's silhouette — five\n * vertical bars at staggered heights anchored to the bottom, plus a legend\n * stub — so the skeleton reads as \"a bar chart\" rather than a generic list.\n */\nexport function BarSkeleton() {\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildCsvDownloadItem,\n buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: (ctx: DownloadContext) => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (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 return items\n}\n"],"mappings":";;;;;;;;;AAsCA,SAAgB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,Q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AC,QAAQ,OAAO,CAAC;IAC3B,KAAK,IAAM,KAAK,GAAQ,EAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;GACrD;GACA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT"}
|
|
1
|
+
{"version":3,"file":"bar.js","names":["<Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>","(height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n )","<Box sx={styles.container}>\n <Box sx={styles.grid}>\n {BAR_HEIGHTS.map((height, i) => (\n <Skeleton\n key={`bar-${i}`}\n sx={styles.bar}\n variant='rectangular'\n height={height}\n />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>","(i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n )","i"],"sources":["../../src/widgets-v2/bar/options.ts","../../src/widgets-v2/bar/skeleton.tsx","../../src/widgets-v2/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 '../../widgets/utils/chart-config'\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'\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: 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 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 buildPngDownloadItem,\n type DownloadContext,\n type DownloadItem,\n} from '../actions/download'\nimport type { BarWidgetData } from './types'\n\nexport interface BarDownloadConfigArgs {\n filename: string\n getData: (ctx: DownloadContext) => BarWidgetData\n /**\n * Optional getter for the widget's capture element (registered by\n * `Widget.State` on its success path). When provided, a PNG item is\n * prepended to the returned list. Wire it to\n * `() => getCaptureEl(id)`.\n */\n getCaptureEl?: (ctx: DownloadContext) => HTMLElement | null\n /** PNG `pixelRatio` (default 2). */\n pngPixelRatio?: number\n /** PNG `backgroundColor` (default transparent). */\n pngBackgroundColor?: string | null\n}\n\n/**\n * Builds download items for the Bar widget. Always includes a CSV item\n * with one `name,value` block per series, separated by an empty row when\n * there are multiple. When `getCaptureEl` is supplied, also prepends a PNG\n * item that rasterises the captured element via `html2canvas`.\n */\nexport function createBarDownloadConfig(\n args: BarDownloadConfigArgs,\n): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push(\n buildCsvDownloadItem({\n filename: args.filename,\n getRows: (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 return items\n}\n"],"mappings":";;;;;;;;;;;AAwCA,SAAgB,EAAW,EACzB,UACA,cACA,qBACoC;CAGpC,IAAI,IAAU,GACV,IAAU;CAEd,OAAO;EACL,MAAM;GACJ,MAAM,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC/B,KAAK,SAAS,EAAM,QAAQ,CAAC,CAAC;GAC9B,OAAO,SAAS,EAAM,QAAQ,CAAC,CAAC;GAEhC,GAAG,EAAgB,IAAO,CAAK;GAC/B,cAAc;EAChB;EACA,SAAS;GACP,SAAS;GACT,iBAAiB,EAAM,QAAQ,KAAK;GACpC,aAAa;GACb,SAAS,CAAC,SAAS,EAAM,QAAQ,CAAC,CAAC,GAAG,S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AAK,CAAC;GACrD;GACA,OAAO;EACT;CACF,CAAC,CACH,GACO;AACT"}
|
|
@@ -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-DBUD2ZBo.js";
|
|
2
2
|
export { o as Category, r as CategoryBar, e as CategoryLegend, s as CategoryRowMulti, a as CategoryRowOther, t as CategoryRowSingle, i as CategorySkeleton, n as CategoryUI, c as createCategoryDownloadConfig };
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { r as e } from "../zoom-toggle-IsF8BnAp.js";
|
|
2
|
-
import { n as t
|
|
3
|
-
import { n
|
|
4
|
-
import {
|
|
5
|
-
import { c as f } from "
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
2
|
+
import { n as t } from "../scale-0elCv3tk.js";
|
|
3
|
+
import { n, t as r } from "../download-DGgFOaXj.js";
|
|
4
|
+
import { n as i, r as a, t as o } from "../utils-Dr6gf3vD.js";
|
|
5
|
+
import { a as s, d as c, f as l, i as u, s as d, u as f } from "../chart-config-B_fdIcD3.js";
|
|
6
|
+
import { t as p } from "../item-color-ZYxH3NM5.js";
|
|
7
|
+
import { c as m } from "react/compiler-runtime";
|
|
8
|
+
import { Box as h, Skeleton as g } from "@mui/material";
|
|
9
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
10
|
+
import * as y from "echarts";
|
|
11
|
+
//#region src/widgets-v2/histogram/bins.ts
|
|
12
|
+
function b(e) {
|
|
13
|
+
return typeof e == "number" ? e : e.value;
|
|
14
|
+
}
|
|
15
|
+
function x(e) {
|
|
16
|
+
if (typeof e == "number") return Number.isFinite(e);
|
|
17
|
+
if (typeof e != "object" || !e) return !1;
|
|
18
|
+
let t = e.value;
|
|
19
|
+
return typeof t == "number" && Number.isFinite(t);
|
|
20
|
+
}
|
|
21
|
+
function S(e, t) {
|
|
22
|
+
return typeof e == "number" ? t : {
|
|
23
|
+
...e,
|
|
24
|
+
value: t
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
9
28
|
//#region src/widgets-v2/histogram/options.ts
|
|
10
|
-
function
|
|
29
|
+
function C({ theme: e, formatter: t }) {
|
|
11
30
|
let n = 0, r = 1;
|
|
12
31
|
return {
|
|
13
32
|
grid: {
|
|
14
33
|
left: parseInt(e.spacing(1)),
|
|
15
34
|
top: parseInt(e.spacing(3)),
|
|
16
35
|
right: parseInt(e.spacing(1)),
|
|
17
|
-
...
|
|
36
|
+
...s(!1, e),
|
|
18
37
|
containLabel: !0
|
|
19
38
|
},
|
|
20
39
|
tooltip: {
|
|
@@ -28,10 +47,10 @@ function v({ theme: e, formatter: t }) {
|
|
|
28
47
|
fontFamily: e.typography.caption.fontFamily
|
|
29
48
|
},
|
|
30
49
|
axisPointer: { type: "line" },
|
|
31
|
-
position:
|
|
32
|
-
formatter:
|
|
50
|
+
position: c(e),
|
|
51
|
+
formatter: T(t)
|
|
33
52
|
},
|
|
34
|
-
legend: { ...
|
|
53
|
+
legend: { ...d({ hasLegend: !1 }) },
|
|
35
54
|
axisPointer: { lineStyle: { color: e.palette.grey[400] } },
|
|
36
55
|
color: [e.palette.secondary.main, ...Object.values(e.palette.qualitative?.bold ?? {})],
|
|
37
56
|
xAxis: {
|
|
@@ -39,7 +58,7 @@ function v({ theme: e, formatter: t }) {
|
|
|
39
58
|
axisLine: { show: !1 },
|
|
40
59
|
axisTick: { show: !1 },
|
|
41
60
|
axisLabel: {
|
|
42
|
-
...
|
|
61
|
+
...u(e),
|
|
43
62
|
padding: [
|
|
44
63
|
parseInt(e.spacing(.5)),
|
|
45
64
|
0,
|
|
@@ -53,8 +72,8 @@ function v({ theme: e, formatter: t }) {
|
|
|
53
72
|
},
|
|
54
73
|
yAxis: {
|
|
55
74
|
type: "value",
|
|
56
|
-
min: (e) => (n = e.min < 0 ?
|
|
57
|
-
max: (e) => (r = e.max <= 0 ? 1 :
|
|
75
|
+
min: (e) => (n = e.min < 0 ? l(e.min) : 0, n),
|
|
76
|
+
max: (e) => (r = e.max <= 0 ? 1 : l(e.max), r),
|
|
58
77
|
axisLine: { show: !1 },
|
|
59
78
|
axisTick: { show: !1 },
|
|
60
79
|
splitLine: {
|
|
@@ -62,7 +81,7 @@ function v({ theme: e, formatter: t }) {
|
|
|
62
81
|
lineStyle: { color: e.palette.black?.[4] ?? e.palette.divider }
|
|
63
82
|
},
|
|
64
83
|
axisLabel: {
|
|
65
|
-
...
|
|
84
|
+
...u(e),
|
|
66
85
|
margin: parseInt(e.spacing(1)),
|
|
67
86
|
show: !0,
|
|
68
87
|
showMaxLabel: !0,
|
|
@@ -74,94 +93,105 @@ function v({ theme: e, formatter: t }) {
|
|
|
74
93
|
}
|
|
75
94
|
};
|
|
76
95
|
}
|
|
77
|
-
function
|
|
78
|
-
let { theme:
|
|
79
|
-
for (let e = 0; e <
|
|
80
|
-
let t =
|
|
81
|
-
|
|
96
|
+
function w(n) {
|
|
97
|
+
let { theme: r, formatter: s, ticks: c, series: u, labelFormatter: d, selection: f } = n, m = n.optionsOverride, h = n.lockedItems, g = f && f.length > 0 ? new Set(f) : null, _ = [];
|
|
98
|
+
for (let e = 0; e < c.length - 1; e++) {
|
|
99
|
+
let t = c[e], n = c[e + 1], r = `${E(t)}–${E(n)}`;
|
|
100
|
+
_.push(d ? d(r) : r);
|
|
82
101
|
}
|
|
83
|
-
let
|
|
84
|
-
let e =
|
|
102
|
+
let v = h && h.length > 0 ? (() => {
|
|
103
|
+
let e = h.map(Number), t = _[Math.min(...e)], n = _[Math.max(...e)];
|
|
85
104
|
return t != null && n != null ? {
|
|
86
105
|
min: t,
|
|
87
106
|
max: n
|
|
88
107
|
} : null;
|
|
89
108
|
})() : null;
|
|
90
|
-
return (
|
|
91
|
-
if (
|
|
92
|
-
let e =
|
|
93
|
-
theme:
|
|
94
|
-
formatter:
|
|
109
|
+
return (n, c, d) => {
|
|
110
|
+
if (n == null) {
|
|
111
|
+
let e = C({
|
|
112
|
+
theme: r,
|
|
113
|
+
formatter: s
|
|
95
114
|
});
|
|
96
|
-
return
|
|
115
|
+
return m ? a(e, m) : e;
|
|
97
116
|
}
|
|
98
|
-
let
|
|
99
|
-
if (
|
|
100
|
-
...
|
|
117
|
+
let f = Array.isArray(c) ? c : [];
|
|
118
|
+
if (f.length === 0 || _.length === 0) return {
|
|
119
|
+
...n,
|
|
101
120
|
dataset: [],
|
|
102
121
|
series: []
|
|
103
122
|
};
|
|
104
|
-
let
|
|
105
|
-
let
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
let h = f.length > 1, x = Array.isArray(n.series) ? n.series : [], S = x[0] ?? {}, w = typeof n.yAxis == "object" && !Array.isArray(n.yAxis) ? n.yAxis : {}, E = t(w), 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) => {
|
|
124
|
+
let n = p({
|
|
125
|
+
theme: r,
|
|
126
|
+
datums: e,
|
|
127
|
+
template: t,
|
|
128
|
+
fallback: (e) => e.color
|
|
129
|
+
});
|
|
130
|
+
return { color: (e) => {
|
|
131
|
+
let t = n(e);
|
|
132
|
+
return g ? g.has(e.dataIndex) ? t : y.color.modifyAlpha(t, .15) : t;
|
|
133
|
+
} };
|
|
134
|
+
}, R = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, z = {
|
|
135
|
+
min: v?.min ?? R?.min ?? null,
|
|
136
|
+
max: v?.max ?? R?.max ?? null
|
|
137
|
+
}, B = Array.isArray(n.xAxis) ? [{
|
|
138
|
+
...n.xAxis[0],
|
|
139
|
+
...z
|
|
140
|
+
}, ...n.xAxis.slice(1)] : {
|
|
141
|
+
...typeof n.xAxis == "object" ? n.xAxis : {},
|
|
142
|
+
...z
|
|
116
143
|
};
|
|
117
144
|
return {
|
|
118
|
-
...
|
|
119
|
-
xAxis:
|
|
120
|
-
dataset:
|
|
121
|
-
|
|
122
|
-
|
|
145
|
+
...n,
|
|
146
|
+
xAxis: B,
|
|
147
|
+
dataset: f.map((e) => ({ source: _.map((t, n) => {
|
|
148
|
+
let r = e[n];
|
|
149
|
+
return [t, r == null ? 0 : b(r)];
|
|
150
|
+
}) })),
|
|
151
|
+
series: f.map((e, t) => {
|
|
152
|
+
let n = x[t] ?? S, i = o(r, u?.[t]?.color);
|
|
123
153
|
return {
|
|
124
|
-
...typeof
|
|
154
|
+
...typeof n == "object" ? n : {},
|
|
125
155
|
type: "bar",
|
|
126
156
|
datasetIndex: t,
|
|
127
|
-
name:
|
|
157
|
+
name: u?.[t]?.name ?? `Series ${t + 1}`,
|
|
128
158
|
encode: {
|
|
129
159
|
x: 0,
|
|
130
160
|
y: 1
|
|
131
161
|
},
|
|
132
162
|
barCategoryGap: "0%",
|
|
133
163
|
emphasis: { focus: "series" },
|
|
134
|
-
itemStyle:
|
|
164
|
+
itemStyle: L(e, n),
|
|
135
165
|
...i ? { color: i } : {}
|
|
136
166
|
};
|
|
137
167
|
}),
|
|
138
168
|
legend: {
|
|
139
|
-
...
|
|
140
|
-
show:
|
|
169
|
+
...k,
|
|
170
|
+
show: h
|
|
141
171
|
},
|
|
142
172
|
grid: {
|
|
143
|
-
...
|
|
144
|
-
bottom:
|
|
173
|
+
...D,
|
|
174
|
+
bottom: I
|
|
145
175
|
},
|
|
146
|
-
...
|
|
176
|
+
...N ? { dataZoom: N } : {},
|
|
147
177
|
yAxis: {
|
|
148
|
-
...
|
|
149
|
-
min: (e) => (
|
|
150
|
-
max: (e) => (
|
|
178
|
+
...w,
|
|
179
|
+
min: (e) => (j = e.min < 0 ? E.min ?? l(e.min) : 0, j),
|
|
180
|
+
max: (e) => (M = e.max <= 0 ? 1 : E.max ?? l(e.max), M),
|
|
151
181
|
axisLabel: {
|
|
152
|
-
...
|
|
153
|
-
formatter: (e) => e !==
|
|
182
|
+
...w.axisLabel ?? {},
|
|
183
|
+
formatter: (e) => e !== M && e !== j || e === 0 ? "" : A ? A(e) : String(e)
|
|
154
184
|
}
|
|
155
185
|
},
|
|
156
186
|
tooltip: {
|
|
157
|
-
...
|
|
158
|
-
formatter:
|
|
187
|
+
...O,
|
|
188
|
+
formatter: T(A)
|
|
159
189
|
}
|
|
160
190
|
};
|
|
161
191
|
};
|
|
162
192
|
}
|
|
163
|
-
function
|
|
164
|
-
return
|
|
193
|
+
function T(e) {
|
|
194
|
+
return f((t) => {
|
|
165
195
|
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}: ` : "";
|
|
166
196
|
return {
|
|
167
197
|
name: String(t.name ?? ""),
|
|
@@ -171,12 +201,12 @@ function b(e) {
|
|
|
171
201
|
};
|
|
172
202
|
});
|
|
173
203
|
}
|
|
174
|
-
function
|
|
204
|
+
function E(e) {
|
|
175
205
|
return Number.isInteger(e) ? String(e) : Number(e.toFixed(2)).toString();
|
|
176
206
|
}
|
|
177
207
|
//#endregion
|
|
178
208
|
//#region src/widgets-v2/histogram/skeleton.tsx
|
|
179
|
-
var
|
|
209
|
+
var D = {
|
|
180
210
|
container: {
|
|
181
211
|
display: "flex",
|
|
182
212
|
alignItems: "center",
|
|
@@ -203,65 +233,65 @@ var S = {
|
|
|
203
233
|
alignItems: "center",
|
|
204
234
|
gap: ({ spacing: e }) => e(1.5)
|
|
205
235
|
}
|
|
206
|
-
},
|
|
236
|
+
}, O = (e) => ({
|
|
207
237
|
flex: 1,
|
|
208
238
|
height: `${e}%`,
|
|
209
239
|
minWidth: 8
|
|
210
240
|
});
|
|
211
|
-
function
|
|
212
|
-
let t =
|
|
241
|
+
function k(e) {
|
|
242
|
+
let t = m(15), { bins: n } = e, r = n === void 0 ? 12 : n, i, a, o, s, c;
|
|
213
243
|
if (t[0] !== r) {
|
|
214
244
|
let e = Array.from({ length: r }, (e, t) => {
|
|
215
245
|
let n = t / Math.max(1, r - 1);
|
|
216
246
|
return Math.round(20 + 80 * Math.exp(-((n - .5) ** 2) * 8));
|
|
217
247
|
});
|
|
218
|
-
a =
|
|
248
|
+
a = h, c = D.container, i = h, o = D.grid, s = e.map(j), t[0] = r, t[1] = i, t[2] = a, t[3] = o, t[4] = s, t[5] = c;
|
|
219
249
|
} else i = t[1], a = t[2], o = t[3], s = t[4], c = t[5];
|
|
220
250
|
let l;
|
|
221
|
-
t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */
|
|
251
|
+
t[6] !== i || t[7] !== o || t[8] !== s ? (l = /* @__PURE__ */ _(i, {
|
|
222
252
|
sx: o,
|
|
223
253
|
children: s
|
|
224
254
|
}), t[6] = i, t[7] = o, t[8] = s, t[9] = l) : l = t[9];
|
|
225
255
|
let u;
|
|
226
|
-
t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ h
|
|
227
|
-
sx:
|
|
228
|
-
children: [0, 1].map(
|
|
256
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ _(h, {
|
|
257
|
+
sx: D.legend,
|
|
258
|
+
children: [0, 1].map(A)
|
|
229
259
|
}), t[10] = u) : u = t[10];
|
|
230
260
|
let d;
|
|
231
|
-
return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */
|
|
261
|
+
return t[11] !== a || t[12] !== c || t[13] !== l ? (d = /* @__PURE__ */ v(a, {
|
|
232
262
|
sx: c,
|
|
233
263
|
children: [l, u]
|
|
234
264
|
}), t[11] = a, t[12] = c, t[13] = l, t[14] = d) : d = t[14], d;
|
|
235
265
|
}
|
|
236
|
-
function
|
|
237
|
-
return /* @__PURE__ */
|
|
238
|
-
sx:
|
|
239
|
-
children: [/* @__PURE__ */
|
|
266
|
+
function A(e) {
|
|
267
|
+
return /* @__PURE__ */ v(h, {
|
|
268
|
+
sx: D.legendItem,
|
|
269
|
+
children: [/* @__PURE__ */ _(g, {
|
|
240
270
|
variant: "circular",
|
|
241
271
|
width: 8,
|
|
242
272
|
height: 8
|
|
243
|
-
}), /* @__PURE__ */
|
|
273
|
+
}), /* @__PURE__ */ _(g, {
|
|
244
274
|
width: 48,
|
|
245
275
|
height: 8
|
|
246
276
|
})]
|
|
247
277
|
}, `legend-${e}`);
|
|
248
278
|
}
|
|
249
|
-
function
|
|
250
|
-
return /* @__PURE__ */
|
|
279
|
+
function j(e, t) {
|
|
280
|
+
return /* @__PURE__ */ _(g, {
|
|
251
281
|
variant: "rectangular",
|
|
252
|
-
sx:
|
|
282
|
+
sx: O(e)
|
|
253
283
|
}, `bar-${t}`);
|
|
254
284
|
}
|
|
255
285
|
//#endregion
|
|
256
286
|
//#region src/widgets-v2/histogram/download.ts
|
|
257
|
-
function
|
|
258
|
-
let
|
|
259
|
-
return e.getCaptureEl &&
|
|
287
|
+
function M(e) {
|
|
288
|
+
let t = [];
|
|
289
|
+
return e.getCaptureEl && t.push(n({
|
|
260
290
|
filename: e.filename,
|
|
261
291
|
getCaptureEl: e.getCaptureEl,
|
|
262
292
|
pixelRatio: e.pngPixelRatio,
|
|
263
293
|
backgroundColor: e.pngBackgroundColor
|
|
264
|
-
})),
|
|
294
|
+
})), t.push(r({
|
|
265
295
|
filename: e.filename,
|
|
266
296
|
getRows: (t) => {
|
|
267
297
|
let n = e.getData(t), r = e.getTicks(), i = n.length, a = ["bin_low", "bin_high"];
|
|
@@ -269,29 +299,32 @@ function D(e) {
|
|
|
269
299
|
let o = [a];
|
|
270
300
|
for (let e = 0; e < Math.max(0, r.length - 1); e++) {
|
|
271
301
|
let t = [r[e], r[e + 1]];
|
|
272
|
-
for (let r = 0; r < i; r++)
|
|
302
|
+
for (let r = 0; r < i; r++) {
|
|
303
|
+
let i = n[r]?.[e];
|
|
304
|
+
t.push(i == null ? 0 : b(i));
|
|
305
|
+
}
|
|
273
306
|
o.push(t);
|
|
274
307
|
}
|
|
275
308
|
return o;
|
|
276
309
|
}
|
|
277
|
-
})),
|
|
310
|
+
})), t;
|
|
278
311
|
}
|
|
279
312
|
//#endregion
|
|
280
313
|
//#region src/widgets-v2/histogram/transforms.ts
|
|
281
|
-
var
|
|
282
|
-
if (!
|
|
283
|
-
let t = e.reduce((e, t) => e + Math.abs(t), 0);
|
|
284
|
-
return t <= 0 ? e : e.map((e) => e / t * 100);
|
|
314
|
+
var N = (e) => Array.isArray(e) ? e.map((e) => {
|
|
315
|
+
if (!P(e)) return e;
|
|
316
|
+
let t = e.reduce((e, t) => e + Math.abs(b(t)), 0);
|
|
317
|
+
return t <= 0 ? e : e.map((e) => S(e, b(e) / t * 100));
|
|
285
318
|
}) : e;
|
|
286
|
-
function
|
|
287
|
-
return Array.isArray(e)
|
|
319
|
+
function P(e) {
|
|
320
|
+
return Array.isArray(e) && e.every(x);
|
|
288
321
|
}
|
|
289
|
-
function
|
|
322
|
+
function F(e, t) {
|
|
290
323
|
if (t.length === 0 || !Array.isArray(e)) return e;
|
|
291
324
|
let n = new Set(t.map(Number));
|
|
292
|
-
return e.map((e) =>
|
|
325
|
+
return e.map((e) => P(e) ? e.map((e, t) => n.has(t) ? e : S(e, 0)) : e);
|
|
293
326
|
}
|
|
294
327
|
//#endregion
|
|
295
|
-
export {
|
|
328
|
+
export { k as HistogramSkeleton, M as createHistogramDownloadConfig, w as createHistogramOptionFactory, F as filterHistogramByLockedBins, b as getHistogramBinValue, C as histogramOptions, N as toRelativeHistogramData };
|
|
296
329
|
|
|
297
330
|
//# sourceMappingURL=histogram.js.map
|