@m4l/widgets 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/charts/ChartSeries/ChartSeries.d.ts +1 -1
- package/charts/ChartSeries/ChartSeries.d.ts.map +1 -1
- package/charts/ChartSeries/ChartSeries.js +33 -13
- package/charts/ChartSeries/dictionary.d.ts +17 -0
- package/charts/ChartSeries/dictionary.d.ts.map +1 -0
- package/charts/ChartSeries/dictionary.js +24 -0
- package/charts/ChartSeries/helpers/formatCompactNumber.d.ts +11 -0
- package/charts/ChartSeries/helpers/formatCompactNumber.d.ts.map +1 -0
- package/charts/ChartSeries/helpers/formatCompactNumber.js +108 -0
- package/charts/ChartSeries/helpers/options.d.ts +2 -2
- package/charts/ChartSeries/helpers/options.d.ts.map +1 -1
- package/charts/ChartSeries/helpers/options.js +83 -34
- package/charts/ChartSeries/index.d.ts +3 -1
- package/charts/ChartSeries/index.d.ts.map +1 -1
- package/charts/ChartSeries/types.d.ts +22 -0
- package/charts/ChartSeries/types.d.ts.map +1 -1
- package/index.js +14 -8
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@ import { ChartSeriesProps } from './types';
|
|
|
5
5
|
* @param sx - System styles applied to the chart root container
|
|
6
6
|
* @returns ChartSeries component
|
|
7
7
|
*/
|
|
8
|
-
export declare function ChartSeries({ values, scrollable, sx }: ChartSeriesProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ChartSeries({ values, scrollable, numberLocalization, sx, }: ChartSeriesProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default ChartSeries;
|
|
10
10
|
//# sourceMappingURL=ChartSeries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartSeries.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/ChartSeries.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChartSeries.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/ChartSeries.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAUhD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,UAAkB,EAClB,kBAAkB,EAClB,EAAE,GACH,EAAE,gBAAgB,oDAuClB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import f from "echarts-for-react";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { useRef as h, useMemo as n } from "react";
|
|
4
|
+
import { useModuleDictionary as u } from "@m4l/core";
|
|
5
|
+
import { ChartSeriesRootStyled as d, ChartContainerStyled as y } from "./slots/ChartSeriesSlots.js";
|
|
6
|
+
import { useChartResize as C } from "./hooks/useChartResize.js";
|
|
7
|
+
import { useTheme as R } from "@mui/material";
|
|
8
|
+
import { generateOptions as S } from "./helpers/options.js";
|
|
9
|
+
import { resolveChartSeriesCompactNumberDictionary as g } from "./dictionary.js";
|
|
10
|
+
function F({
|
|
11
|
+
values: r,
|
|
12
|
+
scrollable: o = !1,
|
|
13
|
+
numberLocalization: e,
|
|
14
|
+
sx: c
|
|
15
|
+
}) {
|
|
16
|
+
const i = h(null), m = R(), { getLabel: s } = u(), a = n(
|
|
17
|
+
() => ({
|
|
18
|
+
...e,
|
|
19
|
+
locale: e?.locale ?? Intl.NumberFormat().resolvedOptions().locale,
|
|
20
|
+
compactDictionary: {
|
|
21
|
+
...g(s),
|
|
22
|
+
...e?.compactDictionary ?? {}
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
[s, e]
|
|
26
|
+
), p = n(
|
|
27
|
+
() => S(r, m, o, a),
|
|
28
|
+
[a, o, m, r]
|
|
29
|
+
), l = C(i);
|
|
30
|
+
return /* @__PURE__ */ t(d, { sx: c, children: /* @__PURE__ */ t(y, { ref: l, children: /* @__PURE__ */ t(
|
|
11
31
|
f,
|
|
12
32
|
{
|
|
13
|
-
ref:
|
|
14
|
-
option:
|
|
33
|
+
ref: i,
|
|
34
|
+
option: p,
|
|
15
35
|
style: { height: "100%", width: "100%" },
|
|
16
36
|
notMerge: !0,
|
|
17
37
|
lazyUpdate: !0
|
|
@@ -19,6 +39,6 @@ function E({ values: t, scrollable: r = !1, sx: n }) {
|
|
|
19
39
|
) }) });
|
|
20
40
|
}
|
|
21
41
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
F as ChartSeries,
|
|
43
|
+
F as default
|
|
24
44
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CompactNumberDictionary } from './types';
|
|
2
|
+
export declare const CHART_SERIES_DICTIONARY_ID = "chart_series";
|
|
3
|
+
/**
|
|
4
|
+
* Register the ChartSeries component dictionary namespace for compact y-axis labels.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getChartSeriesComponentDictionary(): string[];
|
|
7
|
+
export declare const CHART_SERIES_DICTIONARY: {
|
|
8
|
+
readonly LABEL_THOUSAND: "chart_series.label_thousand";
|
|
9
|
+
readonly LABEL_MILLION: "chart_series.label_million";
|
|
10
|
+
readonly LABEL_BILLION: "chart_series.label_billion";
|
|
11
|
+
readonly LABEL_TRILLION: "chart_series.label_trillion";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the compact-number suffix labels from the active module dictionary.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveChartSeriesCompactNumberDictionary(getLabel: (key: string) => string): CompactNumberDictionary;
|
|
17
|
+
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AAEzD;;GAEG;AACH,wBAAgB,iCAAiC,aAEhD;AAED,eAAO,MAAM,uBAAuB;;;;;CAK1B,CAAC;AAEX;;GAEG;AACH,wBAAgB,yCAAyC,CACvD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAChC,uBAAuB,CAOzB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const L = "chart_series";
|
|
2
|
+
function o() {
|
|
3
|
+
return [L];
|
|
4
|
+
}
|
|
5
|
+
const n = {
|
|
6
|
+
LABEL_THOUSAND: `${L}.label_thousand`,
|
|
7
|
+
LABEL_MILLION: `${L}.label_million`,
|
|
8
|
+
LABEL_BILLION: `${L}.label_billion`,
|
|
9
|
+
LABEL_TRILLION: `${L}.label_trillion`
|
|
10
|
+
};
|
|
11
|
+
function I(i) {
|
|
12
|
+
return {
|
|
13
|
+
thousand: i(n.LABEL_THOUSAND),
|
|
14
|
+
million: i(n.LABEL_MILLION),
|
|
15
|
+
billion: i(n.LABEL_BILLION),
|
|
16
|
+
trillion: i(n.LABEL_TRILLION)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
n as CHART_SERIES_DICTIONARY,
|
|
21
|
+
L as CHART_SERIES_DICTIONARY_ID,
|
|
22
|
+
o as getChartSeriesComponentDictionary,
|
|
23
|
+
I as resolveChartSeriesCompactNumberDictionary
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CompactNumberLocalizationOptions } from '../types';
|
|
2
|
+
export interface FormatCompactNumberOptions extends CompactNumberLocalizationOptions {
|
|
3
|
+
fallbackValue?: string;
|
|
4
|
+
value: number | null | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Format one numeric value using localized compact notation and replace compact suffixes from the caller dictionary when requested.
|
|
8
|
+
* When Intl compact formatting is unavailable, the value degrades to plain delimiter formatting without a compact suffix.
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatCompactNumber(options: FormatCompactNumberOptions): string;
|
|
11
|
+
//# sourceMappingURL=formatCompactNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatCompactNumber.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/ChartSeries/helpers/formatCompactNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gCAAgC,EACjC,MAAM,UAAU,CAAC;AAsBlB,MAAM,WAAW,0BACf,SAAQ,gCAAgC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC;AA6MD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,0BAA0B,GAClC,MAAM,CAkCR"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const d = [
|
|
2
|
+
{ minimumValue: 1e3, scale: "thousand" },
|
|
3
|
+
{ minimumValue: 1e6, scale: "million" },
|
|
4
|
+
{ minimumValue: 1e9, scale: "billion" },
|
|
5
|
+
{ minimumValue: 1e12, scale: "trillion" }
|
|
6
|
+
];
|
|
7
|
+
function A(t) {
|
|
8
|
+
if (!(typeof t != "string" || t.trim() === ""))
|
|
9
|
+
return t.trim().replace(/_/gu, "-");
|
|
10
|
+
}
|
|
11
|
+
function p(t) {
|
|
12
|
+
return !Number.isInteger(t) || typeof t != "number" || t < 0 ? 1 : t;
|
|
13
|
+
}
|
|
14
|
+
function f(t, i) {
|
|
15
|
+
return typeof t != "string" || t.trim() === "" ? i : t.trim();
|
|
16
|
+
}
|
|
17
|
+
function b(t) {
|
|
18
|
+
return {
|
|
19
|
+
dictionary: { ...t },
|
|
20
|
+
units: d
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function D(t, i, n) {
|
|
24
|
+
const e = Number.isInteger(t) ? String(t) : t.toFixed(2).replace(/\.?0+$/u, ""), r = e.startsWith("-"), m = r ? e.slice(1) : e, [u = "", o] = m.split("."), s = u.replace(
|
|
25
|
+
/\B(?=(\d{3})+(?!\d))/gu,
|
|
26
|
+
n
|
|
27
|
+
), a = r ? `-${s}` : s;
|
|
28
|
+
return typeof o != "string" || o === "" ? a : `${a}${i}${o}`;
|
|
29
|
+
}
|
|
30
|
+
function L(t, i) {
|
|
31
|
+
const n = 10 ** i;
|
|
32
|
+
return Math.round((t + Number.EPSILON) * n) / n;
|
|
33
|
+
}
|
|
34
|
+
function _(t, i) {
|
|
35
|
+
let n = -1;
|
|
36
|
+
for (let e = 0; e < t.length; e += 1)
|
|
37
|
+
Math.abs(i) >= t[e].minimumValue && (n = e);
|
|
38
|
+
return n;
|
|
39
|
+
}
|
|
40
|
+
function g(t, i, n) {
|
|
41
|
+
let e = _(t, i);
|
|
42
|
+
if (e === -1)
|
|
43
|
+
return null;
|
|
44
|
+
for (; e < t.length - 1; ) {
|
|
45
|
+
const r = t[e], m = t[e + 1], u = L(
|
|
46
|
+
i / r.minimumValue,
|
|
47
|
+
n
|
|
48
|
+
), o = m.minimumValue / r.minimumValue;
|
|
49
|
+
if (Math.abs(u) < o)
|
|
50
|
+
break;
|
|
51
|
+
e += 1;
|
|
52
|
+
}
|
|
53
|
+
return t[e];
|
|
54
|
+
}
|
|
55
|
+
function N(t, i) {
|
|
56
|
+
const {
|
|
57
|
+
compactDictionary: n,
|
|
58
|
+
maximumFractionDigits: e,
|
|
59
|
+
value: r
|
|
60
|
+
} = i;
|
|
61
|
+
if (typeof r != "number" || !Number.isFinite(r) || !n || Object.keys(n).length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
const { dictionary: m, units: u } = b(
|
|
64
|
+
n
|
|
65
|
+
), o = t.formatToParts(r);
|
|
66
|
+
if (!o.some((c) => c.type === "compact"))
|
|
67
|
+
return t.format(r);
|
|
68
|
+
const a = g(
|
|
69
|
+
u,
|
|
70
|
+
r,
|
|
71
|
+
p(e)
|
|
72
|
+
);
|
|
73
|
+
if (!a)
|
|
74
|
+
return t.format(r);
|
|
75
|
+
const l = m[a.scale];
|
|
76
|
+
return typeof l != "string" || l.trim() === "" ? t.format(r) : o.map((c) => c.type === "compact" ? l : c.value).join("");
|
|
77
|
+
}
|
|
78
|
+
function U(t) {
|
|
79
|
+
const {
|
|
80
|
+
decimalSymbol: i,
|
|
81
|
+
fallbackValue: n = "",
|
|
82
|
+
locale: e,
|
|
83
|
+
maximumFractionDigits: r,
|
|
84
|
+
thousandsSymbol: m,
|
|
85
|
+
value: u
|
|
86
|
+
} = t;
|
|
87
|
+
if (typeof u != "number" || !Number.isFinite(u))
|
|
88
|
+
return n;
|
|
89
|
+
try {
|
|
90
|
+
const o = new Intl.NumberFormat(A(e), {
|
|
91
|
+
notation: "compact",
|
|
92
|
+
compactDisplay: "short",
|
|
93
|
+
maximumFractionDigits: p(
|
|
94
|
+
r
|
|
95
|
+
)
|
|
96
|
+
});
|
|
97
|
+
return N(o, t) ?? o.format(u);
|
|
98
|
+
} catch {
|
|
99
|
+
return D(
|
|
100
|
+
u,
|
|
101
|
+
f(i, "."),
|
|
102
|
+
f(m, ",")
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
U as formatCompactNumber
|
|
108
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Theme } from '@mui/material/styles';
|
|
2
|
-
import { ChartSeriesProps } from '../types';
|
|
2
|
+
import { ChartSeriesProps, CompactNumberLocalizationOptions } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Builds ECharts option config for the series chart from data and theme.
|
|
5
5
|
*/
|
|
6
|
-
export declare function generateOptions(values: ChartSeriesProps['values'], theme: Theme, scrollable: boolean): any;
|
|
6
|
+
export declare function generateOptions(values: ChartSeriesProps['values'], theme: Theme, scrollable: boolean, numberLocalization?: CompactNumberLocalizationOptions): any;
|
|
7
7
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/ChartSeries/helpers/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../../packages/widgets/src/charts/ChartSeries/helpers/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAMjE;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,OAAO,EACnB,kBAAkB,CAAC,EAAE,gCAAgC,GACpD,GAAG,CAmSL"}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import { getColorHexFromVar as i, getColorHexFromToken as
|
|
2
|
-
import * as
|
|
3
|
-
import { remapTooltipFormatter as
|
|
4
|
-
|
|
1
|
+
import { getColorHexFromVar as i, getColorHexFromToken as c } from "../../../tools/color.js";
|
|
2
|
+
import * as m from "echarts";
|
|
3
|
+
import { remapTooltipFormatter as g } from "./tooltipFormatter.js";
|
|
4
|
+
import { formatCompactNumber as b } from "./formatCompactNumber.js";
|
|
5
|
+
const h = 56, p = 84;
|
|
6
|
+
function A(o, r, d, n) {
|
|
5
7
|
const e = {
|
|
6
|
-
textPrimaryColor: i(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
textPrimaryColor: i(
|
|
9
|
+
r.vars?.palette?.text?.primary
|
|
10
|
+
),
|
|
11
|
+
textDisabledColor: i(
|
|
12
|
+
r.vars?.palette?.text?.disabled
|
|
13
|
+
),
|
|
14
|
+
themeBackgroundColor: i(
|
|
15
|
+
r.vars?.palette?.background?.default
|
|
16
|
+
),
|
|
17
|
+
contrastTextColor: i(
|
|
18
|
+
r.vars?.palette?.text?.contrastText
|
|
19
|
+
),
|
|
20
|
+
backgroundNeutralColor: i(
|
|
21
|
+
r.vars?.palette?.background?.neutral
|
|
22
|
+
),
|
|
23
|
+
contrastDefaultColor: i(
|
|
24
|
+
r.vars?.palette?.background?.contrastDefault
|
|
25
|
+
)
|
|
26
|
+
}, x = u(o.values[0]);
|
|
13
27
|
return {
|
|
14
28
|
baseOption: {
|
|
15
29
|
/**
|
|
@@ -27,7 +41,7 @@ function m(o, r, d) {
|
|
|
27
41
|
fontSize: 13,
|
|
28
42
|
fontWeight: 700
|
|
29
43
|
},
|
|
30
|
-
formatter: (t) =>
|
|
44
|
+
formatter: (t) => g(t, o, e),
|
|
31
45
|
axisPointer: {
|
|
32
46
|
type: "cross",
|
|
33
47
|
lineStyle: {
|
|
@@ -110,12 +124,18 @@ function m(o, r, d) {
|
|
|
110
124
|
* Y-axis configuration.
|
|
111
125
|
*/
|
|
112
126
|
yAxis: o.yAxis.map((t, a) => {
|
|
113
|
-
const l = o.series.find(
|
|
127
|
+
const l = o.series.find(
|
|
128
|
+
(s) => s.yAxisId === t.id
|
|
129
|
+
), f = x[l?.field || ""] || "", y = c(
|
|
130
|
+
l?.pallet_color || "",
|
|
131
|
+
"contained",
|
|
132
|
+
"backgroundColorTone"
|
|
133
|
+
);
|
|
114
134
|
return {
|
|
115
135
|
type: "value",
|
|
116
|
-
name: t.title + " (" +
|
|
136
|
+
name: t.title + " (" + f + ")",
|
|
117
137
|
position: a === 0 ? "left" : "right",
|
|
118
|
-
offset: a > 1 ? (a - 1) *
|
|
138
|
+
offset: a > 1 ? (a - 1) * p : 0,
|
|
119
139
|
alignTicks: !0,
|
|
120
140
|
splitLine: {
|
|
121
141
|
show: !0,
|
|
@@ -135,19 +155,24 @@ function m(o, r, d) {
|
|
|
135
155
|
},
|
|
136
156
|
nameRotate: 90,
|
|
137
157
|
nameLocation: "middle",
|
|
158
|
+
nameGap: h,
|
|
138
159
|
axisLabel: {
|
|
139
160
|
color: e.textPrimaryColor,
|
|
140
161
|
fontFamily: "Jura",
|
|
141
162
|
fontSize: "13px",
|
|
142
163
|
fontWeight: 700,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
formatter: (s) =>
|
|
164
|
+
/**
|
|
165
|
+
* Format y-axis values with locale-aware compact notation.
|
|
166
|
+
*/
|
|
167
|
+
formatter: (s) => b({
|
|
168
|
+
value: s,
|
|
169
|
+
fallbackValue: `${s}`,
|
|
170
|
+
...n
|
|
171
|
+
})
|
|
147
172
|
},
|
|
148
173
|
axisLine: {
|
|
149
174
|
show: !0,
|
|
150
|
-
lineStyle: { color:
|
|
175
|
+
lineStyle: { color: y, width: 0.5, opacity: 1 }
|
|
151
176
|
}
|
|
152
177
|
};
|
|
153
178
|
}),
|
|
@@ -157,24 +182,30 @@ function m(o, r, d) {
|
|
|
157
182
|
grid: {
|
|
158
183
|
left: "8%",
|
|
159
184
|
bottom: "10%",
|
|
160
|
-
right: o.yAxis.length > 1 ? (o.yAxis.length - 1) *
|
|
185
|
+
right: o.yAxis.length > 1 ? (o.yAxis.length - 1) * p : "8%",
|
|
161
186
|
top: o.xAxis.length > 2 ? (o.xAxis.length - 1) * 35 : "15%",
|
|
162
|
-
containLabel: !
|
|
187
|
+
containLabel: !0
|
|
163
188
|
},
|
|
164
189
|
/**
|
|
165
190
|
* Series configuration.
|
|
166
191
|
*/
|
|
167
192
|
series: o.series.map((t) => {
|
|
168
|
-
const a = o.yAxis.findIndex(
|
|
193
|
+
const a = o.yAxis.findIndex(
|
|
194
|
+
(l) => l.id === t.yAxisId
|
|
195
|
+
);
|
|
169
196
|
return {
|
|
170
197
|
name: t.title,
|
|
171
198
|
type: t.type,
|
|
172
199
|
yAxisIndex: a !== -1 ? a : 0,
|
|
173
200
|
areaStyle: {
|
|
174
|
-
color: new
|
|
201
|
+
color: new m.graphic.LinearGradient(0, 0, 0, 1, [
|
|
175
202
|
{
|
|
176
203
|
offset: 0,
|
|
177
|
-
color:
|
|
204
|
+
color: c(
|
|
205
|
+
t?.pallet_color || "",
|
|
206
|
+
"contained",
|
|
207
|
+
"backgroundColor"
|
|
208
|
+
)
|
|
178
209
|
},
|
|
179
210
|
{
|
|
180
211
|
offset: 0.8,
|
|
@@ -182,22 +213,36 @@ function m(o, r, d) {
|
|
|
182
213
|
}
|
|
183
214
|
])
|
|
184
215
|
},
|
|
185
|
-
data: o.values.map(
|
|
216
|
+
data: o.values.map(
|
|
217
|
+
(l) => l[t.field].r
|
|
218
|
+
),
|
|
186
219
|
...t.type === "line" && {
|
|
187
220
|
symbol: "circle",
|
|
188
221
|
symbolSize: 10,
|
|
189
222
|
itemStyle: {
|
|
190
223
|
borderWidth: 2,
|
|
191
|
-
borderColor:
|
|
224
|
+
borderColor: c(
|
|
225
|
+
t.pallet_color,
|
|
226
|
+
"contained",
|
|
227
|
+
"backgroundColorTone"
|
|
228
|
+
),
|
|
192
229
|
color: e.themeBackgroundColor
|
|
193
230
|
},
|
|
194
231
|
lineStyle: {
|
|
195
232
|
width: 2,
|
|
196
|
-
color:
|
|
233
|
+
color: c(
|
|
234
|
+
t.pallet_color,
|
|
235
|
+
"contained",
|
|
236
|
+
"backgroundColorTone"
|
|
237
|
+
)
|
|
197
238
|
},
|
|
198
239
|
emphasis: {
|
|
199
240
|
itemStyle: {
|
|
200
|
-
color:
|
|
241
|
+
color: c(
|
|
242
|
+
t.pallet_color,
|
|
243
|
+
"contained",
|
|
244
|
+
"backgroundColorTone"
|
|
245
|
+
)
|
|
201
246
|
}
|
|
202
247
|
}
|
|
203
248
|
},
|
|
@@ -208,7 +253,11 @@ function m(o, r, d) {
|
|
|
208
253
|
itemStyle: {
|
|
209
254
|
borderRadius: [6, 6, 0, 0]
|
|
210
255
|
},
|
|
211
|
-
color:
|
|
256
|
+
color: c(
|
|
257
|
+
t.pallet_color,
|
|
258
|
+
"contained",
|
|
259
|
+
"backgroundColorTone"
|
|
260
|
+
)
|
|
212
261
|
}
|
|
213
262
|
};
|
|
214
263
|
})
|
|
@@ -218,12 +267,12 @@ function m(o, r, d) {
|
|
|
218
267
|
}
|
|
219
268
|
};
|
|
220
269
|
}
|
|
221
|
-
function
|
|
270
|
+
function u(o) {
|
|
222
271
|
return Object.keys(o).reduce((r, d) => {
|
|
223
|
-
const
|
|
224
|
-
return
|
|
272
|
+
const n = o[d];
|
|
273
|
+
return n && typeof n == "object" && "v" in n && (r[d] = n.v.replace(/[0-9.\s]+/g, "")), r;
|
|
225
274
|
}, {});
|
|
226
275
|
}
|
|
227
276
|
export {
|
|
228
|
-
|
|
277
|
+
A as generateOptions
|
|
229
278
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { ChartSeries } from './ChartSeries';
|
|
2
|
-
export
|
|
2
|
+
export { CHART_SERIES_DICTIONARY, getChartSeriesComponentDictionary, resolveChartSeriesCompactNumberDictionary, } from './dictionary';
|
|
3
|
+
export { formatCompactNumber } from './helpers/formatCompactNumber';
|
|
4
|
+
export type { CompactNumberDictionary, CompactNumberLocalizationOptions, ChartSeriesProps, ChartSeriesValueItem, } from './types';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EACV,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACvB,iCAAiC,EACjC,yCAAyC,GAC1C,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,YAAY,EACV,uBAAuB,EACvB,gCAAgC,EAChC,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -2,6 +2,26 @@ import { ChartSeriesSlots } from './slots/ChartSeriesEnum';
|
|
|
2
2
|
import { CHART_SERIES_KEY_COMPONENT } from './constants';
|
|
3
3
|
import { M4LOverridesStyleRules } from '@m4l/components';
|
|
4
4
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
5
|
+
/**
|
|
6
|
+
* Dictionary used to label compact magnitudes in the chart y-axis.
|
|
7
|
+
*/
|
|
8
|
+
export interface CompactNumberDictionary {
|
|
9
|
+
billion: string;
|
|
10
|
+
million: string;
|
|
11
|
+
thousand: string;
|
|
12
|
+
trillion: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Localization options used when formatting compact y-axis labels.
|
|
16
|
+
*/
|
|
17
|
+
export interface CompactNumberLocalizationOptions {
|
|
18
|
+
/** Optional compact suffix labels; partial entries override the caller-resolved dictionary. */
|
|
19
|
+
compactDictionary?: Partial<CompactNumberDictionary>;
|
|
20
|
+
decimalSymbol?: string | null;
|
|
21
|
+
locale?: string | null;
|
|
22
|
+
maximumFractionDigits?: number;
|
|
23
|
+
thousandsSymbol?: string | null;
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
26
|
* Item for the series chart (API shape).
|
|
7
27
|
*/
|
|
@@ -48,6 +68,8 @@ export interface ChartSeriesProps {
|
|
|
48
68
|
values: ChartSeriesValueItem;
|
|
49
69
|
/** Chart scrollable option. */
|
|
50
70
|
scrollable?: boolean;
|
|
71
|
+
/** Localization options used when formatting compact y-axis labels. */
|
|
72
|
+
numberLocalization?: CompactNumberLocalizationOptions;
|
|
51
73
|
/** System styles applied to the chart root container. */
|
|
52
74
|
sx?: SxProps<Theme>;
|
|
53
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ;;OAEG;IACH,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ;;OAEG;IACH,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ;;OAEG;IACH,MAAM,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/widgets/src/charts/ChartSeries/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ;;OAEG;IACH,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ;;OAEG;IACH,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ;;OAEG;IACH,MAAM,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GACR;YACE,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;SACX,GACD,MAAM,CAAC;KACZ,EAAE,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,MAAM,EAAE,oBAAoB,CAAC;IAC7B,+BAA+B;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,gCAAgC,CAAC;IACtD,yDAAyD;IACzD,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AACjE,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,CACpD,oBAAoB,EACpB,OAAO,0BAA0B,EACjC,KAAK,CACN,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { ChartPie as t } from "./charts/ChartPie/ChartPie.js";
|
|
2
|
-
import { ChartSeries as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { ChartSeries as a } from "./charts/ChartSeries/ChartSeries.js";
|
|
3
|
+
import { CHART_SERIES_DICTIONARY as m, getChartSeriesComponentDictionary as p, resolveChartSeriesCompactNumberDictionary as C } from "./charts/ChartSeries/dictionary.js";
|
|
4
|
+
import { formatCompactNumber as s } from "./charts/ChartSeries/helpers/formatCompactNumber.js";
|
|
5
|
+
import { WidgetBase as g } from "./cards/WidgetBase/WidgetBase.js";
|
|
6
|
+
import { WidgetDigitalInput as n } from "./cards/WidgetDigitalInput/WidgetDigitalInput.js";
|
|
7
|
+
import { WidgetBaseThreeValues as c } from "./cards/WidgetBaseThreeValues/WidgetBaseThreeValues.js";
|
|
6
8
|
export {
|
|
9
|
+
m as CHART_SERIES_DICTIONARY,
|
|
7
10
|
t as ChartPie,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
a as ChartSeries,
|
|
12
|
+
g as WidgetBase,
|
|
13
|
+
c as WidgetBaseThreeValues,
|
|
14
|
+
n as WidgetDigitalInput,
|
|
15
|
+
s as formatCompactNumber,
|
|
16
|
+
p as getChartSeriesComponentDictionary,
|
|
17
|
+
C as resolveChartSeriesCompactNumberDictionary
|
|
12
18
|
};
|