@carto/ps-react-ui 4.4.2 → 4.4.3
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/download-config-Dqu78h2a.js +57 -0
- package/dist/download-config-Dqu78h2a.js.map +1 -0
- package/dist/formatter-B9Bxn1k7.js +6 -0
- package/dist/formatter-B9Bxn1k7.js.map +1 -0
- package/dist/styles-Y8q7Jff3.js +118 -0
- package/dist/styles-Y8q7Jff3.js.map +1 -0
- package/dist/types/widgets/actions/brush-toggle/types.d.ts +8 -2
- package/dist/types/widgets/category/components/category-row-multi.d.ts +2 -1
- package/dist/types/widgets/category/components/category-row-single.d.ts +2 -1
- package/dist/types/widgets/category/types.d.ts +1 -0
- package/dist/types/widgets/echart/types.d.ts +2 -0
- package/dist/types/widgets/histogram/config.d.ts +15 -3
- package/dist/types/widgets/histogram/index.d.ts +2 -1
- package/dist/types/widgets/histogram/types.d.ts +6 -3
- package/dist/types/widgets/stores/types.d.ts +2 -0
- package/dist/types/widgets/utils/chart-config/index.d.ts +1 -1
- package/dist/types/widgets/utils/chart-config/option-builders.d.ts +13 -8
- package/dist/types/widgets/utils/formatter.d.ts +1 -0
- package/dist/types/widgets/utils/index.d.ts +1 -1
- package/dist/widgets/actions.js +455 -439
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +52 -46
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +206 -197
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/formula.js +1 -1
- package/dist/widgets/histogram.js +119 -79
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/pie.js +110 -98
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/range.js +1 -1
- package/dist/widgets/scatterplot.js +49 -43
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/spread.js +1 -1
- package/dist/widgets/timeseries.js +51 -45
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/toolbar-actions.js +101 -6693
- package/dist/widgets/toolbar-actions.js.map +1 -1
- package/dist/widgets/utils.js +16 -14
- package/dist/widgets/utils.js.map +1 -1
- package/package.json +5 -4
- package/src/widgets/README.md +3 -3
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +42 -47
- package/src/widgets/actions/brush-toggle/types.ts +8 -2
- package/src/widgets/bar/config.ts +22 -14
- package/src/widgets/category/category-ui.tsx +9 -1
- package/src/widgets/category/components/category-row-multi.tsx +6 -2
- package/src/widgets/category/components/category-row-single.tsx +5 -1
- package/src/widgets/category/types.ts +1 -0
- package/src/widgets/echart/types.ts +2 -0
- package/src/widgets/histogram/config.ts +101 -20
- package/src/widgets/histogram/index.ts +6 -1
- package/src/widgets/histogram/types.ts +9 -3
- package/src/widgets/pie/config.ts +17 -5
- package/src/widgets/scatterplot/config.ts +8 -3
- package/src/widgets/stores/types.ts +2 -0
- package/src/widgets/timeseries/config.ts +21 -13
- package/src/widgets/utils/chart-config/index.ts +1 -1
- package/src/widgets/utils/chart-config/option-builders.ts +22 -12
- package/src/widgets/utils/formatter.ts +2 -1
- package/src/widgets/utils/index.ts +1 -1
- package/dist/formatter-B1Xh8XDH.js +0 -5
- package/dist/formatter-B1Xh8XDH.js.map +0 -1
- package/dist/styles-C_8vOEep.js +0 -167
- package/dist/styles-C_8vOEep.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EchartWidgetState } from '../echart'
|
|
2
2
|
import type {
|
|
3
3
|
EchartWidgetOptionProps,
|
|
4
4
|
EchartWidgetProps,
|
|
5
5
|
} from '../echart/types'
|
|
6
6
|
import type { ConfigProps } from '../loader'
|
|
7
7
|
|
|
8
|
-
export type HistogramWidgetData =
|
|
8
|
+
export type HistogramWidgetData = number[][]
|
|
9
9
|
|
|
10
10
|
export type HistogramWidgetState = EchartWidgetState
|
|
11
11
|
|
|
@@ -14,4 +14,10 @@ export type HistogramWidgetConfig = EchartWidgetProps & {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type HistogramConfig = ConfigProps &
|
|
17
|
-
|
|
17
|
+
Pick<
|
|
18
|
+
EchartWidgetOptionProps<unknown>,
|
|
19
|
+
'theme' | 'formatter' | 'labelFormatter'
|
|
20
|
+
> & {
|
|
21
|
+
data?: number[][]
|
|
22
|
+
ticks: number[]
|
|
23
|
+
}
|
|
@@ -29,6 +29,7 @@ export function pieConfig(props: PieConfig): PieWidgetConfig {
|
|
|
29
29
|
type: 'pie',
|
|
30
30
|
option: mergeEchartWidgetConfig(getCommonOptions(props), getOption(props)),
|
|
31
31
|
formatter: props.formatter,
|
|
32
|
+
labelFormatter: props.labelFormatter,
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -36,6 +37,7 @@ function getOption({
|
|
|
36
37
|
data = [],
|
|
37
38
|
theme,
|
|
38
39
|
formatter,
|
|
40
|
+
labelFormatter,
|
|
39
41
|
}: PieConfig): EchartOptionsProps {
|
|
40
42
|
const multiSeries = (data?.length ?? 0) > 1
|
|
41
43
|
|
|
@@ -44,7 +46,7 @@ function getOption({
|
|
|
44
46
|
let niceMax = 1
|
|
45
47
|
|
|
46
48
|
return {
|
|
47
|
-
legend: buildLegendConfig(true),
|
|
49
|
+
legend: buildLegendConfig({ hasLegend: true, labelFormatter }),
|
|
48
50
|
grid: {
|
|
49
51
|
...buildGridConfig(true, theme),
|
|
50
52
|
right: parseInt(theme.spacing(4)),
|
|
@@ -97,6 +99,10 @@ function getOption({
|
|
|
97
99
|
},
|
|
98
100
|
axisLabel: {
|
|
99
101
|
padding: [parseInt(theme.spacing(0.5)), 0, 0, 0],
|
|
102
|
+
...(labelFormatter && {
|
|
103
|
+
formatter: (value: string | number) =>
|
|
104
|
+
String(labelFormatter(value)),
|
|
105
|
+
}),
|
|
100
106
|
},
|
|
101
107
|
},
|
|
102
108
|
tooltip: {
|
|
@@ -113,7 +119,9 @@ function getOption({
|
|
|
113
119
|
|
|
114
120
|
const marker = typeof item.marker === 'string' ? item.marker : ''
|
|
115
121
|
const seriesName = item.seriesName ? `${item.seriesName}: ` : ''
|
|
116
|
-
const name =
|
|
122
|
+
const name = labelFormatter
|
|
123
|
+
? String(labelFormatter(item.name ?? ''))
|
|
124
|
+
: (item.name ?? '')
|
|
117
125
|
|
|
118
126
|
return { name, seriesName, marker, value: formattedValue }
|
|
119
127
|
}),
|
|
@@ -132,7 +140,7 @@ function getOption({
|
|
|
132
140
|
const hasLegend = true
|
|
133
141
|
|
|
134
142
|
return {
|
|
135
|
-
legend: buildLegendConfig(hasLegend),
|
|
143
|
+
legend: buildLegendConfig({ hasLegend, labelFormatter }),
|
|
136
144
|
grid: {
|
|
137
145
|
...buildGridConfig(hasLegend, theme),
|
|
138
146
|
left: 0,
|
|
@@ -164,7 +172,9 @@ function getOption({
|
|
|
164
172
|
|
|
165
173
|
const marker = typeof item.marker === 'string' ? item.marker : ''
|
|
166
174
|
const seriesName = item.seriesName ? `${item.seriesName}: ` : ''
|
|
167
|
-
const name =
|
|
175
|
+
const name = labelFormatter
|
|
176
|
+
? String(labelFormatter(item.name ?? ''))
|
|
177
|
+
: (item.name ?? '')
|
|
168
178
|
|
|
169
179
|
return {
|
|
170
180
|
name: seriesName,
|
|
@@ -203,7 +213,9 @@ function getOption({
|
|
|
203
213
|
? formatter(value)
|
|
204
214
|
: (value ?? '')
|
|
205
215
|
|
|
206
|
-
const nameFormatted =
|
|
216
|
+
const nameFormatted = labelFormatter
|
|
217
|
+
? String(labelFormatter(name ?? ''))
|
|
218
|
+
: (name ?? '')
|
|
207
219
|
|
|
208
220
|
return `{c|${formattedValue}}\n\n{b|${nameFormatted}}`
|
|
209
221
|
},
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
createTooltipFormatter,
|
|
15
15
|
createChartDownloadConfig,
|
|
16
16
|
applyYAxisFormatter,
|
|
17
|
+
applyXAxisFormatter,
|
|
17
18
|
} from '../utils/chart-config'
|
|
18
19
|
|
|
19
20
|
export const scatterplotDownloadConfig =
|
|
@@ -32,6 +33,7 @@ export function scatterplotConfig(
|
|
|
32
33
|
type: 'scatterplot',
|
|
33
34
|
option: mergeEchartWidgetConfig(getCommonOptions(props), getOption(props)),
|
|
34
35
|
formatter: props.formatter,
|
|
36
|
+
labelFormatter: props.labelFormatter,
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -39,6 +41,7 @@ function getOption({
|
|
|
39
41
|
data = [],
|
|
40
42
|
theme,
|
|
41
43
|
formatter,
|
|
44
|
+
labelFormatter,
|
|
42
45
|
}: ScatterplotConfig): EchartOptionsProps {
|
|
43
46
|
const hasLegend = data.length > 1
|
|
44
47
|
|
|
@@ -94,12 +97,12 @@ function getOption({
|
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
return {
|
|
97
|
-
legend: buildLegendConfig(hasLegend),
|
|
100
|
+
legend: buildLegendConfig({ hasLegend, labelFormatter }),
|
|
98
101
|
grid: {
|
|
99
102
|
...(!hasLegend && { bottom: parseInt(theme.spacing(1)) }),
|
|
100
103
|
...(hasLegend && { bottom: parseInt(theme.spacing(10)) }),
|
|
101
104
|
},
|
|
102
|
-
xAxis,
|
|
105
|
+
xAxis: applyXAxisFormatter(xAxis, labelFormatter),
|
|
103
106
|
yAxis: applyYAxisFormatter(yAxis, formatter),
|
|
104
107
|
tooltip: {
|
|
105
108
|
trigger: 'item',
|
|
@@ -114,7 +117,9 @@ function getOption({
|
|
|
114
117
|
? formatter(_value)
|
|
115
118
|
: (_value ?? '')
|
|
116
119
|
const marker = typeof item.marker === 'string' ? item.marker : ''
|
|
117
|
-
const name =
|
|
120
|
+
const name = labelFormatter
|
|
121
|
+
? String(labelFormatter(item.seriesName ?? ''))
|
|
122
|
+
: (item.seriesName ?? '')
|
|
118
123
|
|
|
119
124
|
return { name, seriesName: '', marker, value: formattedValue }
|
|
120
125
|
}),
|
|
@@ -31,6 +31,8 @@ export interface WidgetsStoreProps {
|
|
|
31
31
|
registeredTools?: ToolRegistration[]
|
|
32
32
|
/** Formatter function for widget values */
|
|
33
33
|
formatter?: (value: number) => string
|
|
34
|
+
/** Formatter function for widget label/category values */
|
|
35
|
+
labelFormatter?: (value: string | number) => string | number
|
|
34
36
|
/** Locale for number formatting (e.g., 'en-US', 'es-ES', 'fr-FR') */
|
|
35
37
|
locale?: string
|
|
36
38
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
createTooltipFormatter,
|
|
16
16
|
createChartDownloadConfig,
|
|
17
17
|
applyYAxisFormatter,
|
|
18
|
+
applyXAxisFormatter,
|
|
18
19
|
} from '../utils/chart-config'
|
|
19
20
|
|
|
20
21
|
export const timeseriesDownloadConfig =
|
|
@@ -33,6 +34,7 @@ export function timeseriesConfig(
|
|
|
33
34
|
type: 'timeseries',
|
|
34
35
|
option: mergeEchartWidgetConfig(getCommonOptions(props), getOption(props)),
|
|
35
36
|
formatter: props.formatter,
|
|
37
|
+
labelFormatter: props.labelFormatter,
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -40,6 +42,7 @@ function getOption({
|
|
|
40
42
|
data = [],
|
|
41
43
|
theme,
|
|
42
44
|
formatter,
|
|
45
|
+
labelFormatter,
|
|
43
46
|
}: TimeseriesConfig): EchartOptionsProps {
|
|
44
47
|
const hasLegend = (data?.length ?? 0) > 1
|
|
45
48
|
|
|
@@ -73,7 +76,7 @@ function getOption({
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
return {
|
|
76
|
-
legend: buildLegendConfig(hasLegend),
|
|
79
|
+
legend: buildLegendConfig({ hasLegend, labelFormatter }),
|
|
77
80
|
grid: {
|
|
78
81
|
...buildGridConfig(hasLegend, theme),
|
|
79
82
|
outerBounds: {
|
|
@@ -82,18 +85,21 @@ function getOption({
|
|
|
82
85
|
top: parseInt(theme.spacing(2)),
|
|
83
86
|
},
|
|
84
87
|
},
|
|
85
|
-
xAxis:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
xAxis: applyXAxisFormatter(
|
|
89
|
+
{
|
|
90
|
+
type: 'category',
|
|
91
|
+
axisTick: {
|
|
92
|
+
alignWithLabel: true,
|
|
93
|
+
},
|
|
94
|
+
axisLabel: {
|
|
95
|
+
show: true,
|
|
96
|
+
showMaxLabel: true,
|
|
97
|
+
showMinLabel: true,
|
|
98
|
+
rotate: 45,
|
|
99
|
+
},
|
|
89
100
|
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
showMaxLabel: true,
|
|
93
|
-
showMinLabel: true,
|
|
94
|
-
rotate: 45,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
101
|
+
labelFormatter,
|
|
102
|
+
),
|
|
97
103
|
yAxis: applyYAxisFormatter(yAxis, formatter),
|
|
98
104
|
tooltip: {
|
|
99
105
|
formatter: createTooltipFormatter((item) => {
|
|
@@ -108,7 +114,9 @@ function getOption({
|
|
|
108
114
|
|
|
109
115
|
const marker = typeof item.marker === 'string' ? item.marker : ''
|
|
110
116
|
const seriesName = item.seriesName ? `${item.seriesName}: ` : ''
|
|
111
|
-
const name =
|
|
117
|
+
const name = labelFormatter
|
|
118
|
+
? String(labelFormatter(item.name ?? ''))
|
|
119
|
+
: (item.name ?? '')
|
|
112
120
|
|
|
113
121
|
return { name, seriesName, marker, value: formattedValue }
|
|
114
122
|
}),
|
|
@@ -26,10 +26,18 @@ export function niceNum(value: number): number {
|
|
|
26
26
|
/**
|
|
27
27
|
* Builds standard legend configuration for chart widgets
|
|
28
28
|
*
|
|
29
|
-
* @param
|
|
29
|
+
* @param params - Legend configuration parameters
|
|
30
|
+
* @param params.hasLegend - Whether to show the legend
|
|
31
|
+
* @param params.labelFormatter - Optional formatter for legend item names
|
|
30
32
|
* @returns Legend configuration object
|
|
31
33
|
*/
|
|
32
|
-
export function buildLegendConfig(
|
|
34
|
+
export function buildLegendConfig({
|
|
35
|
+
hasLegend,
|
|
36
|
+
labelFormatter,
|
|
37
|
+
}: {
|
|
38
|
+
hasLegend: boolean
|
|
39
|
+
labelFormatter?: (value: string | number) => string | number
|
|
40
|
+
}): LegendComponentOption {
|
|
33
41
|
return {
|
|
34
42
|
show: hasLegend,
|
|
35
43
|
icon: 'circle' as const,
|
|
@@ -37,6 +45,9 @@ export function buildLegendConfig(hasLegend: boolean): LegendComponentOption {
|
|
|
37
45
|
bottom: 0,
|
|
38
46
|
orient: 'horizontal',
|
|
39
47
|
type: 'scroll',
|
|
48
|
+
...(labelFormatter && {
|
|
49
|
+
formatter: (name: string) => String(labelFormatter(name)),
|
|
50
|
+
}),
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
|
|
@@ -101,25 +112,24 @@ export function createAxisLabelFormatter(
|
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
/**
|
|
104
|
-
* Applies
|
|
105
|
-
*
|
|
115
|
+
* Applies labelFormatter to xAxis configuration
|
|
116
|
+
* Applies to any xAxis regardless of axis type (category, value, etc.)
|
|
106
117
|
*
|
|
107
118
|
* @param xAxis - Existing xAxis configuration
|
|
108
|
-
* @param
|
|
109
|
-
* @returns Updated xAxis configuration
|
|
119
|
+
* @param labelFormatter - Optional labelFormatter function from widget config
|
|
120
|
+
* @returns Updated xAxis configuration
|
|
110
121
|
*/
|
|
111
122
|
export function applyXAxisFormatter(
|
|
112
123
|
xAxis: unknown,
|
|
113
|
-
formatter?: (value: number) => string,
|
|
124
|
+
formatter?: (value: string | number) => string | number,
|
|
114
125
|
) {
|
|
115
|
-
let axisFormatter = createAxisLabelFormatter(formatter)
|
|
116
|
-
|
|
117
126
|
const xAxisIsObject = xAxis && !Array.isArray(xAxis)
|
|
118
127
|
const xAxisTyped = xAxis as { type?: string; axisLabel?: unknown }
|
|
119
128
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
const axisFormatter =
|
|
130
|
+
formatter && xAxisIsObject
|
|
131
|
+
? (value: string | number) => String(formatter(value))
|
|
132
|
+
: undefined
|
|
123
133
|
|
|
124
134
|
return {
|
|
125
135
|
...xAxisTyped,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const defaultFormatter = (value: number) => value
|
|
1
|
+
export const defaultFormatter = (value: number) => String(value)
|
|
2
|
+
export const defaultLabelFormatter = (value: string | number) => value
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter-B1Xh8XDH.js","sources":["../src/widgets/utils/formatter.ts"],"sourcesContent":["export const defaultFormatter = (value: number) => value.toString()\n"],"names":["defaultFormatter","value","toString"],"mappings":"AAAO,MAAMA,IAAmBA,CAACC,MAAkBA,EAAMC,SAAAA;"}
|
package/dist/styles-C_8vOEep.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import "react/compiler-runtime";
|
|
3
|
-
import "@mui/material";
|
|
4
|
-
import "./widget-store-CzDt8oSK.js";
|
|
5
|
-
import "@mui/icons-material";
|
|
6
|
-
import "zustand/shallow";
|
|
7
|
-
import "react";
|
|
8
|
-
import "react-markdown";
|
|
9
|
-
import { d as p, a as f } from "./exports-Cr43OCul.js";
|
|
10
|
-
import "./lasso-tool-BYbxrJ-7.js";
|
|
11
|
-
import "./cjs-D4KH3azB.js";
|
|
12
|
-
import "@dnd-kit/core";
|
|
13
|
-
import "@dnd-kit/sortable";
|
|
14
|
-
import "@dnd-kit/utilities";
|
|
15
|
-
function I(t) {
|
|
16
|
-
const e = [];
|
|
17
|
-
if (t.length > 0 && (t[0]?.length ?? 0) > 0) {
|
|
18
|
-
const o = t?.[0]?.[0] ?? {}, i = Object.keys(o);
|
|
19
|
-
e.push(i);
|
|
20
|
-
}
|
|
21
|
-
return t.forEach((o) => {
|
|
22
|
-
o.forEach((i) => {
|
|
23
|
-
const r = Object.values(i).map((n) => String(n));
|
|
24
|
-
e.push(r);
|
|
25
|
-
});
|
|
26
|
-
}), e;
|
|
27
|
-
}
|
|
28
|
-
function z(t) {
|
|
29
|
-
const e = [];
|
|
30
|
-
return e.push(["x", "y"]), t.forEach((o) => {
|
|
31
|
-
o.forEach((i) => {
|
|
32
|
-
e.push([String(i[0]), String(i[1])]);
|
|
33
|
-
});
|
|
34
|
-
}), e;
|
|
35
|
-
}
|
|
36
|
-
function O(t) {
|
|
37
|
-
if (t === 0) return 0;
|
|
38
|
-
const e = Math.abs(t), o = Math.pow(10, Math.floor(Math.log10(e))), i = Math.ceil(e / o) * o;
|
|
39
|
-
return t < 0 ? -i : i;
|
|
40
|
-
}
|
|
41
|
-
function V(t) {
|
|
42
|
-
return {
|
|
43
|
-
show: t,
|
|
44
|
-
icon: "circle",
|
|
45
|
-
left: 0,
|
|
46
|
-
bottom: 0,
|
|
47
|
-
orient: "horizontal",
|
|
48
|
-
type: "scroll"
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function D(t, e) {
|
|
52
|
-
return {
|
|
53
|
-
...!t && {
|
|
54
|
-
bottom: parseInt(e.spacing(3))
|
|
55
|
-
},
|
|
56
|
-
...t && {
|
|
57
|
-
bottom: parseInt(e.spacing(7))
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function E(t) {
|
|
62
|
-
return function(e, o, i, r, n) {
|
|
63
|
-
const c = {
|
|
64
|
-
top: parseInt(t.spacing(0.5))
|
|
65
|
-
};
|
|
66
|
-
return n.contentSize[0] < n.viewSize[0] - e[0] ? c.left = e[0] : c.right = n.viewSize[0] - e[0], c;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function m(t) {
|
|
70
|
-
if (t)
|
|
71
|
-
return (e) => t(e);
|
|
72
|
-
}
|
|
73
|
-
function k(t, e) {
|
|
74
|
-
let o = m(e);
|
|
75
|
-
const i = t && !Array.isArray(t), r = t;
|
|
76
|
-
return (!i || r.type !== "value") && (o = void 0), {
|
|
77
|
-
...r,
|
|
78
|
-
axisLabel: {
|
|
79
|
-
...typeof r.axisLabel == "object" && r.axisLabel ? r.axisLabel : {},
|
|
80
|
-
formatter: o
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function _(t, e) {
|
|
85
|
-
let o = m(e);
|
|
86
|
-
const i = t && !Array.isArray(t), r = t;
|
|
87
|
-
return (!i || r.type !== "value") && (o = void 0), {
|
|
88
|
-
...r,
|
|
89
|
-
axisLabel: {
|
|
90
|
-
...typeof r.axisLabel == "object" && r.axisLabel ? r.axisLabel : {},
|
|
91
|
-
formatter: o
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function G(t) {
|
|
96
|
-
return (e) => {
|
|
97
|
-
const o = Array.isArray(e) ? e : [e], i = (a, s) => `<div style="margin: 0px 0 0;line-height:1;">${a ? `<div style="font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px">${a}</div>` : ""}<div style="margin: 0;line-height:1;">${s}</div><div style="clear:both"></div></div>`, r = o.map((a) => {
|
|
98
|
-
const {
|
|
99
|
-
name: s,
|
|
100
|
-
seriesName: l,
|
|
101
|
-
marker: g,
|
|
102
|
-
value: d
|
|
103
|
-
} = t(a, o);
|
|
104
|
-
return {
|
|
105
|
-
name: s,
|
|
106
|
-
seriesName: l,
|
|
107
|
-
marker: g,
|
|
108
|
-
value: d
|
|
109
|
-
};
|
|
110
|
-
}), n = r[0]?.name ?? "", u = n || o.length > 1 ? "margin: 10px 0 0;line-height:1;" : "margin: 0;line-height:1;", h = r.map(({
|
|
111
|
-
seriesName: a,
|
|
112
|
-
marker: s,
|
|
113
|
-
value: l
|
|
114
|
-
}) => `<div style="${u}"><div style="margin: 0px 0 0;line-height:1;">${s}${a ? `<span style="font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px">${a}</span>` : ""}<span style="float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900">${l}</span></div></div>`);
|
|
115
|
-
return i(n, h.join(""));
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function N(t) {
|
|
119
|
-
return function({
|
|
120
|
-
refUI: e
|
|
121
|
-
}) {
|
|
122
|
-
return [{
|
|
123
|
-
...p,
|
|
124
|
-
modifier: () => p.modifier(e)
|
|
125
|
-
}, {
|
|
126
|
-
...f,
|
|
127
|
-
modifier: async (o) => {
|
|
128
|
-
const i = t(o);
|
|
129
|
-
return f.modifier(i);
|
|
130
|
-
}
|
|
131
|
-
}];
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const P = {
|
|
135
|
-
graph: {
|
|
136
|
-
/**
|
|
137
|
-
* Common container style for chart widget skeletons
|
|
138
|
-
*/
|
|
139
|
-
container: {
|
|
140
|
-
display: "flex",
|
|
141
|
-
alignItems: "center",
|
|
142
|
-
justifyContent: "space-between",
|
|
143
|
-
flexDirection: "column",
|
|
144
|
-
gap: ({
|
|
145
|
-
spacing: t
|
|
146
|
-
}) => t(1),
|
|
147
|
-
height: ({
|
|
148
|
-
spacing: t
|
|
149
|
-
}) => t(38)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
export {
|
|
154
|
-
k as a,
|
|
155
|
-
_ as b,
|
|
156
|
-
P as c,
|
|
157
|
-
D as d,
|
|
158
|
-
V as e,
|
|
159
|
-
m as f,
|
|
160
|
-
N as g,
|
|
161
|
-
G as h,
|
|
162
|
-
E as i,
|
|
163
|
-
I as j,
|
|
164
|
-
O as n,
|
|
165
|
-
z as s
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=styles-C_8vOEep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles-C_8vOEep.js","sources":["../src/widgets/utils/chart-config/csv-modifiers.ts","../src/widgets/utils/chart-config/option-builders.ts","../src/widgets/utils/chart-config/download-config.ts","../src/widgets/utils/skeleton/styles.ts"],"sourcesContent":["/**\n * Shared CSV export modifiers for chart widgets\n */\n\n/**\n * Flattens object array data into CSV-ready rows.\n * Used by bar, pie, histogram, and timeseries widgets.\n *\n * @param data - Array of series, where each series is an array of data objects\n * @returns CSV rows with headers and values\n */\nexport function flattenObjectArrayToCSV<T extends Record<string, unknown>>(\n data: T[][],\n): string[][] {\n const rows: string[][] = []\n\n // Add headers from first data point if available\n if (data.length > 0 && (data[0]?.length ?? 0) > 0) {\n const firstDataPoint = data?.[0]?.[0] ?? {}\n const headers = Object.keys(firstDataPoint)\n rows.push(headers)\n }\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n const values = Object.values(dataPoint).map((v) => String(v))\n rows.push(values)\n })\n })\n\n return rows\n}\n\n/**\n * Creates CSV rows for scatterplot data.\n * Scatterplot uses array format [x, y] instead of objects.\n *\n * @param data - Array of series, where each series is an array of [x, y] tuples\n * @returns CSV rows with ['x', 'y'] headers\n */\nexport function scatterplotDataToCSV(data: number[][][]): string[][] {\n const rows: string[][] = []\n\n // Add headers\n rows.push(['x', 'y'])\n\n // Add data rows from all series\n data.forEach((series) => {\n series.forEach((dataPoint) => {\n rows.push([String(dataPoint[0]), String(dataPoint[1])])\n })\n })\n\n return rows\n}\n","import type { Theme } from '@mui/material'\nimport type { LegendComponentOption } from 'echarts'\nimport type {\n CallbackDataParams,\n TopLevelFormatterParams,\n} from 'echarts/types/dist/shared'\n\n/**\n * Shared EChart configuration builders for chart widgets\n */\n\n/**\n * Rounds a value up to the nearest \"nice\" number.\n * A nice number is a multiple of 10^floor(log10(value)).\n *\n * Examples: 547 → 600, 200 → 200, 1200 → 2000, 18 → 20, 5 → 5, -547 → -500\n */\nexport function niceNum(value: number): number {\n if (value === 0) return 0\n const absValue = Math.abs(value)\n const base = Math.pow(10, Math.floor(Math.log10(absValue)))\n const rounded = Math.ceil(absValue / base) * base\n return value < 0 ? -rounded : rounded\n}\n\n/**\n * Builds standard legend configuration for chart widgets\n *\n * @param hasLegend - Whether to show the legend\n * @returns Legend configuration object\n */\nexport function buildLegendConfig(hasLegend: boolean): LegendComponentOption {\n return {\n show: hasLegend,\n icon: 'circle' as const,\n left: 0,\n bottom: 0,\n orient: 'horizontal',\n type: 'scroll',\n }\n}\n\n/**\n * Builds standard grid configuration with legend-aware spacing\n *\n * @param hasLegend - Whether the chart has a legend\n * @param theme - MUI theme for spacing\n * @param additionalConfig - Additional grid configuration to merge\n * @returns Grid configuration object\n */\nexport function buildGridConfig(hasLegend: boolean, theme: Theme) {\n return {\n ...(!hasLegend && { bottom: parseInt(theme.spacing(3)) }),\n ...(hasLegend && { bottom: parseInt(theme.spacing(7)) }),\n }\n}\n\n/**\n * Creates a tooltip position calculator that handles overflow\n * Used by bar, histogram, and scatterplot widgets\n *\n * @param theme - MUI theme for spacing\n * @returns Tooltip position function\n */\nexport function createTooltipPositioner(theme: Theme) {\n return function (\n point: [number, number],\n _params: unknown,\n _dom: unknown,\n _rect: unknown,\n size: { contentSize: [number, number]; viewSize: [number, number] },\n ) {\n const position = { top: parseInt(theme.spacing(0.5)) } as Record<\n string,\n number\n >\n\n // Position tooltip left or right based on available space\n if (size.contentSize[0] < size.viewSize[0] - point[0]) {\n position.left = point[0]\n } else {\n position.right = size.viewSize[0] - point[0]\n }\n\n return position\n }\n}\n\n/**\n * Creates an axis label formatter for ECharts\n * Used to format numeric axis labels with a widget formatter\n *\n * @param formatter - Optional formatter function from widget config\n * @returns Axis label formatter function or undefined\n */\nexport function createAxisLabelFormatter(\n formatter?: (value: number) => string,\n) {\n if (!formatter) return undefined\n return (value: number) => formatter(value)\n}\n\n/**\n * Applies formatter to xAxis configuration\n * Only applies to single axis objects (not arrays) with type 'value'\n *\n * @param xAxis - Existing xAxis configuration\n * @param formatter - Optional formatter function from widget config\n * @returns Updated xAxis configuration or undefined if no changes needed\n */\nexport function applyXAxisFormatter(\n xAxis: unknown,\n formatter?: (value: number) => string,\n) {\n let axisFormatter = createAxisLabelFormatter(formatter)\n\n const xAxisIsObject = xAxis && !Array.isArray(xAxis)\n const xAxisTyped = xAxis as { type?: string; axisLabel?: unknown }\n\n if (!xAxisIsObject || xAxisTyped.type !== 'value') {\n axisFormatter = undefined\n }\n\n return {\n ...xAxisTyped,\n axisLabel: {\n ...(typeof xAxisTyped.axisLabel === 'object' && xAxisTyped.axisLabel\n ? xAxisTyped.axisLabel\n : {}),\n formatter: axisFormatter,\n },\n }\n}\n\n/**\n * Applies formatter to yAxis configuration\n * Only applies to single axis objects (not arrays) with type 'value'\n *\n * @param yAxis - Existing yAxis configuration\n * @param formatter - Optional formatter function from widget config\n * @returns Updated yAxis configuration or undefined if no changes needed\n */\nexport function applyYAxisFormatter(\n yAxis: unknown,\n formatter?: (value: number) => string,\n) {\n let axisFormatter = createAxisLabelFormatter(formatter)\n\n const yAxisIsObject = yAxis && !Array.isArray(yAxis)\n const yAxisTyped = yAxis as { type?: string; axisLabel?: unknown }\n\n if (!yAxisIsObject || yAxisTyped.type !== 'value') {\n axisFormatter = undefined\n }\n\n return {\n ...yAxisTyped,\n axisLabel: {\n ...(typeof yAxisTyped.axisLabel === 'object' && yAxisTyped.axisLabel\n ? yAxisTyped.axisLabel\n : {}),\n formatter: axisFormatter,\n },\n }\n}\n\n/**\n * Creates a tooltip formatter for ECharts\n * Formats numeric values in tooltip using widget formatter\n * Handles both axis trigger (array) and item trigger (object) modes\n *\n * @param formatter - Optional formatter function from widget config\n * @returns Tooltip formatter function or undefined\n */\nexport function createTooltipFormatter(\n callback: (\n item: CallbackDataParams,\n items: CallbackDataParams[],\n ) => {\n name: string\n seriesName: string\n marker: string\n value: string | number\n },\n) {\n return (params: TopLevelFormatterParams) => {\n // Handle both array (axis trigger) and object (item trigger)\n const items = Array.isArray(params) ? params : [params]\n\n const tooltip = (name: string, callback: string) =>\n `<div style=\"margin: 0px 0 0;line-height:1;\">${name ? `<div style=\"font-size:11px;color:#FFFFFF;font-weight:400;line-height:1; margin-bottom: 10px\">${name}</div>` : ''}<div style=\"margin: 0;line-height:1;\">${callback}</div><div style=\"clear:both\"></div></div>`\n\n const values = items.map((item) => {\n const { name, seriesName, marker, value } = callback(item, items)\n return {\n name,\n seriesName,\n marker,\n value,\n }\n })\n\n const name = values[0]?.name ?? ''\n // Show margin if name exists or there are multiple items\n const showMargin = name || items.length > 1\n const marginStyle = showMargin\n ? 'margin: 10px 0 0;line-height:1;'\n : 'margin: 0;line-height:1;'\n\n const formattedValues = values.map(\n ({ seriesName, marker, value }) =>\n `<div style=\"${marginStyle}\"><div style=\"margin: 0px 0 0;line-height:1;\">${marker}${seriesName ? `<span style=\"font-size:11px;color:#FFFFFF;font-weight:400;margin-left:2px;margin-right:10px\">${seriesName}</span>` : ''}<span style=\"float:right;margin-left:10px;font-size:11px;color:#FFFFFF;font-weight:900\">${value}</span></div></div>`,\n )\n\n return tooltip(name, formattedValues.join(''))\n }\n}\n","import { downloadToCSV, downloadToPNG, type DownloadItem } from '../../actions'\nimport type { ConfigProps } from '../../loader/types'\n\nexport function createChartDownloadConfig<TData>(\n csvModifier: (data: TData) => string[][],\n) {\n return function ({ refUI }: ConfigProps): DownloadItem<TData>[] {\n return [\n {\n ...downloadToPNG,\n modifier: () => downloadToPNG.modifier(refUI),\n },\n {\n ...downloadToCSV,\n modifier: async (data) => {\n const rows = csvModifier(data)\n return downloadToCSV.modifier(rows)\n },\n },\n ]\n }\n}\n","import type { Theme } from '@mui/material'\n\n/**\n * Base skeleton styles shared across all chart widgets\n */\nexport const baseSkeletonStyles = {\n graph: {\n /**\n * Common container style for chart widget skeletons\n */\n container: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n flexDirection: 'column',\n gap: ({ spacing }: Theme) => spacing(1),\n height: ({ spacing }: Theme) => spacing(38),\n },\n },\n} as const\n"],"names":["flattenObjectArrayToCSV","data","rows","length","firstDataPoint","headers","Object","keys","push","forEach","series","dataPoint","values","map","v","String","scatterplotDataToCSV","niceNum","value","absValue","Math","abs","base","pow","floor","log10","rounded","ceil","buildLegendConfig","hasLegend","show","icon","left","bottom","orient","type","buildGridConfig","theme","parseInt","spacing","createTooltipPositioner","point","_params","_dom","_rect","size","position","top","contentSize","viewSize","right","createAxisLabelFormatter","formatter","applyXAxisFormatter","xAxis","axisFormatter","xAxisIsObject","Array","isArray","xAxisTyped","undefined","axisLabel","applyYAxisFormatter","yAxis","yAxisIsObject","yAxisTyped","createTooltipFormatter","callback","params","items","tooltip","name","item","seriesName","marker","marginStyle","formattedValues","join","createChartDownloadConfig","csvModifier","refUI","downloadToPNG","modifier","downloadToCSV","baseSkeletonStyles","graph","container","display","alignItems","justifyContent","flexDirection","gap","height"],"mappings":";;;;;;;;;;;;;;AAWO,SAASA,EACdC,GACY;AACZ,QAAMC,IAAmB,CAAA;AAGzB,MAAID,EAAKE,SAAS,MAAMF,EAAK,CAAC,GAAGE,UAAU,KAAK,GAAG;AACjD,UAAMC,IAAiBH,IAAO,CAAC,IAAI,CAAC,KAAK,CAAA,GACnCI,IAAUC,OAAOC,KAAKH,CAAc;AAC1CF,IAAAA,EAAKM,KAAKH,CAAO;AAAA,EACnB;AAGAJ,SAAAA,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5B,YAAMC,IAASN,OAAOM,OAAOD,CAAS,EAAEE,IAAKC,CAAAA,MAAMC,OAAOD,CAAC,CAAC;AAC5DZ,MAAAA,EAAKM,KAAKI,CAAM;AAAA,IAClB,CAAC;AAAA,EACH,CAAC,GAEMV;AACT;AASO,SAASc,EAAqBf,GAAgC;AACnE,QAAMC,IAAmB,CAAA;AAGzBA,SAAAA,EAAKM,KAAK,CAAC,KAAK,GAAG,CAAC,GAGpBP,EAAKQ,QAASC,CAAAA,MAAW;AACvBA,IAAAA,EAAOD,QAASE,CAAAA,MAAc;AAC5BT,MAAAA,EAAKM,KAAK,CAACO,OAAOJ,EAAU,CAAC,CAAC,GAAGI,OAAOJ,EAAU,CAAC,CAAC,CAAC,CAAC;AAAA,IACxD,CAAC;AAAA,EACH,CAAC,GAEMT;AACT;ACtCO,SAASe,EAAQC,GAAuB;AAC7C,MAAIA,MAAU,EAAG,QAAO;AACxB,QAAMC,IAAWC,KAAKC,IAAIH,CAAK,GACzBI,IAA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