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