@carto/ps-react-ui 4.9.1 → 4.11.1
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/category-Dnd2_j0x.js +719 -0
- package/dist/category-Dnd2_j0x.js.map +1 -0
- package/dist/change-column-DjjwoPt1.js +1143 -0
- package/dist/change-column-DjjwoPt1.js.map +1 -0
- package/dist/chat.js +1507 -0
- package/dist/chat.js.map +1 -0
- package/dist/components.js +122 -120
- package/dist/components.js.map +1 -1
- package/dist/copy-button-DGL1tyli.js +26 -0
- package/dist/copy-button-DGL1tyli.js.map +1 -0
- package/dist/{data-zoom-layout-0QSptXG_.js → data-zoom-layout-CkVnm6ej.js} +3 -3
- package/dist/{data-zoom-layout-0QSptXG_.js.map → data-zoom-layout-CkVnm6ej.js.map} +1 -1
- package/dist/{download-config-CzmjOT2T.js → download-config-oJIFZ2WC.js} +9 -8
- package/dist/{download-config-CzmjOT2T.js.map → download-config-oJIFZ2WC.js.map} +1 -1
- package/dist/{png-item-CS4z1iSH.js → png-item-BE9uEqlD.js} +2 -2
- package/dist/png-item-BE9uEqlD.js.map +1 -0
- package/dist/{spread-Y9R1f5dm.js → spread-DYNpzgh_.js} +10 -11
- package/dist/{spread-Y9R1f5dm.js.map → spread-DYNpzgh_.js.map} +1 -1
- package/dist/{table-CQCAnDLb.js → table-C9IMbTr0.js} +50 -53
- package/dist/table-C9IMbTr0.js.map +1 -0
- package/dist/types/chat/bubbles/chat-error-message.d.ts +2 -0
- package/dist/types/chat/bubbles/chat-suggestion-button.d.ts +2 -0
- package/dist/types/chat/bubbles/chat-user-message.d.ts +2 -0
- package/dist/types/chat/bubbles/index.d.ts +4 -0
- package/dist/types/chat/const.d.ts +4 -0
- package/dist/types/chat/containers/chat-content.d.ts +2 -0
- package/dist/types/chat/containers/chat-footer.d.ts +2 -0
- package/dist/types/chat/containers/chat-header.d.ts +2 -0
- package/dist/types/chat/containers/chat-starter.d.ts +2 -0
- package/dist/types/chat/containers/index.d.ts +4 -0
- package/dist/types/chat/containers/styles.d.ts +93 -0
- package/dist/types/chat/feedback/chat-loader.d.ts +2 -0
- package/dist/types/chat/feedback/chat-rating-action.d.ts +2 -0
- package/dist/types/chat/feedback/chat-thinking.d.ts +2 -0
- package/dist/types/chat/feedback/chat-tool-code-area.d.ts +2 -0
- package/dist/types/chat/feedback/chat-tool-full-view-dialog.d.ts +2 -0
- package/dist/types/chat/feedback/chat-tool-group.d.ts +2 -0
- package/dist/types/chat/feedback/chat-tool-trace.d.ts +3 -0
- package/dist/types/chat/feedback/get-tool-label.d.ts +2 -0
- package/dist/types/chat/feedback/index.d.ts +8 -0
- package/dist/types/chat/feedback/styles.d.ts +211 -0
- package/dist/types/chat/index.d.ts +20 -0
- package/dist/types/chat/types.d.ts +184 -0
- package/dist/types/chat/use-typewriter.d.ts +30 -0
- package/dist/types/components/copy-button/copy-button.d.ts +2 -0
- package/dist/types/components/copy-button/types.d.ts +6 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/widgets/actions/brush-toggle/style.d.ts +1 -1
- package/dist/types/widgets/actions/shared/styles.d.ts +1 -1
- package/dist/types/widgets/actions/zoom-toggle/style.d.ts +1 -1
- package/dist/types/widgets/echart/types.d.ts +1 -1
- package/dist/types/widgets/toolbar-actions/styles.d.ts +1 -1
- package/dist/types/widgets-v2/actions/brush-toggle/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/change-column/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/fullscreen/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/index.d.ts +1 -0
- package/dist/types/widgets-v2/actions/lock-selection/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/relative-data/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/searcher/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/show-all/index.d.ts +2 -0
- package/dist/types/widgets-v2/actions/show-all/labels.d.ts +5 -0
- package/dist/types/widgets-v2/actions/show-all/show-all.d.ts +33 -0
- package/dist/types/widgets-v2/actions/show-all/style.d.ts +8 -0
- package/dist/types/widgets-v2/actions/stack-toggle/style.d.ts +1 -1
- package/dist/types/widgets-v2/actions/zoom-toggle/style.d.ts +1 -1
- package/dist/types/widgets-v2/category/category-ui.d.ts +9 -2
- package/dist/types/widgets-v2/category/category.d.ts +9 -2
- package/dist/types/widgets-v2/category/components/category-row-other.d.ts +19 -6
- package/dist/types/widgets-v2/category/style.d.ts +21 -2
- package/dist/types/widgets-v2/category/types.d.ts +2 -0
- package/dist/types/widgets-v2/index.d.ts +3 -2
- package/dist/types/widgets-v2/selection-summary/labels.d.ts +7 -2
- package/dist/types/widgets-v2/selection-summary/selection-summary.d.ts +13 -6
- package/dist/types/widgets-v2/selection-summary/style.d.ts +15 -0
- package/dist/widgets/actions.js +115 -114
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +1 -1
- package/dist/widgets/category.js +9 -8
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/formula.js +11 -10
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +7 -6
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/markdown.js +9 -8
- package/dist/widgets/markdown.js.map +1 -1
- package/dist/widgets/pie.js +1 -1
- package/dist/widgets/scatterplot.js +1 -1
- package/dist/widgets/spread.js +9 -8
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/table.js +17 -16
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +1 -1
- package/dist/widgets/utils.js +1 -1
- package/dist/widgets/wrapper.js +3 -2
- package/dist/widgets/wrapper.js.map +1 -1
- package/dist/widgets-v2/actions.js +41 -37
- package/dist/widgets-v2/bar.js +9 -10
- package/dist/widgets-v2/bar.js.map +1 -1
- package/dist/widgets-v2/category.js +25 -26
- package/dist/widgets-v2/category.js.map +1 -1
- package/dist/widgets-v2/formula.js +3 -3
- package/dist/widgets-v2/histogram.js +11 -13
- package/dist/widgets-v2/histogram.js.map +1 -1
- package/dist/widgets-v2/markdown.js +26 -27
- package/dist/widgets-v2/markdown.js.map +1 -1
- package/dist/widgets-v2/pie.js +8 -10
- package/dist/widgets-v2/pie.js.map +1 -1
- package/dist/widgets-v2/scatterplot.js +10 -12
- package/dist/widgets-v2/scatterplot.js.map +1 -1
- package/dist/widgets-v2/spread.js +15 -16
- package/dist/widgets-v2/spread.js.map +1 -1
- package/dist/widgets-v2/table.js +39 -40
- package/dist/widgets-v2/table.js.map +1 -1
- package/dist/widgets-v2/timeseries.js +9 -11
- package/dist/widgets-v2/timeseries.js.map +1 -1
- package/dist/widgets-v2/utils.js +1 -1
- package/dist/widgets-v2.js +284 -282
- package/dist/widgets-v2.js.map +1 -1
- package/package.json +5 -1
- package/src/chat/bubbles/chat-agent-message.test.tsx +30 -0
- package/src/chat/bubbles/chat-agent-message.tsx +11 -0
- package/src/chat/bubbles/chat-error-message.test.tsx +40 -0
- package/src/chat/bubbles/chat-error-message.tsx +47 -0
- package/src/chat/bubbles/chat-suggestion-button.test.tsx +24 -0
- package/src/chat/bubbles/chat-suggestion-button.tsx +27 -0
- package/src/chat/bubbles/chat-user-message.test.tsx +27 -0
- package/src/chat/bubbles/chat-user-message.tsx +27 -0
- package/src/chat/bubbles/index.ts +4 -0
- package/src/chat/bubbles/styles.ts +148 -0
- package/src/chat/const.ts +4 -0
- package/src/chat/containers/chat-content.test.tsx +269 -0
- package/src/chat/containers/chat-content.tsx +142 -0
- package/src/chat/containers/chat-footer.test.tsx +34 -0
- package/src/chat/containers/chat-footer.tsx +78 -0
- package/src/chat/containers/chat-header.test.tsx +28 -0
- package/src/chat/containers/chat-header.tsx +29 -0
- package/src/chat/containers/chat-starter.test.tsx +32 -0
- package/src/chat/containers/chat-starter.tsx +75 -0
- package/src/chat/containers/index.ts +4 -0
- package/src/chat/containers/styles.ts +96 -0
- package/src/chat/feedback/chat-actions-container.test.tsx +64 -0
- package/src/chat/feedback/chat-actions-container.tsx +7 -0
- package/src/chat/feedback/chat-loader.test.tsx +10 -0
- package/src/chat/feedback/chat-loader.tsx +31 -0
- package/src/chat/feedback/chat-rating-action.tsx +43 -0
- package/src/chat/feedback/chat-thinking.test.tsx +15 -0
- package/src/chat/feedback/chat-thinking.tsx +23 -0
- package/src/chat/feedback/chat-tool-code-area.test.tsx +23 -0
- package/src/chat/feedback/chat-tool-code-area.tsx +71 -0
- package/src/chat/feedback/chat-tool-full-view-dialog.test.tsx +39 -0
- package/src/chat/feedback/chat-tool-full-view-dialog.tsx +121 -0
- package/src/chat/feedback/chat-tool-group.test.tsx +84 -0
- package/src/chat/feedback/chat-tool-group.tsx +156 -0
- package/src/chat/feedback/chat-tool-trace.test.tsx +81 -0
- package/src/chat/feedback/chat-tool-trace.tsx +192 -0
- package/src/chat/feedback/get-tool-label.test.tsx +91 -0
- package/src/chat/feedback/get-tool-label.ts +13 -0
- package/src/chat/feedback/index.ts +8 -0
- package/src/chat/feedback/styles.ts +229 -0
- package/src/chat/index.ts +59 -0
- package/src/chat/types.ts +215 -0
- package/src/chat/use-typewriter.test.tsx +38 -0
- package/src/chat/use-typewriter.ts +82 -0
- package/src/components/copy-button/copy-button.test.tsx +41 -0
- package/src/components/copy-button/copy-button.tsx +31 -0
- package/src/components/copy-button/types.ts +10 -0
- package/src/components/index.ts +3 -0
- package/src/widgets/echart/types.ts +1 -1
- package/src/widgets-v2/actions/brush-toggle/brush-toggle.tsx +1 -1
- package/src/widgets-v2/actions/change-column/sortable-column-item.tsx +1 -1
- package/src/widgets-v2/actions/download/download.tsx +1 -1
- package/src/widgets-v2/actions/download/icons.tsx +1 -1
- package/src/widgets-v2/actions/fullscreen/fullscreen.tsx +3 -3
- package/src/widgets-v2/actions/index.ts +8 -0
- package/src/widgets-v2/actions/lock-selection/lock-selection.tsx +2 -2
- package/src/widgets-v2/actions/relative-data/relative-data.tsx +1 -1
- package/src/widgets-v2/actions/searcher/searcher-toggle.tsx +1 -1
- package/src/widgets-v2/actions/searcher/searcher.tsx +2 -2
- package/src/widgets-v2/actions/show-all/index.ts +7 -0
- package/src/widgets-v2/actions/show-all/labels.ts +8 -0
- package/src/widgets-v2/actions/show-all/show-all.test.tsx +50 -0
- package/src/widgets-v2/actions/show-all/show-all.tsx +72 -0
- package/src/widgets-v2/actions/show-all/style.ts +8 -0
- package/src/widgets-v2/actions/stack-toggle/stack-toggle.tsx +1 -1
- package/src/widgets-v2/actions/zoom-toggle/zoom-toggle.tsx +1 -1
- package/src/widgets-v2/category/category-ui.test.tsx +26 -10
- package/src/widgets-v2/category/category-ui.tsx +13 -3
- package/src/widgets-v2/category/category.test.tsx +4 -4
- package/src/widgets-v2/category/category.tsx +10 -1
- package/src/widgets-v2/category/components/category-row-other.test.tsx +36 -7
- package/src/widgets-v2/category/components/category-row-other.tsx +64 -13
- package/src/widgets-v2/category/style.ts +35 -4
- package/src/widgets-v2/category/types.ts +2 -0
- package/src/widgets-v2/index.ts +3 -0
- package/src/widgets-v2/selection-summary/labels.ts +8 -4
- package/src/widgets-v2/selection-summary/selection-summary.test.tsx +15 -9
- package/src/widgets-v2/selection-summary/selection-summary.tsx +42 -22
- package/src/widgets-v2/selection-summary/style.ts +15 -0
- package/src/widgets-v2/table/table-ui.tsx +4 -4
- package/src/widgets-v2/toolbox/toolbox.tsx +1 -1
- package/src/widgets-v2/wrapper/widget-wrapper.tsx +1 -1
- package/dist/category-DwaeYjpX.js +0 -656
- package/dist/category-DwaeYjpX.js.map +0 -1
- package/dist/change-column-B4IT0rh6.js +0 -1110
- package/dist/change-column-B4IT0rh6.js.map +0 -1
- package/dist/png-item-CS4z1iSH.js.map +0 -1
- package/dist/table-CQCAnDLb.js.map +0 -1
|
@@ -10,11 +10,11 @@ import "react";
|
|
|
10
10
|
import "html2canvas";
|
|
11
11
|
import "../lasso-tool-CDFj4zKY.js";
|
|
12
12
|
import "../cjs-D4KH3azB.js";
|
|
13
|
+
import "@carto/ps-utils";
|
|
13
14
|
import "@dnd-kit/core";
|
|
14
15
|
import "@dnd-kit/sortable";
|
|
15
16
|
import "@dnd-kit/utilities";
|
|
16
17
|
import "react-dom";
|
|
17
|
-
import "@mui/icons-material/ZoomIn";
|
|
18
18
|
import "../widget-context-DTGO0Yta.js";
|
|
19
19
|
import "zustand";
|
|
20
20
|
import "zustand/vanilla";
|
|
@@ -22,11 +22,9 @@ import "zustand/middleware";
|
|
|
22
22
|
import "zustand/react/shallow";
|
|
23
23
|
import { Z as O } from "../transforms-Cdx4fkU5.js";
|
|
24
24
|
import { m as q, r as U } from "../resolve-theme-color-BdojIw0K.js";
|
|
25
|
-
import { p as J } from "../data-zoom-layout-
|
|
26
|
-
import "@mui/icons-material/FileDownload";
|
|
25
|
+
import { p as J } from "../data-zoom-layout-CkVnm6ej.js";
|
|
27
26
|
import { a as K } from "../exports-Cx-f6m6U.js";
|
|
28
|
-
import "
|
|
29
|
-
import { b as Q } from "../png-item-CS4z1iSH.js";
|
|
27
|
+
import { b as Q } from "../png-item-BE9uEqlD.js";
|
|
30
28
|
function X({
|
|
31
29
|
theme: e,
|
|
32
30
|
formatter: t
|
|
@@ -116,7 +114,7 @@ function X({
|
|
|
116
114
|
}
|
|
117
115
|
};
|
|
118
116
|
}
|
|
119
|
-
function
|
|
117
|
+
function Ne(e) {
|
|
120
118
|
const {
|
|
121
119
|
theme: t,
|
|
122
120
|
formatter: a,
|
|
@@ -272,7 +270,7 @@ const w = {
|
|
|
272
270
|
height: `${e}%`,
|
|
273
271
|
minWidth: 8
|
|
274
272
|
});
|
|
275
|
-
function
|
|
273
|
+
function Oe(e) {
|
|
276
274
|
const t = Y(15), {
|
|
277
275
|
bins: a
|
|
278
276
|
} = e, o = a === void 0 ? 12 : a;
|
|
@@ -306,7 +304,7 @@ function re(e) {
|
|
|
306
304
|
function oe(e, t) {
|
|
307
305
|
return /* @__PURE__ */ b(k, { variant: "rectangular", sx: te(e) }, `bar-${t}`);
|
|
308
306
|
}
|
|
309
|
-
function
|
|
307
|
+
function _e(e) {
|
|
310
308
|
const t = [];
|
|
311
309
|
return e.getCaptureEl && t.push(Q({
|
|
312
310
|
filename: e.filename,
|
|
@@ -335,7 +333,7 @@ function je(e) {
|
|
|
335
333
|
}
|
|
336
334
|
}), t;
|
|
337
335
|
}
|
|
338
|
-
const
|
|
336
|
+
const $e = (e) => Array.isArray(e) ? e.map((t) => {
|
|
339
337
|
if (!ie(t)) return t;
|
|
340
338
|
const a = t.reduce((o, i) => o + Math.abs(i), 0);
|
|
341
339
|
return a <= 0 ? t : t.map((o) => o / a * 100);
|
|
@@ -344,10 +342,10 @@ function ie(e) {
|
|
|
344
342
|
return Array.isArray(e) ? e.every((t) => typeof t == "number" && Number.isFinite(t)) : !1;
|
|
345
343
|
}
|
|
346
344
|
export {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
Oe as HistogramSkeleton,
|
|
346
|
+
_e as createHistogramDownloadConfig,
|
|
347
|
+
Ne as createHistogramOptionFactory,
|
|
350
348
|
X as histogramOptions,
|
|
351
|
-
|
|
349
|
+
$e as toRelativeHistogramData
|
|
352
350
|
};
|
|
353
351
|
//# sourceMappingURL=histogram.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram.js","sources":["../../src/widgets-v2/histogram/options.ts","../../src/widgets-v2/histogram/skeleton.tsx","../../src/widgets-v2/histogram/download.ts","../../src/widgets-v2/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\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 HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n const { niceMinVal, niceMaxVal } = computeHistogramNiceBounds(seriesArr)\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: niceMinVal,\n max: niceMaxVal,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction computeHistogramNiceBounds(seriesArr: HistogramWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let max = -Infinity\n for (const counts of seriesArr) {\n for (const v of counts) {\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n if (v > max) max = v\n }\n }\n return {\n niceMinVal: 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(args: {\n filename: string\n getData: () => HistogramWidgetData\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n"],"names":["histogramOptions","theme","formatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildHistogramTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","String","createHistogramOptionFactory","options","ticks","series","labelFormatter","selection","optionsOverride","selectionSet","length","Set","binLabels","i","lo","hi","raw","formatNumber","push","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","niceMinVal","niceMaxVal","computeHistogramNiceBounds","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","has","dataIndex","echarts","modifyAlpha","map","counts","source","label","_","template","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","barCategoryGap","emphasis","focus","itemStyle","createTooltipFormatter","item","formattedValue","marker","seriesName","v","Number","isFinite","n","isInteger","toFixed","toString","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","barSx","minWidth","HistogramSkeleton","t0","$","_c","bins","t1","undefined","T0","T1","t2","t3","t4","heights","from","t","Math","round","exp","Box","_temp","t5","jsx","t6","Symbol","for","_temp2","t7","i_1","jsxs","Skeleton","h","i_0","createHistogramDownloadConfig","args","items","getCaptureEl","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","getTicks","seriesCount","header","seriesNames","rows","bin","row","s","handle","downloadToCSV","Promise","url","revoke","toRelativeHistogramData","input","isFlatNumberArray","total","reduce","acc","abs","every"],"mappings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AAA,EAAA,CACD,GACMtB;AACT;AC3CO,MAAMuB,KAA0BA,CAACC,MACjClI,MAAMC,QAAQiI,CAAK,IACjBA,EAAMpG,IAAI,CAAClD,MAA6B;AAC7C,MAAI,CAACuJ,GAAkBvJ,CAAM,EAAG,QAAOA;AACvC,QAAMwJ,IAAQxJ,EAAOyJ,OAAO,CAACC,GAAKlF,MAAMkF,IAAM/C,KAAKgD,IAAInF,CAAC,GAAG,CAAC;AAC5D,SAAIgF,KAAS,IAAUxJ,IAChBA,EAAOkD,IAAKsB,CAAAA,MAAOA,IAAIgF,IAAS,GAAG;AAC5C,CAAC,IANiCF;AASpC,SAASC,GAAkB/E,GAA2B;AACpD,SAAKpD,MAAMC,QAAQmD,CAAC,IACbA,EAAEoF,MAAOxF,CAAAA,MAAS,OAAOA,KAAS,YAAYK,OAAOC,SAASN,CAAI,CAAC,IAD5C;AAEhC;"}
|
|
1
|
+
{"version":3,"file":"histogram.js","sources":["../../src/widgets-v2/histogram/options.ts","../../src/widgets-v2/histogram/skeleton.tsx","../../src/widgets-v2/histogram/download.ts","../../src/widgets-v2/histogram/transforms.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\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 HistogramEChartsOption,\n HistogramOptionFactoryInput,\n HistogramOptionsInput,\n HistogramWidgetData,\n} from './types'\n\n/**\n * Builds the **structural** ECharts option for a histogram widget — axes,\n * grid, tooltip, value-axis label formatter, themed legend. Mirrors\n * {@link import('../bar/options').barOptions} so the two widgets share v1\n * look-and-feel: themed dark tooltip with positioner, CARTO color palette,\n * structural legend (`show` toggled by the merger based on series count),\n * y-axis labels rendered inside the plot via the `niceNum` closure pattern.\n *\n * Intentional deviations from bar (histogram-specific):\n * - **No `xAxis.axisLabel.formatter`.** Bin labels are pre-formatted in\n * the merger via `formatNumber(lo)–formatNumber(hi)` and optionally\n * the consumer's `labelFormatter`. The strings on the axis are\n * already display-ready, so there's nothing to post-format here.\n * - **Tooltip formatter reads the array-tuple row shape.** The dataset\n * uses positional `encode: { x: 0, y: 1 }`, so `item.value` comes in\n * as `[binLabel, count]` rather than bar's `{ name, value }` object.\n *\n * Intentionally data-agnostic: no series, no dataset, no x-axis category\n * data (those depend on data + ticks and are added by the option factory's\n * merge phase via {@link createHistogramOptionFactory}).\n */\nexport function histogramOptions({\n theme,\n formatter,\n}: HistogramOptionsInput): HistogramEChartsOption {\n // Closure shared between yAxis min/max callbacks and the label formatter,\n // so only the rounded extents are labelled (matches v1 + bar).\n let niceMin = 0\n let niceMax = 1\n\n return {\n grid: {\n left: parseInt(theme.spacing(1)),\n top: parseInt(theme.spacing(3)),\n right: parseInt(theme.spacing(1)),\n // Default: no legend. Merger bumps this when there are >1 series.\n ...buildGridConfig(false, theme),\n containLabel: true,\n },\n tooltip: {\n trigger: 'axis',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n axisPointer: { type: 'line' },\n position: createTooltipPositioner(theme),\n formatter: buildHistogramTooltipFormatter(formatter),\n },\n // Legend styling baked here; `show` is toggled by the merger based on\n // series count. Histogram doesn't accept `labelFormatter` at the\n // options layer (bin labels are pre-formatted in the merger), so we\n // skip the legend `labelFormatter` argument too.\n legend: {\n ...buildLegendConfig({ hasLegend: false }),\n },\n axisPointer: { lineStyle: { color: theme.palette.grey[400] } },\n color: [\n theme.palette.secondary.main,\n ...Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n ],\n xAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n margin: 0,\n hideOverlap: true,\n },\n },\n yAxis: {\n type: 'value',\n min: (extent: { min: number }) => {\n niceMin = extent.min < 0 ? niceNum(extent.min) : 0\n return niceMin\n },\n max: (extent: { min: number; max: number }) => {\n niceMax = extent.max <= 0 ? 1 : niceNum(extent.max)\n return niceMax\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n show: true,\n showMaxLabel: true,\n showMinLabel: true,\n verticalAlign: 'bottom',\n inside: true,\n formatter: (value: number) => {\n if (value !== niceMax && value !== niceMin) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n } as HistogramEChartsOption\n}\n\n/**\n * Returns the histogram widget's {@link OptionFactory} — one closure that\n * owns BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link histogramOptions}, optionally merging\n * the consumer-supplied `optionsOverride`. Called once by Provider to\n * seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`HistogramWidgetData` — `number[][]`) into the option via the\n * dataset API. Each series gets its own dataset of `[binLabel, count]`\n * pairs derived from `ticks`; series reference their dataset by\n * `datasetIndex` and are encoded by column position. Reactive\n * `ctx.formatter` (driven by RelativeData → `%`) plus `niceMin`/`niceMax`\n * are re-derived here so the y-axis label formatter and the tooltip\n * pick up live store values, mirroring bar.\n */\nexport function createHistogramOptionFactory(\n options: HistogramOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, ticks, series, labelFormatter, selection } = options\n const optionsOverride = options.optionsOverride\n const selectionSet =\n selection && selection.length > 0 ? new Set<number>(selection) : null\n\n const binLabels: string[] = []\n for (let i = 0; i < ticks.length - 1; i++) {\n const lo = ticks[i]!\n const hi = ticks[i + 1]!\n const raw = `${formatNumber(lo)}–${formatNumber(hi)}`\n binLabels.push(labelFormatter ? labelFormatter(raw) : raw)\n }\n\n return (option, data, ctx) => {\n if (option == null) {\n const structural = histogramOptions({ theme, formatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr: HistogramWidgetData = Array.isArray(data)\n ? (data as HistogramWidgetData)\n : []\n if (seriesArr.length === 0 || binLabels.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n\n const hasLegend = seriesArr.length > 1\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseYAxis =\n typeof option.yAxis === 'object' && !Array.isArray(option.yAxis)\n ? option.yAxis\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n // Reactive (live store) formatter from ctx — distinct from the\n // closure-time `formatter` captured for the structural-build branch\n // above. RelativeData can install a percent formatter on the store\n // after the factory was constructed; the merge phase reads `ctx` to\n // pick that up.\n const liveFormatter = ctx?.formatter\n\n const { niceMinVal, niceMaxVal } = computeHistogramNiceBounds(seriesArr)\n\n // Zoom slider layout: when ZoomToggle has installed `dataZoom`, push\n // the slider above the legend (if any) and reserve room in the grid.\n const dataZoomLayout = positionDataZoomForLegend(option.dataZoom, hasLegend)\n const fallbackBottom =\n typeof baseGrid.bottom === 'number' ? baseGrid.bottom : 24\n const baseBottom = hasLegend ? 56 : fallbackBottom\n const gridBottom = dataZoomLayout\n ? baseBottom + ZOOM_LAYOUT.sliderHeight + ZOOM_LAYOUT.sliderGap\n : baseBottom\n\n // Dim non-selected bins via `series.itemStyle.color`. Per-row\n // `itemStyle` on dataset sources is silently ignored when\n // `series.encode` is in play.\n //\n // We *always* emit `itemStyle.color` (a passthrough when nothing is\n // selected), not conditionally — dropping the key between renders\n // would let ECharts' default merge keep the previous callback alive\n // and bins would stay dimmed forever after an external clear. Always\n // emitting lets normal merge swap the callback in place, no\n // `replaceMerge` and no entry-animation flash on selection on/off.\n const dimItemStyle = {\n color: (params: CallbackDataParams) => {\n const base = params.color as string\n if (!selectionSet) return base\n return selectionSet.has(params.dataIndex)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n },\n }\n\n return {\n ...option,\n dataset: seriesArr.map((counts) => ({\n source: binLabels.map(\n (label, i) => [label, counts[i] ?? 0] as [string, number],\n ),\n })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n ...(typeof template === 'object' ? template : {}),\n type: 'bar' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n encode: { x: 0, y: 1 },\n barCategoryGap: '0%',\n emphasis: { focus: 'series' },\n itemStyle: dimItemStyle,\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n legend: { ...baseLegend, show: hasLegend },\n grid: { ...baseGrid, bottom: gridBottom },\n ...(dataZoomLayout ? { dataZoom: dataZoomLayout } : {}),\n yAxis: {\n ...baseYAxis,\n min: niceMinVal,\n max: niceMaxVal,\n axisLabel: {\n ...((baseYAxis as { axisLabel?: object }).axisLabel ?? {}),\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return liveFormatter ? liveFormatter(value) : String(value)\n },\n },\n } as EChartsOption['yAxis'],\n tooltip: {\n ...baseTooltip,\n formatter: buildHistogramTooltipFormatter(liveFormatter),\n },\n } as EChartsOption\n }\n}\n\n/**\n * Tooltip formatter for the histogram's positional `[binLabel, count]`\n * row shape. ECharts surfaces the x-axis category through `item.name`\n * (already pre-formatted by the bin-label generator), and `item.value`\n * comes in as the array tuple — distinct from bar's `{ name, value }`\n * object row.\n */\nfunction buildHistogramTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const row = item.value as [string, number] | undefined\n const raw = row?.[1]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n return {\n name: String(item.name ?? ''),\n seriesName,\n marker,\n value: formattedValue,\n }\n })\n}\n\nfunction computeHistogramNiceBounds(seriesArr: HistogramWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let max = -Infinity\n for (const counts of seriesArr) {\n for (const v of counts) {\n if (typeof v !== 'number' || !Number.isFinite(v)) continue\n if (v > max) max = v\n }\n }\n return {\n niceMinVal: 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\nfunction formatNumber(n: number): string {\n if (Number.isInteger(n)) return String(n)\n return Number(n.toFixed(2)).toString()\n}\n","import { Box, Skeleton, type SxProps, type Theme } from '@mui/material'\n\nconst styles = {\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }) => spacing(1),\n height: ({ spacing }) => spacing(38),\n },\n grid: {\n display: 'flex',\n alignItems: 'flex-end',\n flex: '1 1 auto',\n gap: 0.5,\n width: '100%',\n },\n legend: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(2),\n height: ({ spacing }) => spacing(5),\n },\n legendItem: {\n display: 'flex',\n alignItems: 'center',\n gap: ({ spacing }) => spacing(1.5),\n },\n} satisfies Record<string, SxProps<Theme>>\n\nconst barSx = (height: number): SxProps<Theme> => ({\n flex: 1,\n height: `${height}%`,\n minWidth: 8,\n})\n\nexport interface HistogramSkeletonProps {\n bins?: number\n}\n\n/**\n * Loading state for the Histogram widget. Mirrors Bar's skeleton structure\n * — a grid of bars (bin-shaped silhouette, anchored to the bottom) plus a\n * legend stub — so the placeholder reads consistently with Bar.\n */\nexport function HistogramSkeleton({ bins = 12 }: HistogramSkeletonProps) {\n // Sample heights mimicking a typical bell-shaped distribution.\n const heights = Array.from({ length: bins }, (_, i) => {\n const t = i / Math.max(1, bins - 1)\n return Math.round(20 + 80 * Math.exp(-((t - 0.5) ** 2) * 8))\n })\n return (\n <Box sx={styles.container}>\n <Box sx={styles.grid}>\n {heights.map((h, i) => (\n <Skeleton key={`bar-${i}`} variant='rectangular' sx={barSx(h)} />\n ))}\n </Box>\n <Box sx={styles.legend}>\n {[0, 1].map((i) => (\n <Box key={`legend-${i}`} sx={styles.legendItem}>\n <Skeleton variant='circular' width={8} height={8} />\n <Skeleton width={48} height={8} />\n </Box>\n ))}\n </Box>\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { HistogramWidgetData } from './types'\n\n/**\n * Download menu items for histograms. Always includes a CSV item with\n * `bin_low, bin_high, series_1_count, series_2_count, …` columns (one row\n * per bin). When `getCaptureEl` is supplied, prepends a PNG item that\n * rasterises the captured element via `html2canvas`.\n */\nexport function createHistogramDownloadConfig(args: {\n filename: string\n getData: () => HistogramWidgetData\n getTicks: () => readonly number[]\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const ticks = args.getTicks()\n const seriesCount = data.length\n const header: unknown[] = ['bin_low', 'bin_high']\n for (let i = 0; i < seriesCount; i++) {\n header.push(args.seriesNames?.[i] ?? `series_${i + 1}`)\n }\n const rows: unknown[][] = [header]\n for (let bin = 0; bin < Math.max(0, ticks.length - 1); bin++) {\n const row: unknown[] = [ticks[bin], ticks[bin + 1]]\n for (let s = 0; s < seriesCount; s++) row.push(data[s]?.[bin] ?? 0)\n rows.push(row)\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n","/**\n * Histogram-specific `RelativeData` transform. Histogram data is\n * `number[][]` — each series is a flat list of bin counts. This\n * rewrites each count to its share of the series total (0–100), so\n * pairing with `createPercentFormatter` renders the y-axis as\n * percentages.\n *\n * Pass to `<Widget.RelativeData transform={toRelativeHistogramData} />`.\n *\n * The denominator is the sum of |value| across the series so mixed-sign\n * inputs produce sane signed shares-of-magnitude. A series whose total\n * magnitude is zero (all-zero or empty input) is returned unchanged so\n * a stalled or empty data set doesn't show misleading 0% values. Inputs\n * whose shape isn't `number[][]` fall through untouched (same defensive\n * shape-check pattern as the default transform).\n */\nexport const toRelativeHistogramData = (input: unknown): unknown => {\n if (!Array.isArray(input)) return input\n return input.map((series: unknown): unknown => {\n if (!isFlatNumberArray(series)) return series\n const total = series.reduce((acc, v) => acc + Math.abs(v), 0)\n if (total <= 0) return series\n return series.map((v) => (v / total) * 100)\n })\n}\n\nfunction isFlatNumberArray(v: unknown): v is number[] {\n if (!Array.isArray(v)) return false\n return v.every((item) => typeof item === 'number' && Number.isFinite(item))\n}\n"],"names":["histogramOptions","theme","formatter","niceMin","niceMax","grid","left","parseInt","spacing","top","right","buildGridConfig","containLabel","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","textStyle","color","common","white","fontSize","fontFamily","typography","caption","axisPointer","type","position","createTooltipPositioner","buildHistogramTooltipFormatter","legend","buildLegendConfig","hasLegend","lineStyle","secondary","main","Object","values","qualitative","bold","xAxis","axisLine","show","axisTick","axisLabel","margin","hideOverlap","yAxis","min","extent","niceNum","max","splitLine","black","divider","overlineDelicate","showMaxLabel","showMinLabel","verticalAlign","inside","value","String","createHistogramOptionFactory","options","ticks","series","labelFormatter","selection","optionsOverride","selectionSet","length","Set","binLabels","i","lo","hi","raw","formatNumber","push","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","seriesTemplates","broadcastTemplate","baseYAxis","baseGrid","baseTooltip","baseLegend","liveFormatter","niceMinVal","niceMaxVal","computeHistogramNiceBounds","dataZoomLayout","positionDataZoomForLegend","dataZoom","fallbackBottom","bottom","baseBottom","gridBottom","ZOOM_LAYOUT","sliderHeight","sliderGap","dimItemStyle","params","base","has","dataIndex","echarts","modifyAlpha","map","counts","source","label","_","template","overrideColor","resolveThemeColor","datasetIndex","name","encode","x","y","barCategoryGap","emphasis","focus","itemStyle","createTooltipFormatter","item","formattedValue","marker","seriesName","v","Number","isFinite","n","isInteger","toFixed","toString","styles","container","display","alignItems","justifyContent","flexDirection","gap","height","flex","width","legendItem","barSx","minWidth","HistogramSkeleton","t0","$","_c","bins","t1","undefined","T0","T1","t2","t3","t4","heights","from","t","Math","round","exp","Box","_temp","t5","jsx","t6","Symbol","for","_temp2","t7","i_1","jsxs","Skeleton","h","i_0","createHistogramDownloadConfig","args","items","getCaptureEl","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","getTicks","seriesCount","header","seriesNames","rows","bin","row","s","handle","downloadToCSV","Promise","url","revoke","toRelativeHistogramData","input","isFlatNumberArray","total","reduce","acc","abs","every"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,SAASA,EAAiB;AAAA,EAC/BC,OAAAA;AAAAA,EACAC,WAAAA;AACqB,GAA2B;AAGhD,MAAIC,IAAU,GACVC,IAAU;AAEd,SAAO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CAAM,EAAG,QAAOA;AACvC,QAAMwJ,IAAQxJ,EAAOyJ,OAAO,CAACC,GAAKlF,MAAMkF,IAAM/C,KAAKgD,IAAInF,CAAC,GAAG,CAAC;AAC5D,SAAIgF,KAAS,IAAUxJ,IAChBA,EAAOkD,IAAKsB,CAAAA,MAAOA,IAAIgF,IAAS,GAAG;AAC5C,CAAC,IANiCF;AASpC,SAASC,GAAkB/E,GAA2B;AACpD,SAAKpD,MAAMC,QAAQmD,CAAC,IACbA,EAAEoF,MAAOxF,CAAAA,MAAS,OAAOA,KAAS,YAAYK,OAAOC,SAASN,CAAI,CAAC,IAD5C;AAEhC;"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { M as
|
|
1
|
+
import { M as L, a as j, b as B } from "../markdown-BD1jcknS.js";
|
|
2
2
|
import { jsx as a } from "react/jsx-runtime";
|
|
3
3
|
import { c as p } from "react/compiler-runtime";
|
|
4
4
|
import { Box as s, Skeleton as c } from "@mui/material";
|
|
5
5
|
import "react";
|
|
6
|
-
import "@mui/icons-material
|
|
6
|
+
import "@mui/icons-material";
|
|
7
7
|
import "../lasso-tool-CDFj4zKY.js";
|
|
8
8
|
import "../cjs-D4KH3azB.js";
|
|
9
|
-
import "@
|
|
9
|
+
import "@carto/ps-utils";
|
|
10
10
|
import "html2canvas";
|
|
11
|
-
import "
|
|
12
|
-
import { b as d } from "../png-item-CS4z1iSH.js";
|
|
11
|
+
import { b as d } from "../png-item-BE9uEqlD.js";
|
|
13
12
|
const m = {
|
|
14
13
|
root: {
|
|
15
14
|
display: "flex",
|
|
@@ -22,47 +21,47 @@ const m = {
|
|
|
22
21
|
height: 18
|
|
23
22
|
})
|
|
24
23
|
};
|
|
25
|
-
function
|
|
26
|
-
const
|
|
24
|
+
function R(o) {
|
|
25
|
+
const e = p(2), {
|
|
27
26
|
lines: r
|
|
28
27
|
} = o, n = r === void 0 ? 5 : r;
|
|
29
|
-
let
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
28
|
+
let t;
|
|
29
|
+
if (e[0] !== n) {
|
|
30
|
+
const l = ["100%", "95%", "90%", "85%", "70%"];
|
|
31
|
+
t = /* @__PURE__ */ a(s, { sx: m.root, children: Array.from({
|
|
33
32
|
length: n
|
|
34
|
-
}).map((f,
|
|
33
|
+
}).map((f, i) => /* @__PURE__ */ a(c, { variant: "rectangular", sx: m.line(l[i % l.length] ?? "85%") }, `line-${i}`)) }), e[0] = n, e[1] = t;
|
|
35
34
|
} else
|
|
36
|
-
|
|
37
|
-
return
|
|
35
|
+
t = e[1];
|
|
36
|
+
return t;
|
|
38
37
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
return o.getCaptureEl &&
|
|
38
|
+
function y(o) {
|
|
39
|
+
const e = [];
|
|
40
|
+
return o.getCaptureEl && e.push(d({
|
|
42
41
|
filename: o.filename,
|
|
43
42
|
getCaptureEl: o.getCaptureEl,
|
|
44
43
|
pixelRatio: o.pngPixelRatio,
|
|
45
44
|
backgroundColor: o.pngBackgroundColor
|
|
46
|
-
})),
|
|
45
|
+
})), e.push({
|
|
47
46
|
id: "md",
|
|
48
47
|
label: "Download as Markdown",
|
|
49
48
|
resolve: () => {
|
|
50
49
|
const r = o.getData(), n = new Blob([r.content ?? ""], {
|
|
51
50
|
type: "text/markdown;charset=utf-8;"
|
|
52
|
-
}),
|
|
51
|
+
}), t = URL.createObjectURL(n);
|
|
53
52
|
return Promise.resolve({
|
|
54
|
-
url:
|
|
53
|
+
url: t,
|
|
55
54
|
filename: `${o.filename}.md`,
|
|
56
|
-
revoke: () => URL.revokeObjectURL(
|
|
55
|
+
revoke: () => URL.revokeObjectURL(t)
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
|
-
}),
|
|
58
|
+
}), e;
|
|
60
59
|
}
|
|
61
60
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
L as Markdown,
|
|
62
|
+
j as MarkdownContent,
|
|
63
|
+
R as MarkdownSkeleton,
|
|
64
|
+
B as MarkdownUI,
|
|
65
|
+
y as createMarkdownDownloadConfig
|
|
67
66
|
};
|
|
68
67
|
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sources":["../../src/widgets-v2/markdown/skeleton.tsx","../../src/widgets-v2/markdown/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 1,\n },\n line: (width: string): SxProps<Theme> => ({ width, height: 18 }),\n} as const\n\nexport interface MarkdownSkeletonProps {\n lines?: number\n}\n\nexport function MarkdownSkeleton({ lines = 5 }: MarkdownSkeletonProps) {\n // Vary widths to mimic prose.\n const widths = ['100%', '95%', '90%', '85%', '70%']\n return (\n <Box sx={styles.root}>\n {Array.from({ length: lines }).map((_, i) => (\n <Skeleton\n key={`line-${i}`}\n variant='rectangular'\n sx={styles.line(widths[i % widths.length] ?? '85%')}\n />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n toCsvString,\n triggerLinkDownload,\n type DownloadItem,\n} from '../actions/download'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Download menu items for the Markdown widget. Always includes a `.md`\n * item that saves the markdown source verbatim. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createMarkdownDownloadConfig(args: {\n filename: string\n getData: () => MarkdownWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'md',\n label: 'Download as Markdown',\n resolve: () => {\n const data = args.getData()\n const blob = new Blob([data.content ?? ''], {\n type: 'text/markdown;charset=utf-8;',\n })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.md`,\n revoke: () => URL.revokeObjectURL(url),\n })\n },\n })\n return items\n}\n\n// Re-export pure helpers consumers may want when building a custom Download item.\nexport { toCsvString, triggerLinkDownload }\n"],"names":["styles","root","display","flexDirection","gap","py","line","width","height","MarkdownSkeleton","t0","$","_c","lines","t1","undefined","t2","widths","Box","Array","from","length","map","_","i","jsx","Skeleton","createMarkdownDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","blob","Blob","content","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.js","sources":["../../src/widgets-v2/markdown/skeleton.tsx","../../src/widgets-v2/markdown/download.ts"],"sourcesContent":["import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n py: 1,\n },\n line: (width: string): SxProps<Theme> => ({ width, height: 18 }),\n} as const\n\nexport interface MarkdownSkeletonProps {\n lines?: number\n}\n\nexport function MarkdownSkeleton({ lines = 5 }: MarkdownSkeletonProps) {\n // Vary widths to mimic prose.\n const widths = ['100%', '95%', '90%', '85%', '70%']\n return (\n <Box sx={styles.root}>\n {Array.from({ length: lines }).map((_, i) => (\n <Skeleton\n key={`line-${i}`}\n variant='rectangular'\n sx={styles.line(widths[i % widths.length] ?? '85%')}\n />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n toCsvString,\n triggerLinkDownload,\n type DownloadItem,\n} from '../actions/download'\nimport type { MarkdownWidgetData } from './types'\n\n/**\n * Download menu items for the Markdown widget. Always includes a `.md`\n * item that saves the markdown source verbatim. When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createMarkdownDownloadConfig(args: {\n filename: string\n getData: () => MarkdownWidgetData\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'md',\n label: 'Download as Markdown',\n resolve: () => {\n const data = args.getData()\n const blob = new Blob([data.content ?? ''], {\n type: 'text/markdown;charset=utf-8;',\n })\n const url = URL.createObjectURL(blob)\n return Promise.resolve({\n url,\n filename: `${args.filename}.md`,\n revoke: () => URL.revokeObjectURL(url),\n })\n },\n })\n return items\n}\n\n// Re-export pure helpers consumers may want when building a custom Download item.\nexport { toCsvString, triggerLinkDownload }\n"],"names":["styles","root","display","flexDirection","gap","py","line","width","height","MarkdownSkeleton","t0","$","_c","lines","t1","undefined","t2","widths","Box","Array","from","length","map","_","i","jsx","Skeleton","createMarkdownDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","backgroundColor","pngBackgroundColor","id","label","resolve","data","getData","blob","Blob","content","type","url","URL","createObjectURL","Promise","revoke","revokeObjectURL"],"mappings":";;;;;;;;;;;AAGA,MAAMA,IAAS;AAAA,EACbC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,IAAI;AAAA,EAAA;AAAA,EAENC,MAAMA,CAACC,OAAmC;AAAA,IAAEA,OAAAA;AAAAA,IAAOC,QAAQ;AAAA,EAAA;AAC7D;AAMO,SAAAC,EAAAC,GAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAA0B;AAAA,IAAAC,OAAAC;AAAAA,EAAAA,IAAAJ,GAAEG,IAAAC,MA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 +10,19 @@ import "react";
|
|
|
10
10
|
import "html2canvas";
|
|
11
11
|
import "../lasso-tool-CDFj4zKY.js";
|
|
12
12
|
import "../cjs-D4KH3azB.js";
|
|
13
|
+
import "@carto/ps-utils";
|
|
13
14
|
import "@dnd-kit/core";
|
|
14
15
|
import "@dnd-kit/sortable";
|
|
15
16
|
import "@dnd-kit/utilities";
|
|
16
17
|
import "react-dom";
|
|
17
18
|
import { m as V, r as D } from "../resolve-theme-color-BdojIw0K.js";
|
|
18
|
-
import "@mui/icons-material/ZoomIn";
|
|
19
19
|
import "../widget-context-DTGO0Yta.js";
|
|
20
20
|
import "zustand";
|
|
21
21
|
import "zustand/vanilla";
|
|
22
22
|
import "zustand/middleware";
|
|
23
23
|
import "zustand/react/shallow";
|
|
24
|
-
import "@mui/icons-material/FileDownload";
|
|
25
24
|
import { a as M } from "../exports-Cx-f6m6U.js";
|
|
26
|
-
import "
|
|
27
|
-
import { b as z } from "../png-item-CS4z1iSH.js";
|
|
25
|
+
import { b as z } from "../png-item-BE9uEqlD.js";
|
|
28
26
|
const B = ["58%", "74%"];
|
|
29
27
|
function _({
|
|
30
28
|
theme: e,
|
|
@@ -103,7 +101,7 @@ function _({
|
|
|
103
101
|
}]
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
|
-
function
|
|
104
|
+
function ye(e) {
|
|
107
105
|
const {
|
|
108
106
|
theme: r,
|
|
109
107
|
formatter: t,
|
|
@@ -340,7 +338,7 @@ const F = {
|
|
|
340
338
|
borderRadius: "50%"
|
|
341
339
|
}
|
|
342
340
|
};
|
|
343
|
-
function
|
|
341
|
+
function be(e) {
|
|
344
342
|
const r = O(2), {
|
|
345
343
|
count: t
|
|
346
344
|
} = e, n = t === void 0 ? 1 : t;
|
|
@@ -352,7 +350,7 @@ function he(e) {
|
|
|
352
350
|
function G(e, r) {
|
|
353
351
|
return /* @__PURE__ */ I($, { variant: "circular", sx: F.donut }, `donut-${r}`);
|
|
354
352
|
}
|
|
355
|
-
function
|
|
353
|
+
function ve(e) {
|
|
356
354
|
const r = [];
|
|
357
355
|
return e.getCaptureEl && r.push(z({
|
|
358
356
|
filename: e.filename,
|
|
@@ -379,9 +377,9 @@ function Se(e) {
|
|
|
379
377
|
}), r;
|
|
380
378
|
}
|
|
381
379
|
export {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
be as PieSkeleton,
|
|
381
|
+
ve as createPieDownloadConfig,
|
|
382
|
+
ye as createPieOptionFactory,
|
|
385
383
|
_ as pieOptions
|
|
386
384
|
};
|
|
387
385
|
//# sourceMappingURL=pie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie.js","sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Pie reads better with a centered legend (the donut is radially\n // symmetric — left-aligning the legend below it visually unbalances\n // the chart). Override `buildLegendConfig`'s `type: 'scroll'` with\n // `'plain'` so long category lists wrap to multiple rows instead\n // of clipping the last visible item against the chart container.\n // The wider `itemGap` gives chips breathing room in the typical\n // 3–6 category case.\n left: 'center',\n type: 'scroll',\n itemGap: 16,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n const colorFn = (params: CallbackDataParams): string => {\n const base = resolvePaletteColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Center label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n return `{c|${formattedValue}}\\n\\n{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: colorFn,\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n legend: { ...baseLegend, show: true },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const barColorFn = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n const base = (seriesSwatch ?? params.color) as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: { color: barColorFn },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n legend: { ...baseLegend, show: true },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: 2,\n },\n donut: {\n width: 160,\n height: 160,\n borderRadius: '50%',\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\nexport function PieSkeleton({ count = 1 }: PieSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`donut-${i}`} variant='circular' sx={styles.donut} />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: () => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","buildLegendConfig","hasLegend","left","type","itemGap","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","createTooltipPositioner","buildPieTooltipFormatter","Object","values","qualitative","bold","series","colorBy","avoidLabelOverlap","selectedOffset","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","dataIndex","undefined","colorFn","base","name","value","has","echarts","modifyAlpha","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","map","s","source","_","i","template","templateObj","templateLabel","templateItemStyle","datasetIndex","center","itemName","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","barColorFn","seriesIdx","seriesIndex","buildGridConfig","right","containLabel","overrideColor","resolveThemeColor","barMaxWidth","focus","buildSeriesLabelConfig","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","buildHorizontalBarTooltipFormatter","createTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","d","Number","isFinite","niceNum","styles","root","display","alignItems","justifyContent","minHeight","py","gap","donut","width","height","borderRadius","PieSkeleton","t0","$","_c","count","t1","t2","Box","from","_temp","jsx","Skeleton","createPieDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","rows","entries","seriesNames","slice","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,IAA4C,CAAC,OAAO,KAAK;AAiBxD,SAASC,EAAW;AAAA,EACzBC,OAAAA;AAAA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,KAAK,UAAUA,IAAI,CAAC;AAC3D,mBAAW6F,KAAS3J;AAClBwJ,UAAAA,EAAKT,KAAK,CAACjC,GAAY6C,EAAM7G,MAAM6G,EAAM5G,KAAK,CAAC;AAAA,MAEnD;AACA,YAAM6G,IAASC,EAAcL,CAAI;AACjC,aAAOM,QAAQR,QAAQ;AAAA,QACrBS,KAAKH,EAAOG;AAAAA,QACZd,UAAU,GAAGL,EAAKK,QAAQ;AAAA,QAC1Be,QAAQJ,EAAOI;AAAAA,MAAAA,CAChB;AAAA,IACH;AAAA,EAAA,CACD,GACMnB;AACT;"}
|
|
1
|
+
{"version":3,"file":"pie.js","sources":["../../src/widgets-v2/pie/options.ts","../../src/widgets-v2/pie/skeleton.tsx","../../src/widgets-v2/pie/download.ts"],"sourcesContent":["import type { Theme } from '@mui/material'\nimport type { EChartsOption } from 'echarts'\nimport * as echarts from 'echarts'\nimport type { CallbackDataParams } from 'echarts/types/dist/shared'\nimport {\n buildGridConfig,\n buildLegendConfig,\n buildSeriesLabelConfig,\n createTooltipFormatter,\n createTooltipPositioner,\n niceNum,\n} from '../../widgets/utils/chart-config'\nimport type { OptionFactory, OptionFactoryContext } from '../echart'\nimport { mergeOptions, resolveThemeColor } from '../utils'\nimport type { WidgetSeries } from '../types'\nimport type {\n PieEChartsOption,\n PieOptionFactoryInput,\n PieOptionsInput,\n PieWidgetData,\n} from './types'\n\nconst DEFAULT_RADIUS: readonly [string, string] = ['58%', '74%']\n\n/**\n * Builds the **structural** ECharts option for a pie / donut widget.\n * Mirrors v1's pie look-and-feel: themed legend (`buildLegendConfig`),\n * themed tooltip via `createTooltipPositioner` / `createTooltipFormatter`,\n * `qualitative.bold` color palette, slice borders against the paper\n * background, hover-emphasis disabled, and a centered rich-text label.\n *\n * Layered like Bar / Histogram:\n * - **Theme-aware bits** live here on a series template (slice border,\n * center-label rich style sizes, emphasis-disabled).\n * - **Reactive bits** (tooltip value formatter, center-label text,\n * selection-driven dim) are re-emitted by\n * {@link createPieOptionFactory} at fusion time so RelativeData's\n * percent override flows through.\n */\nexport function pieOptions({\n theme,\n formatter,\n labelFormatter,\n}: PieOptionsInput): PieEChartsOption {\n return {\n legend: {\n ...buildLegendConfig({ hasLegend: true, labelFormatter }),\n // Pie reads better with a centered legend (the donut is radially\n // symmetric — left-aligning the legend below it visually unbalances\n // the chart). Override `buildLegendConfig`'s `type: 'scroll'` with\n // `'plain'` so long category lists wrap to multiple rows instead\n // of clipping the last visible item against the chart container.\n // The wider `itemGap` gives chips breathing room in the typical\n // 3–6 category case.\n left: 'center',\n type: 'scroll',\n itemGap: 16,\n },\n tooltip: {\n // Pie uses item-trigger (no axis); the rest of the styling mirrors\n // bar/histogram so the dashboard reads consistently — dark\n // grey[900] bg, white caption-font text, padded, with the shared\n // overflow-aware positioner.\n trigger: 'item',\n backgroundColor: theme.palette.grey[900],\n borderWidth: 0,\n padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))],\n textStyle: {\n color: theme.palette.common.white,\n fontSize: 11,\n fontFamily: theme.typography.caption.fontFamily,\n },\n position: createTooltipPositioner(theme),\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n // V1 used `qualitative.bold` only (no `secondary.main` prefix) because\n // pie slices are categorical — each slice deserves a distinct palette\n // entry from the start, not a primary highlight.\n color: Object.values(\n (theme.palette as { qualitative?: { bold?: Record<string, string> } })\n .qualitative?.bold ?? {},\n ),\n // Pie template. The merger spreads this into each per-data series it\n // emits — borderColor / borderWidth / emphasis-disabled / label rich\n // sizes all survive through.\n series: [\n {\n type: 'pie',\n colorBy: 'data',\n avoidLabelOverlap: true,\n selectedOffset: 0,\n emphasis: { disabled: true },\n itemStyle: {\n borderColor: theme.palette.background.paper,\n borderWidth: 1,\n },\n label: {\n show: true,\n position: 'center',\n rich: {\n b: { fontSize: 16, fontWeight: 'normal', lineHeight: 20 },\n c: { fontSize: 28, fontWeight: 'bold', lineHeight: 27 },\n },\n },\n },\n ],\n }\n}\n\n/**\n * Returns the pie widget's {@link OptionFactory} — one closure that owns\n * BOTH phases of option construction:\n *\n * - **Structural phase** (`option == null`) — builds the theme-aware\n * structural option via {@link pieOptions}, optionally merging the\n * consumer-supplied `optionsOverride` on top. Called once by Provider\n * to seed `rawOptions` in the store.\n * - **Merge phase** (`option != null`) — fuses post-pipeline `state.data`\n * (`PieWidgetData`) into the option via the dataset API. Single-series\n * → donut (one dataset, `series[i].encode = { itemName: 'name', value: 'value' }`).\n * Multi-series → horizontal-bar fallback (mirrors v1 pie). Reactive\n * formatters from `ctx` drive the tooltip + center label at fusion\n * time so RelativeData's percent formatter flows through without a\n * structural rebuild.\n */\nexport function createPieOptionFactory(\n options: PieOptionFactoryInput,\n): OptionFactory {\n const { theme, formatter, labelFormatter, optionsOverride, series } = options\n const radius = options.radius ?? DEFAULT_RADIUS\n const selection = options.selection\n const selectionSet =\n selection && selection.length > 0\n ? new Set<string | number>(selection)\n : null\n return (option, data, ctx) => {\n if (option == null) {\n const structural = pieOptions({ theme, formatter, labelFormatter })\n return optionsOverride\n ? (mergeOptions(\n structural as unknown as Record<string, unknown>,\n optionsOverride as Partial<Record<string, unknown>>,\n ) as EChartsOption)\n : structural\n }\n\n const seriesArr = Array.isArray(data) ? (data as PieWidgetData) : []\n if (seriesArr.length === 0) {\n return { ...option, dataset: [], series: [] }\n }\n if (seriesArr.length > 1) {\n return buildMultiSeriesBarFusion(\n option,\n seriesArr,\n theme,\n series,\n ctx,\n selectionSet,\n )\n }\n return buildSingleSeriesPieFusion(\n option,\n seriesArr,\n radius,\n series,\n ctx,\n selectionSet,\n )\n }\n}\n\n/**\n * Single-series donut fusion. Spreads the structural pie series template\n * into per-data series with center/radius/encoding, wires the reactive\n * center-label / tooltip formatters and the per-data palette-aware\n * selection-dim callback.\n */\nfunction buildSingleSeriesPieFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n radius: readonly [string, string],\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const seriesTemplates = Array.isArray(option.series) ? option.series : []\n const broadcastTemplate = seriesTemplates[0] ?? {}\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n // Pie wants `colorBy: 'data'` — each slice draws from the option's\n // `color` palette by data index. But installing an `itemStyle.color`\n // callback disables ECharts' automatic per-data cycling, and\n // `params.color` collapses to the series color (so every slice goes\n // the same color). We re-implement the per-data palette resolution\n // here so the multicolor look survives selection-driven dimming.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const resolvePaletteColor = (params: CallbackDataParams): string => {\n const swatch =\n palette.length > 0\n ? palette[params.dataIndex % palette.length]\n : undefined\n return swatch ?? (params.color as string)\n }\n\n // Always emit `itemStyle.color` (passthrough when nothing is selected),\n // not conditionally — same anti-stale-callback rationale as bar /\n // histogram. The slice border + width come from the structural\n // template's `itemStyle` and survive via the spread below.\n const colorFn = (params: CallbackDataParams): string => {\n const base = resolvePaletteColor(params)\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n // Center label formatter — lives in the merger because it reads\n // reactive `formatter` / `labelFormatter` from ctx. The rich tags\n // `{c|…}` and `{b|…}` reference the rich styles baked into the\n // structural label template.\n const labelTextFormatter = (params: CallbackDataParams): string => {\n const { name } = params\n const encodeIndex = params.encode?.value?.[0]\n if (encodeIndex === undefined) return ''\n const value = (Object.values(params.data ?? {}) as unknown[]).at(\n encodeIndex,\n )\n // `value` here is the resolved dataset cell — for pie data it's a\n // `string | number` primitive. Anything else is a misuse we won't\n // dress up with `String(...)` (would render \"[object Object]\").\n const formattedValue =\n typeof value === 'number'\n ? formatter\n ? formatter(value)\n : String(value)\n : typeof value === 'string'\n ? value\n : ''\n const formattedName = labelFormatter\n ? String(labelFormatter(name ?? ''))\n : String(name ?? '')\n return `{c|${formattedValue}}\\n\\n{b|${formattedName}}`\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n series: seriesArr.map((_, i) => {\n const template =\n (seriesTemplates[i] as object | undefined) ??\n (broadcastTemplate as object)\n const templateObj = typeof template === 'object' ? template : {}\n const templateLabel = (templateObj as { label?: object }).label ?? {}\n const templateItemStyle =\n (templateObj as { itemStyle?: object }).itemStyle ?? {}\n return {\n ...templateObj,\n type: 'pie' as const,\n datasetIndex: i,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n radius: [...radius],\n // Lift the donut up so the bottom-anchored legend has the\n // vertical real estate to wrap to multiple rows for long\n // category lists — at exactly `50%` the bottom slices crowd\n // the chips and `type: 'plain'` legends can't expand upward\n // without overlapping the donut.\n center: ['50%', '38%'] as [string, string],\n encode: { itemName: 'name', value: 'value' },\n label: {\n ...templateLabel,\n formatter: labelTextFormatter,\n },\n itemStyle: {\n ...templateItemStyle,\n color: colorFn,\n },\n }\n }),\n // Legend always shows for pie (mirrors v1) — slice names drive the\n // entries, so even a single donut benefits from a category list.\n legend: { ...baseLegend, show: true },\n tooltip: {\n ...baseTooltip,\n formatter: buildPieTooltipFormatter(formatter, labelFormatter),\n },\n }\n}\n\n/**\n * Multi-series horizontal-bar fusion. Mirrors v1 pie's \"pie data with\n * >1 series collapses into a horizontal bar chart\" behavior — side-by-\n * side donuts don't read well when you're comparing the same categories\n * across cohorts, so swap to a value-on-x / category-on-y bar layout.\n *\n * Pie data shape is identical to bar's (`{ name, value }[][]`), so the\n * same dataset feeds either layout without transformation.\n */\nfunction buildMultiSeriesBarFusion(\n option: EChartsOption,\n seriesArr: PieWidgetData,\n theme: Theme,\n series: readonly WidgetSeries[] | undefined,\n ctx: OptionFactoryContext | undefined,\n selectionSet: Set<string | number> | null,\n): EChartsOption {\n const baseTooltip =\n typeof option.tooltip === 'object' && !Array.isArray(option.tooltip)\n ? option.tooltip\n : {}\n const baseLegend =\n typeof option.legend === 'object' && !Array.isArray(option.legend)\n ? option.legend\n : {}\n const baseGrid =\n typeof option.grid === 'object' && !Array.isArray(option.grid)\n ? option.grid\n : {}\n const formatter = ctx?.formatter\n const labelFormatter = ctx?.labelFormatter\n\n const { niceMinVal, niceMaxVal } = computeNiceBounds(seriesArr)\n\n // Per-series palette — multi-series bars take one color per series\n // (not per-data, unlike donut slices). Same anti-stale-callback rule:\n // always emit the callback so a transition to/from a selection\n // replaces the previous closure cleanly.\n const palette = Array.isArray(option.color)\n ? (option.color as readonly (string | undefined)[])\n : []\n const barColorFn = (params: CallbackDataParams): string => {\n const seriesIdx = params.seriesIndex ?? 0\n const seriesSwatch =\n palette.length > 0 ? palette[seriesIdx % palette.length] : undefined\n const base = (seriesSwatch ?? params.color) as string\n if (!selectionSet) return base\n const datum = params.value as { name?: string | number } | undefined\n const name = datum?.name ?? params.name\n return name != null && selectionSet.has(name)\n ? base\n : echarts.color.modifyAlpha(base, 0.15)\n }\n\n return {\n ...option,\n dataset: seriesArr.map((s) => ({ source: s as readonly object[] })),\n grid: {\n ...baseGrid,\n ...buildGridConfig(true, theme),\n right: parseInt(theme.spacing(4)),\n containLabel: true,\n },\n // Drop pie-specific structural keys that shouldn't render in the\n // bar fallback. ECharts ignores undefined keys, so this is a clean\n // override.\n series: seriesArr.map((_, i) => {\n const overrideColor = resolveThemeColor(theme, series?.[i]?.color)\n return {\n datasetIndex: i,\n type: 'bar' as const,\n name: series?.[i]?.name ?? `Series ${i + 1}`,\n barMaxWidth: 100,\n emphasis: { focus: 'series' },\n ...buildSeriesLabelConfig(formatter, 'x'),\n itemStyle: { color: barColorFn },\n ...(overrideColor ? { color: overrideColor } : {}),\n }\n }),\n xAxis: {\n type: 'value',\n // Closures over the pre-computed nice bounds — ECharts calls them\n // once per render to resolve the axis extents.\n min: () => niceMinVal,\n max: () => niceMaxVal,\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: {\n show: true,\n lineStyle: { color: theme.palette.black?.[4] ?? theme.palette.divider },\n },\n // Value labels render BELOW the axis line (default placement),\n // NOT inside the plot. Bar/histogram use `inside: true` +\n // `verticalAlign: 'bottom'` for their *vertical* y-axis where the\n // axis is the left wall — labels inside read like grid annotations.\n // A horizontal bar chart's value axis is the x-axis, and `inside`\n // there pushes the max label *behind* the bar (it visually\n // disappears once a bar reaches the right edge). Use the default\n // below-the-axis placement so the rounded extents stay readable.\n axisLabel: {\n fontSize: theme.typography.overlineDelicate?.fontSize,\n fontFamily: theme.typography.overlineDelicate?.fontFamily,\n margin: parseInt(theme.spacing(1)),\n showMaxLabel: true,\n showMinLabel: true,\n formatter: (value: number) => {\n if (value !== niceMaxVal && value !== niceMinVal) return ''\n if (value === 0) return ''\n return formatter ? formatter(value) : String(value)\n },\n },\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],\n ...(labelFormatter && {\n formatter: (value: string | number) => String(labelFormatter(value)),\n }),\n },\n },\n legend: { ...baseLegend, show: true },\n tooltip: {\n ...baseTooltip,\n trigger: 'axis',\n formatter: buildHorizontalBarTooltipFormatter(formatter, labelFormatter),\n },\n } as EChartsOption\n}\n\n/**\n * Tooltip formatter for the horizontal-bar fallback. Reads the value by\n * `encode.x` dimension index (v1 parity) so it stays robust to\n * downstream changes that rename dataset columns.\n */\nfunction buildHorizontalBarTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.x?.at(0)\n const dimName =\n encodeIndex !== undefined ? item.dimensionNames?.[encodeIndex] : undefined\n const row =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (item.value as Record<string, string | number>)\n : undefined\n const raw = dimName && row ? row[dimName] : undefined\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n\n/**\n * Min/max bounds over every datum's `.value` across all series. Used by\n * the horizontal-bar fallback's x-axis label formatter so we only render\n * labels at the rounded extents (matches v1 + bar / histogram).\n */\nfunction computeNiceBounds(seriesArr: PieWidgetData): {\n niceMinVal: number\n niceMaxVal: number\n} {\n let min = 0\n let max = -Infinity\n for (const series of seriesArr) {\n for (const d of series) {\n if (typeof d?.value !== 'number' || !Number.isFinite(d.value)) continue\n if (d.value < min) min = d.value\n if (d.value > max) max = d.value\n }\n }\n return {\n niceMinVal: min < 0 ? niceNum(min) : 0,\n niceMaxVal: max <= 0 ? 1 : niceNum(max),\n }\n}\n\n/**\n * Tooltip formatter for pie slices. `item.value` is the dataset row\n * object (e.g. `{ name: 'A', value: 10 }`); we pull the value by\n * `encode.value`'s dimension index, formatted via the reactive `formatter`\n * if present. Slice name passes through `labelFormatter`.\n */\nfunction buildPieTooltipFormatter(\n formatter: ((value: number) => string) | undefined,\n labelFormatter: ((value: string | number) => string | number) | undefined,\n) {\n return createTooltipFormatter((item) => {\n const encodeIndex = item.encode?.value?.at(0) ?? 1\n const values =\n item.value && typeof item.value === 'object' && !Array.isArray(item.value)\n ? (Object.values(item.value) as (string | number)[])\n : []\n const raw = values[encodeIndex]\n const formattedValue =\n typeof raw === 'number' && formatter ? formatter(raw) : (raw ?? '')\n const marker = typeof item.marker === 'string' ? item.marker : ''\n const seriesName = item.seriesName ? `${item.seriesName}: ` : ''\n const name = labelFormatter\n ? String(labelFormatter(item.name ?? ''))\n : String(item.name ?? '')\n return { name, seriesName, marker, value: formattedValue }\n })\n}\n","import { Box, Skeleton } from '@mui/material'\nimport type { SxProps, Theme } from '@mui/material'\n\nconst styles = {\n root: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 200,\n py: 1,\n gap: 2,\n },\n donut: {\n width: 160,\n height: 160,\n borderRadius: '50%',\n },\n} satisfies Record<string, SxProps<Theme>>\n\nexport interface PieSkeletonProps {\n count?: number\n}\n\nexport function PieSkeleton({ count = 1 }: PieSkeletonProps) {\n return (\n <Box sx={styles.root}>\n {Array.from({ length: count }).map((_, i) => (\n <Skeleton key={`donut-${i}`} variant='circular' sx={styles.donut} />\n ))}\n </Box>\n )\n}\n","import {\n buildPngDownloadItem,\n downloadToCSV,\n type DownloadItem,\n} from '../actions/download'\nimport type { PieWidgetData } from './types'\n\n/**\n * Download menu items for the Pie widget. Always includes a CSV item with\n * `series, name, value` columns (one row per slice; series labels come from\n * `seriesNames` if provided, else `series_<n>`). When `getCaptureEl` is\n * supplied, prepends a PNG item that rasterises the captured element via\n * `html2canvas`.\n */\nexport function createPieDownloadConfig(args: {\n filename: string\n getData: () => PieWidgetData\n seriesNames?: readonly string[]\n getCaptureEl?: () => HTMLElement | null\n pngPixelRatio?: number\n pngBackgroundColor?: string | null\n}): DownloadItem[] {\n const items: DownloadItem[] = []\n if (args.getCaptureEl) {\n items.push(\n buildPngDownloadItem({\n filename: args.filename,\n getCaptureEl: args.getCaptureEl,\n pixelRatio: args.pngPixelRatio,\n backgroundColor: args.pngBackgroundColor,\n }),\n )\n }\n items.push({\n id: 'csv',\n label: 'Download as CSV',\n resolve: () => {\n const data = args.getData()\n const rows: unknown[][] = [['series', 'name', 'value']]\n for (const [i, series] of data.entries()) {\n const seriesName = args.seriesNames?.[i] ?? `series_${i + 1}`\n for (const slice of series) {\n rows.push([seriesName, slice.name, slice.value])\n }\n }\n const handle = downloadToCSV(rows)\n return Promise.resolve({\n url: handle.url,\n filename: `${args.filename}.csv`,\n revoke: handle.revoke,\n })\n },\n })\n return items\n}\n"],"names":["DEFAULT_RADIUS","pieOptions","theme","formatter","labelFormatter","legend","buildLegendConfig","hasLegend","left","type","itemGap","tooltip","trigger","backgroundColor","palette","grey","borderWidth","padding","parseInt","spacing","textStyle","color","common","white","fontSize","fontFamily","typography","caption","position","createTooltipPositioner","buildPieTooltipFormatter","Object","values","qualitative","bold","series","colorBy","avoidLabelOverlap","selectedOffset","emphasis","disabled","itemStyle","borderColor","background","paper","label","show","rich","b","fontWeight","lineHeight","c","createPieOptionFactory","options","optionsOverride","radius","selection","selectionSet","length","Set","option","data","ctx","structural","mergeOptions","seriesArr","Array","isArray","dataset","buildMultiSeriesBarFusion","buildSingleSeriesPieFusion","seriesTemplates","broadcastTemplate","baseTooltip","baseLegend","resolvePaletteColor","params","dataIndex","undefined","colorFn","base","name","value","has","echarts","modifyAlpha","labelTextFormatter","encodeIndex","encode","at","formattedValue","String","formattedName","map","s","source","_","i","template","templateObj","templateLabel","templateItemStyle","datasetIndex","center","itemName","baseGrid","grid","niceMinVal","niceMaxVal","computeNiceBounds","barColorFn","seriesIdx","seriesIndex","buildGridConfig","right","containLabel","overrideColor","resolveThemeColor","barMaxWidth","focus","buildSeriesLabelConfig","xAxis","min","max","axisLine","axisTick","splitLine","lineStyle","black","divider","axisLabel","overlineDelicate","margin","showMaxLabel","showMinLabel","yAxis","buildHorizontalBarTooltipFormatter","createTooltipFormatter","item","x","dimName","dimensionNames","row","raw","marker","seriesName","d","Number","isFinite","niceNum","styles","root","display","alignItems","justifyContent","minHeight","py","gap","donut","width","height","borderRadius","PieSkeleton","t0","$","_c","count","t1","t2","Box","from","_temp","jsx","Skeleton","createPieDownloadConfig","args","items","getCaptureEl","push","buildPngDownloadItem","filename","pixelRatio","pngPixelRatio","pngBackgroundColor","id","resolve","getData","rows","entries","seriesNames","slice","handle","downloadToCSV","Promise","url","revoke"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,IAA4C,CAAC,OAAO,KAAK;AAiBxD,SAASC,EAAW;AAAA,EACzBC,OAAAA;AAAAA,EACAC,WAAAA;AAAAA,E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