@rowsncolumns/charts 28.1.6 → 28.1.7

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.
Files changed (29) hide show
  1. package/dist/cjs/basic-chart/basic-chart.d.ts +1 -1
  2. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  3. package/dist/cjs/basic-chart/basic-chart.js +152 -137
  4. package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
  5. package/dist/cjs/components/editors/chart-editor.js +5 -1
  6. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +1 -1
  7. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  8. package/dist/cjs/plotly/basic-chart/basic-chart.js +56 -11
  9. package/dist/cjs/utils/axis-number-format.d.ts +26 -7
  10. package/dist/cjs/utils/axis-number-format.d.ts.map +1 -1
  11. package/dist/cjs/utils/axis-number-format.js +94 -16
  12. package/dist/cjs/utils/overrides.d.ts +3 -3
  13. package/dist/cjs/utils/overrides.d.ts.map +1 -1
  14. package/dist/cjs/utils/overrides.js +32 -15
  15. package/dist/esm/basic-chart/basic-chart.d.ts +1 -1
  16. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  17. package/dist/esm/basic-chart/basic-chart.js +64 -45
  18. package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
  19. package/dist/esm/components/editors/chart-editor.js +5 -1
  20. package/dist/esm/plotly/basic-chart/basic-chart.d.ts +1 -1
  21. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  22. package/dist/esm/plotly/basic-chart/basic-chart.js +55 -12
  23. package/dist/esm/utils/axis-number-format.d.ts +26 -7
  24. package/dist/esm/utils/axis-number-format.d.ts.map +1 -1
  25. package/dist/esm/utils/axis-number-format.js +83 -13
  26. package/dist/esm/utils/overrides.d.ts +3 -3
  27. package/dist/esm/utils/overrides.d.ts.map +1 -1
  28. package/dist/esm/utils/overrides.js +33 -16
  29. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAuBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AA4CvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;CAC1C,CAAC;AAuBF,eAAO,MAAM,WAAW,GAAI,sEAMzB,gBAAgB,sBAo6DlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAuBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AA4CvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;CAC1C,CAAC;AAuBF,eAAO,MAAM,WAAW,GAAI,sEAMzB,gBAAgB,sBAw6DlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -699,7 +699,11 @@ var ChartEditor = function (_a) {
699
699
  react_1.default.createElement("option", { value: "outside" }, "Outside"),
700
700
  react_1.default.createElement("option", { value: "insideEnd" }, "Inside end"),
701
701
  react_1.default.createElement("option", { value: "outsideEnd" }, "Outside end"),
702
- react_1.default.createElement("option", { value: "bestFit" }, "Best fit")),
702
+ react_1.default.createElement("option", { value: "bestFit" }, "Best fit"),
703
+ react_1.default.createElement("option", { value: "above" }, "Above"),
704
+ react_1.default.createElement("option", { value: "below" }, "Below"),
705
+ react_1.default.createElement("option", { value: "left" }, "Left"),
706
+ react_1.default.createElement("option", { value: "right" }, "Right")),
703
707
  react_1.default.createElement("label", { className: "font-system text-xs" }, "Number format pattern"),
704
708
  react_1.default.createElement(ui_1.Input, { value: (_30 = (_29 = values === null || values === void 0 ? void 0 : values.spec.dataLabels) === null || _29 === void 0 ? void 0 : _29.numberFormatPattern) !== null && _30 !== void 0 ? _30 : "", type: "text", onChange: function (e) {
705
709
  return setFieldValue("spec.dataLabels.numberFormatPattern", e.target.value || undefined);
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import type { EChartComponentProps } from "../../types";
3
3
  export type BasicChartProps = EChartComponentProps;
4
- export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, }: BasicChartProps) => React.JSX.Element;
4
+ export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, }: BasicChartProps) => React.JSX.Element;
5
5
  //# sourceMappingURL=basic-chart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAgXxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AA0FnD,eAAO,MAAM,UAAU,GAAI,wOAiBxB,eAAe,sBA8zEjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAuZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AA0FnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA00EjB,CAAC"}
@@ -181,15 +181,45 @@ var PLOTLY_DLBL_POS_BAR = {
181
181
  insideEnd: "inside",
182
182
  outsideEnd: "outside",
183
183
  bestFit: "outside",
184
+ above: "outside",
185
+ below: "outside",
186
+ left: "outside",
187
+ right: "outside",
184
188
  };
185
- var applyDataLabelsToTracePlotly = function (trace, opts, chartType, sourceNumberFormat) {
189
+ // A scatter trace (line / area / scatter) places its text with the compass
190
+ // positions, and only draws it when `mode` carries `text`. Excel's line
191
+ // placements are centre / left / right / above / below; the bar-only ones
192
+ // land on Excel's default for a line, above the point (#1049).
193
+ var PLOTLY_DLBL_POS_POINT = {
194
+ center: "middle center",
195
+ inside: "middle center",
196
+ outside: "top center",
197
+ insideEnd: "top center",
198
+ outsideEnd: "top center",
199
+ bestFit: "top center",
200
+ above: "top center",
201
+ below: "bottom center",
202
+ left: "middle left",
203
+ right: "middle right",
204
+ };
205
+ var withTextMode = function (mode) {
206
+ var base = typeof mode === "string" && mode ? mode : "lines+markers";
207
+ return base.split("+").includes("text") ? base : "".concat(base, "+text");
208
+ };
209
+ var applyDataLabelsToTracePlotly = function (trace, opts, chartType, sourceNumberFormat, locale) {
186
210
  var _a, _b, _c;
187
211
  if (!(opts === null || opts === void 0 ? void 0 : opts.show))
188
212
  return trace;
189
213
  var next = tslib_1.__assign({}, trace);
190
214
  var isCircular = chartType === "pie" || chartType === "doughnut";
191
- var posMap = isCircular ? PLOTLY_DLBL_POS_PIE : PLOTLY_DLBL_POS_BAR;
192
- var position = opts.position ? (_a = posMap[opts.position]) !== null && _a !== void 0 ? _a : "inside" : "inside";
215
+ var isPoint = !isCircular && next.type === "scatter";
216
+ var posMap = isCircular
217
+ ? PLOTLY_DLBL_POS_PIE
218
+ : isPoint
219
+ ? PLOTLY_DLBL_POS_POINT
220
+ : PLOTLY_DLBL_POS_BAR;
221
+ var fallback = isPoint ? "top center" : "inside";
222
+ var position = opts.position ? (_a = posMap[opts.position]) !== null && _a !== void 0 ? _a : fallback : fallback;
193
223
  if (isCircular) {
194
224
  // Plotly's pie trace uses `textinfo` to control which fields render.
195
225
  var parts = [];
@@ -207,7 +237,9 @@ var applyDataLabelsToTracePlotly = function (trace, opts, chartType, sourceNumbe
207
237
  var pattern_1 = (_b = opts.numberFormatPattern) !== null && _b !== void 0 ? _b : sourceNumberFormat;
208
238
  if (pattern_1) {
209
239
  var values = Array.isArray(next.values) ? next.values : [];
210
- next.text = values.map(function (v) { return (0, axis_number_format_1.formatAxisValue)(pattern_1, v); });
240
+ next.text = values.map(function (v) {
241
+ return (0, axis_number_format_1.formatAxisValue)(pattern_1, v, locale);
242
+ });
211
243
  next.texttemplate = next.textinfo
212
244
  .split("+")
213
245
  .map(function (part) { return (part === "value" ? "%{text}" : "%{".concat(part, "}")); })
@@ -226,9 +258,15 @@ var applyDataLabelsToTracePlotly = function (trace, opts, chartType, sourceNumbe
226
258
  var values = next.orientation === "h" ? next.x : next.y;
227
259
  var vals = Array.isArray(values) ? values : [];
228
260
  next.text = pattern_2
229
- ? vals.map(function (v) { return (v === null || v === undefined ? "" : (0, utils_1.ssfFormat)(pattern_2, v)); })
230
- : values;
261
+ ? vals.map(function (v) {
262
+ return v === null || v === undefined ? "" : (0, utils_1.ssfFormat)(pattern_2, v, locale);
263
+ })
264
+ : locale
265
+ ? vals.map(function (v) { return (0, axis_number_format_1.formatAxisValue)(undefined, v, locale); })
266
+ : values;
231
267
  next.textposition = position;
268
+ if (isPoint)
269
+ next.mode = withTextMode(next.mode);
232
270
  }
233
271
  return next;
234
272
  };
@@ -369,7 +407,7 @@ var addAlphaToColor = function (color, alpha) {
369
407
  };
370
408
  var BasicChart = function (_a) {
371
409
  var _b;
372
- var width = _a.width, height = _a.height, chart = _a.chart, theme = _a.theme, isDarkMode = _a.isDarkMode, sheetId = _a.sheetId, readonly = _a.readonly, getDomainValuesFromRange = _a.getDomainValuesFromRange, getSeriesValuesFromRange = _a.getSeriesValuesFromRange, getFormattingFromRange = _a.getFormattingFromRange, onDeleteChart = _a.onDeleteChart, onUpdateChart = _a.onUpdateChart, onRequestEdit = _a.onRequestEdit, onRequestCalculate = _a.onRequestCalculate, isSelected = _a.isSelected, fieldButtons = _a.fieldButtons;
410
+ var width = _a.width, height = _a.height, chart = _a.chart, theme = _a.theme, isDarkMode = _a.isDarkMode, sheetId = _a.sheetId, readonly = _a.readonly, getDomainValuesFromRange = _a.getDomainValuesFromRange, getSeriesValuesFromRange = _a.getSeriesValuesFromRange, getFormattingFromRange = _a.getFormattingFromRange, onDeleteChart = _a.onDeleteChart, onUpdateChart = _a.onUpdateChart, onRequestEdit = _a.onRequestEdit, onRequestCalculate = _a.onRequestCalculate, isSelected = _a.isSelected, fieldButtons = _a.fieldButtons, locale = _a.locale;
373
411
  var spec = chart.spec;
374
412
  var hierarchyTitleRef = (0, react_1.useRef)(undefined);
375
413
  var explicitChartTitle = (_b = chart.spec.title) !== null && _b !== void 0 ? _b : undefined;
@@ -1754,6 +1792,7 @@ var BasicChart = function (_a) {
1754
1792
  : (0, axis_number_format_1.valueAxisNameGap)({
1755
1793
  values: primaryValues,
1756
1794
  pattern: primaryAxisNumberFormat,
1795
+ locale: locale,
1757
1796
  fontSize: axisFontSize,
1758
1797
  minimum: 0,
1759
1798
  }) -
@@ -1771,6 +1810,7 @@ var BasicChart = function (_a) {
1771
1810
  : [];
1772
1811
  }),
1773
1812
  pattern: secondaryAxisNumberFormat,
1813
+ locale: locale,
1774
1814
  fontSize: axisFontSize,
1775
1815
  minimum: 0,
1776
1816
  }) -
@@ -1882,12 +1922,14 @@ var BasicChart = function (_a) {
1882
1922
  formattedTraces = traces.map(function (trace) {
1883
1923
  var _a;
1884
1924
  var pattern = traceNumberFormat(trace);
1885
- var next = applyDataLabelsToTracePlotly(trace, dlOpts, spec.chartType, pattern);
1925
+ var next = applyDataLabelsToTracePlotly(trace, dlOpts, spec.chartType, pattern, locale);
1886
1926
  if (next.type === "pie") {
1887
1927
  // Hover values format like the slice's source cell.
1888
1928
  if (pattern && !next.text) {
1889
1929
  var values = Array.isArray(next.values) ? next.values : [];
1890
- next = tslib_1.__assign(tslib_1.__assign({}, next), { text: values.map(function (v) { return (0, axis_number_format_1.formatAxisValue)(pattern, v); }), hoverinfo: "label+text+percent+name" });
1930
+ next = tslib_1.__assign(tslib_1.__assign({}, next), { text: values.map(function (v) {
1931
+ return (0, axis_number_format_1.formatAxisValue)(pattern, v, locale);
1932
+ }), hoverinfo: "label+text+percent+name" });
1891
1933
  }
1892
1934
  else if (pattern) {
1893
1935
  next = tslib_1.__assign(tslib_1.__assign({}, next), { hoverinfo: "label+text+percent+name" });
@@ -1911,7 +1953,7 @@ var BasicChart = function (_a) {
1911
1953
  var values = horizontal ? next.x : next.y;
1912
1954
  if (seriesPattern_1 && Array.isArray(values)) {
1913
1955
  next = tslib_1.__assign(tslib_1.__assign({}, next), { customdata: values.map(function (v) {
1914
- return (0, axis_number_format_1.formatAxisValue)(seriesPattern_1, v);
1956
+ return (0, axis_number_format_1.formatAxisValue)(seriesPattern_1, v, locale);
1915
1957
  }), hovertemplate: "".concat(horizontal ? "%{y}" : "%{x}", "<br>%{customdata}<extra>%{fullData.name}</extra>") });
1916
1958
  }
1917
1959
  }
@@ -1951,6 +1993,7 @@ var BasicChart = function (_a) {
1951
1993
  getDomainValuesFromRange,
1952
1994
  getSeriesValuesFromRange,
1953
1995
  getFormattingFromRange,
1996
+ locale,
1954
1997
  ]);
1955
1998
  // Update theme
1956
1999
  (0, ui_1.useIsomorphicLayoutEffect)(function () {
@@ -1984,7 +2027,9 @@ var BasicChart = function (_a) {
1984
2027
  scrollZoom: false,
1985
2028
  doubleClick: false,
1986
2029
  };
1987
- var plotLayout = (0, react_1.useMemo)(function () { return (tslib_1.__assign(tslib_1.__assign({}, layout), { dragmode: false })); }, [layout]);
2030
+ // Ticks and hover values plotly formats itself use the sheet's separators.
2031
+ var separators = (0, react_1.useMemo)(function () { return (0, axis_number_format_1.plotlySeparators)(locale); }, [locale]);
2032
+ var plotLayout = (0, react_1.useMemo)(function () { return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, layout), { dragmode: false }), (separators ? { separators: separators } : {}))); }, [layout, separators]);
1988
2033
  // Excel's "Rounded Corners" chart frame (`<c:roundedCorners val="1"/>`
1989
2034
  // at the chartSpace root). Default per OOXML §21.2.2.183 is square,
1990
2035
  // so only opt in when the workbook explicitly set the flag.
@@ -26,17 +26,28 @@ export declare const resolveValueAxisNumberFormat: ({ axisOptions, series, getFo
26
26
  getFormattingFromRange: RangeFormatReader | undefined;
27
27
  hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY | null;
28
28
  }) => string | undefined;
29
- /** Format one numeric value through the resolved pattern; non-numbers pass through. */
30
- export declare const formatAxisValue: (pattern: string | undefined, value: unknown) => string;
31
- /** echarts `axisLabel.formatter` / `tooltip.valueFormatter` for a value axis. */
32
- export declare const valueAxisLabelFormatter: (pattern: string | undefined) => ((value: unknown) => string) | undefined;
29
+ export declare const formatPlainNumber: (value: number, locale: string | undefined, grouping?: boolean) => string;
30
+ /**
31
+ * Format one numeric value through the resolved pattern; non-numbers pass
32
+ * through. `locale` is the spreadsheet locale the cells format with: it
33
+ * picks the pattern's separators, and a number without a pattern reads
34
+ * like a `General` cell in that locale.
35
+ */
36
+ export declare const formatAxisValue: (pattern: string | undefined, value: unknown, locale?: string) => string;
37
+ /**
38
+ * echarts `axisLabel.formatter` / `tooltip.valueFormatter` for a value
39
+ * axis. Without a pattern the ticks keep echarts' own labels unless a
40
+ * locale is given, in which case they group thousands the way echarts
41
+ * does but with the locale's separators (#1050).
42
+ */
43
+ export declare const valueAxisLabelFormatter: (pattern: string | undefined, locale?: string) => ((value: unknown) => string) | undefined;
33
44
  /**
34
45
  * echarts `tooltip.valueFormatter` for a series whose data items are
35
46
  * tuples (candlestick, 3-D points): every number formats through the
36
47
  * pattern; `undefined` when there is no pattern so echarts keeps its
37
48
  * default.
38
49
  */
39
- export declare const tooltipValueFormatter: (pattern: string | undefined) => ((value: unknown) => string | string[]) | undefined;
50
+ export declare const tooltipValueFormatter: (pattern: string | undefined, locale?: string) => ((value: unknown) => string | string[]) | undefined;
40
51
  /**
41
52
  * Excel's data labels and tooltips are linked to *each series' own* source
42
53
  * cells, not to the axis: a revenue series formatted `$#,##0` next to a
@@ -45,11 +56,18 @@ export declare const tooltipValueFormatter: (pattern: string | undefined) => ((v
45
56
  */
46
57
  export declare const resolveSeriesNumberFormats: (series: Pick<ChartData, "sources">[] | undefined, getFormattingFromRange: RangeFormatReader | undefined, hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY | null) => (string | undefined)[];
47
58
  /** echarts pie / doughnut tooltip: `name: value (percent%)` with the value formatted. */
48
- export declare const circularTooltipFormatter: (pattern: string | undefined) => (params: {
59
+ export declare const circularTooltipFormatter: (pattern: string | undefined, locale?: string) => (params: {
49
60
  name?: string;
50
61
  value?: unknown;
51
62
  percent?: number;
52
63
  }) => string;
64
+ /**
65
+ * plotly `layout.separators` for the spreadsheet locale: the decimal
66
+ * separator followed by the thousands separator, so ticks and hover
67
+ * values plotly formats itself read like the sheet's cells (#1050).
68
+ * `undefined` without a locale keeps plotly's default (`.,`).
69
+ */
70
+ export declare const plotlySeparators: (locale: string | undefined) => string | undefined;
53
71
  export type PlotlyTickFormat = {
54
72
  tickformat?: string;
55
73
  tickprefix?: string;
@@ -73,9 +91,10 @@ export declare const numberFormatToPlotlyTicks: (pattern: string | undefined) =>
73
91
  * measured; the fixed default of 50px only fits labels up to ~4 digits and
74
92
  * lets a currency axis title paint over its own tick labels.
75
93
  */
76
- export declare const valueAxisNameGap: ({ values, pattern, fontSize, minimum, }: {
94
+ export declare const valueAxisNameGap: ({ values, pattern, locale, fontSize, minimum, }: {
77
95
  values: readonly unknown[];
78
96
  pattern: string | undefined;
97
+ locale?: string;
79
98
  fontSize?: number;
80
99
  minimum?: number;
81
100
  }) => number;
@@ -1 +1 @@
1
- {"version":3,"file":"axis-number-format.d.ts","sourceRoot":"","sources":["../../../utils/axis-number-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,yBAAyB,EACzB,KAAK,EACL,UAAU,EACX,MAAM,2BAA2B,CAAC;AAWnC,KAAK,iBAAiB,GAAG,CACvB,UAAU,EAAE,UAAU,EACtB,uBAAuB,CAAC,EAAE,yBAAyB,KAChD,OAAO,EAAE,CAAC;AAMf;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,YAGjC,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,UAAU,EAAE,GAAG,SAAS,EACjC,wBAAwB,iBAAiB,GAAG,SAAS,EACrD,0BAA0B,yBAAyB,GAAG,IAAI,KACzD,MAAM,GAAG,SAWX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,2EAK1C;IACD,WAAW,EAAE,KAAK,CAAC;QAAE,mBAAmB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IACxE,MAAM,EAAE,IAAI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AAM,gBAAgB,GAAI,iDAM9B;IACD,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,MAgBH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.valueAxisNameGap = exports.numberFormatToPlotlyTicks = exports.circularTooltipFormatter = exports.resolveSeriesNumberFormats = exports.tooltipValueFormatter = exports.valueAxisLabelFormatter = exports.formatAxisValue = exports.resolveValueAxisNumberFormat = exports.resolveSourceNumberFormat = exports.isGeneralNumberFormat = void 0;
3
+ exports.valueAxisNameGap = exports.numberFormatToPlotlyTicks = exports.plotlySeparators = exports.circularTooltipFormatter = exports.resolveSeriesNumberFormats = exports.tooltipValueFormatter = exports.valueAxisLabelFormatter = exports.formatAxisValue = exports.formatPlainNumber = exports.resolveValueAxisNumberFormat = exports.resolveSourceNumberFormat = exports.isGeneralNumberFormat = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var utils_1 = require("@rowsncolumns/utils");
6
6
  var patternOf = function (format) {
@@ -62,18 +62,74 @@ var resolveValueAxisNumberFormat = function (_a) {
62
62
  return (0, exports.resolveSourceNumberFormat)((_b = series[0]) === null || _b === void 0 ? void 0 : _b.sources, getFormattingFromRange, hiddenDimensionStrategy);
63
63
  };
64
64
  exports.resolveValueAxisNumberFormat = resolveValueAxisNumberFormat;
65
- /** Format one numeric value through the resolved pattern; non-numbers pass through. */
66
- var formatAxisValue = function (pattern, value) {
65
+ // A number with no number format, in the spreadsheet locale (#1050). The
66
+ // grid's cells show such a value through `General` — the locale's decimal
67
+ // separator, no grouping — so a data label or tooltip reads the same;
68
+ // echarts' default tick label groups thousands, so ticks keep grouping.
69
+ // `toPrecision(15)` is Excel's significant-digit view of the double, which
70
+ // drops binary noise such as `0.30000000000000004`.
71
+ var plainNumberFormatters = new Map();
72
+ var plainNumberFormatter = function (locale, grouping) {
73
+ var key = "".concat(locale, "\0").concat(grouping ? 1 : 0);
74
+ var formatter = plainNumberFormatters.get(key);
75
+ if (!formatter) {
76
+ try {
77
+ formatter = new Intl.NumberFormat(locale, {
78
+ useGrouping: grouping,
79
+ maximumFractionDigits: 20,
80
+ });
81
+ }
82
+ catch (_a) {
83
+ formatter = new Intl.NumberFormat("en-US", {
84
+ useGrouping: grouping,
85
+ maximumFractionDigits: 20,
86
+ });
87
+ }
88
+ plainNumberFormatters.set(key, formatter);
89
+ }
90
+ return formatter;
91
+ };
92
+ var formatPlainNumber = function (value, locale, grouping) {
93
+ if (grouping === void 0) { grouping = false; }
94
+ return Number.isFinite(value)
95
+ ? plainNumberFormatter(locale !== null && locale !== void 0 ? locale : "en-US", grouping).format(Number(value.toPrecision(15)))
96
+ : String(value);
97
+ };
98
+ exports.formatPlainNumber = formatPlainNumber;
99
+ /**
100
+ * Format one numeric value through the resolved pattern; non-numbers pass
101
+ * through. `locale` is the spreadsheet locale the cells format with: it
102
+ * picks the pattern's separators, and a number without a pattern reads
103
+ * like a `General` cell in that locale.
104
+ */
105
+ var formatAxisValue = function (pattern, value, locale) {
67
106
  if (value === undefined || value === null)
68
107
  return "";
69
- if (pattern && typeof value === "number")
70
- return (0, utils_1.ssfFormat)(pattern, value);
108
+ if (typeof value === "number") {
109
+ if (pattern)
110
+ return (0, utils_1.ssfFormat)(pattern, value, locale);
111
+ if (locale)
112
+ return (0, exports.formatPlainNumber)(value, locale);
113
+ }
71
114
  return String(value);
72
115
  };
73
116
  exports.formatAxisValue = formatAxisValue;
74
- /** echarts `axisLabel.formatter` / `tooltip.valueFormatter` for a value axis. */
75
- var valueAxisLabelFormatter = function (pattern) {
76
- return pattern ? function (value) { return (0, exports.formatAxisValue)(pattern, value); } : undefined;
117
+ /**
118
+ * echarts `axisLabel.formatter` / `tooltip.valueFormatter` for a value
119
+ * axis. Without a pattern the ticks keep echarts' own labels unless a
120
+ * locale is given, in which case they group thousands the way echarts
121
+ * does but with the locale's separators (#1050).
122
+ */
123
+ var valueAxisLabelFormatter = function (pattern, locale) {
124
+ return pattern
125
+ ? function (value) { return (0, exports.formatAxisValue)(pattern, value, locale); }
126
+ : locale
127
+ ? function (value) {
128
+ return typeof value === "number"
129
+ ? (0, exports.formatPlainNumber)(value, locale, true)
130
+ : (0, exports.formatAxisValue)(undefined, value);
131
+ }
132
+ : undefined;
77
133
  };
78
134
  exports.valueAxisLabelFormatter = valueAxisLabelFormatter;
79
135
  /**
@@ -82,12 +138,12 @@ exports.valueAxisLabelFormatter = valueAxisLabelFormatter;
82
138
  * pattern; `undefined` when there is no pattern so echarts keeps its
83
139
  * default.
84
140
  */
85
- var tooltipValueFormatter = function (pattern) {
141
+ var tooltipValueFormatter = function (pattern, locale) {
86
142
  return pattern
87
143
  ? function (value) {
88
144
  return Array.isArray(value)
89
- ? value.map(function (entry) { return (0, exports.formatAxisValue)(pattern, entry); })
90
- : (0, exports.formatAxisValue)(pattern, value);
145
+ ? value.map(function (entry) { return (0, exports.formatAxisValue)(pattern, entry, locale); })
146
+ : (0, exports.formatAxisValue)(pattern, value, locale);
91
147
  }
92
148
  : undefined;
93
149
  };
@@ -105,13 +161,35 @@ var resolveSeriesNumberFormats = function (series, getFormattingFromRange, hidde
105
161
  };
106
162
  exports.resolveSeriesNumberFormats = resolveSeriesNumberFormats;
107
163
  /** echarts pie / doughnut tooltip: `name: value (percent%)` with the value formatted. */
108
- var circularTooltipFormatter = function (pattern) {
164
+ var circularTooltipFormatter = function (pattern, locale) {
109
165
  return function (params) {
110
166
  var _a, _b;
111
- return "".concat((_a = params.name) !== null && _a !== void 0 ? _a : "", ": ").concat((0, exports.formatAxisValue)(pattern, params.value), " (").concat((_b = params.percent) !== null && _b !== void 0 ? _b : "", "%)");
167
+ return "".concat((_a = params.name) !== null && _a !== void 0 ? _a : "", ": ").concat((0, exports.formatAxisValue)(pattern, params.value, locale), " (").concat((_b = params.percent) !== null && _b !== void 0 ? _b : "", "%)");
112
168
  };
113
169
  };
114
170
  exports.circularTooltipFormatter = circularTooltipFormatter;
171
+ /**
172
+ * plotly `layout.separators` for the spreadsheet locale: the decimal
173
+ * separator followed by the thousands separator, so ticks and hover
174
+ * values plotly formats itself read like the sheet's cells (#1050).
175
+ * `undefined` without a locale keeps plotly's default (`.,`).
176
+ */
177
+ var plotlySeparators = function (locale) {
178
+ var _a, _b, _c, _d;
179
+ if (!locale)
180
+ return undefined;
181
+ var parts;
182
+ try {
183
+ parts = new Intl.NumberFormat(locale).formatToParts(1234.5);
184
+ }
185
+ catch (_e) {
186
+ return undefined;
187
+ }
188
+ var decimal = (_b = (_a = parts.find(function (p) { return p.type === "decimal"; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ".";
189
+ var group = (_d = (_c = parts.find(function (p) { return p.type === "group"; })) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : ",";
190
+ return "".concat(decimal).concat(group);
191
+ };
192
+ exports.plotlySeparators = plotlySeparators;
115
193
  /**
116
194
  * Translate the numeric subset of a SpreadsheetML pattern into plotly's
117
195
  * d3-format axis settings (`tickformat` + literal prefix / suffix). Plotly
@@ -238,16 +316,16 @@ var measureLabelWidth = function (text, fontSize) {
238
316
  * lets a currency axis title paint over its own tick labels.
239
317
  */
240
318
  var valueAxisNameGap = function (_a) {
241
- var values = _a.values, pattern = _a.pattern, _b = _a.fontSize, fontSize = _b === void 0 ? 12 : _b, _c = _a.minimum, minimum = _c === void 0 ? 50 : _c;
319
+ var values = _a.values, pattern = _a.pattern, locale = _a.locale, _b = _a.fontSize, fontSize = _b === void 0 ? 12 : _b, _c = _a.minimum, minimum = _c === void 0 ? 50 : _c;
242
320
  var numbers = values.filter(function (v) { return typeof v === "number" && Number.isFinite(v); });
243
321
  if (!numbers.length)
244
322
  return minimum;
245
323
  var min = Math.min.apply(Math, tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(numbers), false), [0], false));
246
324
  var max = Math.max.apply(Math, tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(numbers), false), [0], false));
247
325
  // echarts' default axis label puts thousands separators on plain numbers.
248
- var defaultLabel = function (v) { return v.toLocaleString("en-US"); };
326
+ var defaultLabel = function (v) { return (0, exports.formatPlainNumber)(v, locale, true); };
249
327
  var labels = [min, max].map(function (v) {
250
- return pattern ? (0, exports.formatAxisValue)(pattern, v) : defaultLabel(v);
328
+ return pattern ? (0, exports.formatAxisValue)(pattern, v, locale) : defaultLabel(v);
251
329
  });
252
330
  var widest = Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(labels.map(function (l) { return measureLabelWidth(l, fontSize); })), false));
253
331
  // 8px tick-label margin + the rotated title's own line box + breathing room.
@@ -7,9 +7,9 @@ export declare const applyLegendOverrides: (legend: LegendComponentOption, opts:
7
7
  * the linked source-cell format — see `resolveValueAxisNumberFormat`); it
8
8
  * becomes the tick-label formatter.
9
9
  */
10
- export declare const applyAxisOverrides: (axis: any, opts: any, numberFormatPattern?: string) => any;
11
- export declare const dataLabelFormatter: (opts: any) => (params: any) => string;
12
- export declare const buildSeriesLabelOption: (opts: any) => {
10
+ export declare const applyAxisOverrides: (axis: any, opts: any, numberFormatPattern?: string, locale?: string) => any;
11
+ export declare const dataLabelFormatter: (opts: any, locale?: string) => (params: any) => string;
12
+ export declare const buildSeriesLabelOption: (opts: any, seriesType?: string, locale?: string) => {
13
13
  readonly show: true;
14
14
  readonly position: any;
15
15
  readonly formatter: (params: any) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,QA4B7B,CAAC;AAqBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,MAAM,QAAQ,GAAG,WA4B5D,CAAC;AAWF,eAAO,MAAM,sBAAsB,GAAI,MAAM,GAAG;;;iCAvCU,GAAG;aA+C5D,CAAC"}
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,QA4BhB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,SAAS,MAAM,MAAM,QAAQ,GAAG,WAiC7E,CAAC;AAgCF,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCApE0D,GAAG;aAiF7E,CAAC"}
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildSeriesLabelOption = exports.dataLabelFormatter = exports.applyAxisOverrides = exports.applyLegendOverrides = exports.textFormatToEchartsTextStyle = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var utils_1 = require("@rowsncolumns/utils");
6
5
  var axis_number_format_1 = require("./axis-number-format");
7
6
  // Map ChartSpec.legend / dataLabels / axisOptions to ECharts option
8
7
  // fragments. Each helper is a no-op when the spec field is missing, so
@@ -82,9 +81,9 @@ exports.applyLegendOverrides = applyLegendOverrides;
82
81
  * the linked source-cell format — see `resolveValueAxisNumberFormat`); it
83
82
  * becomes the tick-label formatter.
84
83
  */
85
- var applyAxisOverrides = function (axis, opts, numberFormatPattern) {
84
+ var applyAxisOverrides = function (axis, opts, numberFormatPattern, locale) {
86
85
  var _a, _b, _c, _d, _e;
87
- var formatter = (0, axis_number_format_1.valueAxisLabelFormatter)(numberFormatPattern);
86
+ var formatter = (0, axis_number_format_1.valueAxisLabelFormatter)(numberFormatPattern, locale);
88
87
  if (!opts && !formatter)
89
88
  return axis;
90
89
  var next = tslib_1.__assign({}, axis);
@@ -126,14 +125,8 @@ exports.applyAxisOverrides = applyAxisOverrides;
126
125
  * over the normalized percentage so labels read "$1,831" not "84.6"
127
126
  * — Excel's behaviour.
128
127
  */
129
- var formatLabelValue = function (rawValue, originalValue, pattern) {
130
- var target = originalValue !== null && originalValue !== void 0 ? originalValue : rawValue;
131
- if (pattern) {
132
- return (0, utils_1.ssfFormat)(pattern, target);
133
- }
134
- return target === undefined || target === null ? "" : String(target);
135
- };
136
- var dataLabelFormatter = function (opts) { return function (params) {
128
+ var formatLabelValue = function (rawValue, originalValue, pattern, locale) { return (0, axis_number_format_1.formatAxisValue)(pattern, originalValue !== null && originalValue !== void 0 ? originalValue : rawValue, locale); };
129
+ var dataLabelFormatter = function (opts, locale) { return function (params) {
137
130
  var parts = [];
138
131
  if (opts.showSeriesName && params.seriesName)
139
132
  parts.push(params.seriesName);
@@ -156,7 +149,7 @@ var dataLabelFormatter = function (opts) { return function (params) {
156
149
  var originalValue = typeof params.data === "object" && params.data
157
150
  ? params.data.originalValue
158
151
  : undefined;
159
- parts.push(formatLabelValue(params.value, originalValue, opts.numberFormatPattern));
152
+ parts.push(formatLabelValue(params.value, originalValue, opts.numberFormatPattern, locale));
160
153
  }
161
154
  return parts.join(": ");
162
155
  }; };
@@ -168,16 +161,40 @@ var ECHARTS_DLBL_POS = {
168
161
  insideEnd: "insideTop",
169
162
  outsideEnd: "top",
170
163
  bestFit: "top",
164
+ above: "top",
165
+ below: "bottom",
166
+ left: "left",
167
+ right: "right",
168
+ };
169
+ // A line / scatter label sits on a point, not in a bar: echarts has no
170
+ // `outside` / `insideTop` for it (an unknown position is drawn at the
171
+ // default) and Excel offers centre / left / right / above / below. The
172
+ // bar-only placements land on Excel's default for a line, above the point.
173
+ var ECHARTS_POINT_DLBL_POS = {
174
+ center: "inside",
175
+ inside: "inside",
176
+ outside: "top",
177
+ insideEnd: "top",
178
+ outsideEnd: "top",
179
+ bestFit: "top",
180
+ above: "top",
181
+ below: "bottom",
182
+ left: "left",
183
+ right: "right",
171
184
  };
172
- var buildSeriesLabelOption = function (opts) {
185
+ var POINT_SERIES_TYPES = new Set(["line", "scatter", "effectScatter"]);
186
+ var buildSeriesLabelOption = function (opts, seriesType, locale) {
173
187
  var _a;
174
188
  if (!(opts === null || opts === void 0 ? void 0 : opts.show))
175
189
  return undefined;
176
- var position = (_a = (opts.position && ECHARTS_DLBL_POS[opts.position])) !== null && _a !== void 0 ? _a : "top";
190
+ var positions = seriesType && POINT_SERIES_TYPES.has(seriesType)
191
+ ? ECHARTS_POINT_DLBL_POS
192
+ : ECHARTS_DLBL_POS;
193
+ var position = (_a = (opts.position && positions[opts.position])) !== null && _a !== void 0 ? _a : "top";
177
194
  return {
178
195
  show: true,
179
196
  position: position,
180
- formatter: (0, exports.dataLabelFormatter)(opts),
197
+ formatter: (0, exports.dataLabelFormatter)(opts, locale),
181
198
  };
182
199
  };
183
200
  exports.buildSeriesLabelOption = buildSeriesLabelOption;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import type { EChartComponentProps } from "../types";
3
3
  export type BasicChartProps = EChartComponentProps;
4
- export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, }: BasicChartProps) => React.JSX.Element;
4
+ export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, }: BasicChartProps) => React.JSX.Element;
5
5
  //# sourceMappingURL=basic-chart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAmQrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAqEnD,eAAO,MAAM,UAAU,GAAI,wOAiBxB,eAAe,sBAwzGjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAmQrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAqEnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA02GjB,CAAC"}