@rowsncolumns/charts 28.1.16 → 28.1.18

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 (52) hide show
  1. package/Readme.md +18 -1
  2. package/dist/cjs/basic-chart/basic-chart.d.ts +1 -1
  3. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  4. package/dist/cjs/basic-chart/basic-chart.js +204 -172
  5. package/dist/cjs/components/editors/chart-editor.d.ts +7 -1
  6. package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
  7. package/dist/cjs/components/editors/chart-editor.js +3 -2
  8. package/dist/cjs/components/editors/fields/text-format-fields.d.ts +5 -3
  9. package/dist/cjs/components/editors/fields/text-format-fields.d.ts.map +1 -1
  10. package/dist/cjs/components/editors/fields/text-format-fields.js +6 -6
  11. package/dist/cjs/config.d.ts +10 -0
  12. package/dist/cjs/config.d.ts.map +1 -1
  13. package/dist/cjs/config.js +45 -10
  14. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  15. package/dist/cjs/plotly/basic-chart/basic-chart.js +43 -4
  16. package/dist/cjs/types.d.ts +10 -0
  17. package/dist/cjs/types.d.ts.map +1 -1
  18. package/dist/cjs/utils/echarts-gl-loader.d.ts +6 -0
  19. package/dist/cjs/utils/echarts-gl-loader.d.ts.map +1 -1
  20. package/dist/cjs/utils/echarts-gl-loader.js +42 -1
  21. package/dist/cjs/utils/overrides.d.ts +20 -0
  22. package/dist/cjs/utils/overrides.d.ts.map +1 -1
  23. package/dist/cjs/utils/overrides.js +28 -7
  24. package/dist/cjs/utils/three-d.d.ts +12 -1
  25. package/dist/cjs/utils/three-d.d.ts.map +1 -1
  26. package/dist/cjs/utils/three-d.js +4 -1
  27. package/dist/esm/basic-chart/basic-chart.d.ts +1 -1
  28. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  29. package/dist/esm/basic-chart/basic-chart.js +79 -56
  30. package/dist/esm/components/editors/chart-editor.d.ts +7 -1
  31. package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
  32. package/dist/esm/components/editors/chart-editor.js +4 -3
  33. package/dist/esm/components/editors/fields/text-format-fields.d.ts +5 -3
  34. package/dist/esm/components/editors/fields/text-format-fields.d.ts.map +1 -1
  35. package/dist/esm/components/editors/fields/text-format-fields.js +6 -6
  36. package/dist/esm/config.d.ts +10 -0
  37. package/dist/esm/config.d.ts.map +1 -1
  38. package/dist/esm/config.js +20 -0
  39. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  40. package/dist/esm/plotly/basic-chart/basic-chart.js +44 -2
  41. package/dist/esm/types.d.ts +10 -0
  42. package/dist/esm/types.d.ts.map +1 -1
  43. package/dist/esm/utils/echarts-gl-loader.d.ts +6 -0
  44. package/dist/esm/utils/echarts-gl-loader.d.ts.map +1 -1
  45. package/dist/esm/utils/echarts-gl-loader.js +40 -0
  46. package/dist/esm/utils/overrides.d.ts +20 -0
  47. package/dist/esm/utils/overrides.d.ts.map +1 -1
  48. package/dist/esm/utils/overrides.js +22 -0
  49. package/dist/esm/utils/three-d.d.ts +12 -1
  50. package/dist/esm/utils/three-d.d.ts.map +1 -1
  51. package/dist/esm/utils/three-d.js +4 -1
  52. package/package.json +2 -2
@@ -20,7 +20,7 @@ import { canSwitchRowColumn, cellLabelGetterFromRangeReader, switchRowColumn, }
20
20
  import { coerceCalculatedLabel, getChartDataRanges, } from "../utils/chart-spec-utils";
21
21
  import { getChartPalette } from "../utils/chart-styles";
22
22
  import { clampDoughnutHole, doughnutRings } from "../utils/doughnut";
23
- import { getEchartsGlState, loadEchartsGl, } from "../utils/echarts-gl-loader";
23
+ import { getEchartsGlState, loadEchartsGl, markEchartsGlFailed, } from "../utils/echarts-gl-loader";
24
24
  import { buildEchartsOverlaySeries } from "../utils/echarts-overlays";
25
25
  import { applyEmptyCellsPolicy, connectsAcrossEmptyCells, isLineLikeChartType, isolatedPointIndexes, } from "../utils/empty-cells";
26
26
  import { gradientToEcharts } from "../utils/gradient";
@@ -29,6 +29,7 @@ import { aggregateByCategory, binHistogram, computePareto, isParetoSpec, } from
29
29
  import { categoryAxisNameGap, legendLabelsFrom, reserveEchartsLegendBand, } from "../utils/legend-layout";
30
30
  import { clampSecondPieSize, isOfPieChartSpec, otherSliceHalfAngle, resolveOfPieType, splitOfPie, } from "../utils/of-pie";
31
31
  import { applyAxisOverrides, applyLegendOverrides, buildSeriesLabelOption, dataLabelFormatter, resolveSeriesDataLabels, } from "../utils/overrides";
32
+ import { themedTextStyle } from "../utils/overrides";
32
33
  import { explosionOffsetPx, pieRadiusPx, resolveExplosion, } from "../utils/pie-explosion";
33
34
  import { buildRadarIndicators, buildRadarSeriesData } from "../utils/radar";
34
35
  import { buildRegionMapData, buildSequentialColorRamp, isRegionMapSpec, resolveGeoScope, warnOnceForUnmatchedRegions, } from "../utils/region-map";
@@ -247,7 +248,7 @@ const defaultLegendConfig = {
247
248
  };
248
249
  /** Category-axis title gap: clears one row of tick labels (#986). */
249
250
  const CATEGORY_AXIS_NAME_GAP = categoryAxisNameGap();
250
- export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, }) => {
251
+ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, enable3D, }) => {
251
252
  const spec = chart.spec;
252
253
  const explicitChartTitle = chart.spec.title ?? undefined;
253
254
  const hierarchyTitleRef = useRef(explicitChartTitle);
@@ -427,7 +428,7 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
427
428
  // SSR, import failure, PIE_3D) the 2-D fallback renders untouched.
428
429
  // The 3-D and region-map gates key off disjoint sourceChartType
429
430
  // tokens, so a spec can never satisfy both.
430
- const threeDRenderKind = resolve3DRenderKind(spec.sourceChartType);
431
+ const threeDRenderKind = resolve3DRenderKind(spec.sourceChartType, { enable3D });
431
432
  const canRender3D = threeDRenderKind !== null && isWebGLAvailable();
432
433
  const willRender3D = canRender3D && getEchartsGlState() === "ready";
433
434
  if (canRender3D && !willRender3D && getEchartsGlState() !== "failed") {
@@ -1326,38 +1327,63 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
1326
1327
  inRange: { color: [...SURFACE_COLOR_RAMP] },
1327
1328
  };
1328
1329
  }
1329
- chartRef.current?.setOption({
1330
- tooltip: {
1331
- textStyle: { fontSize: 12 },
1332
- formatter: threeDTooltipFormatter,
1333
- },
1334
- legend: threeDRenderKind === "line3D" || stackedBar3D
1335
- ? applyLegendOverrides({
1336
- ...defaultLegendConfig,
1337
- show: seriesNames.length > 1,
1338
- data: seriesNames,
1339
- }, spec.legend)
1340
- : { show: false },
1341
- xAxis3D: { ...xAxis3D, name: spec.horizontalAxisTitle ?? "" },
1342
- yAxis3D: { ...yAxis3D, name: "" },
1343
- zAxis3D: { type: "value", name: spec.verticalAxisTitle ?? "" },
1344
- grid3D: {
1345
- boxDepth: Math.max(20, Math.min(100, seriesNames.length * 20)),
1346
- viewControl: { autoRotate: false },
1347
- },
1348
- ...(visualMap ? { visualMap: [visualMap] } : {}),
1349
- series: threeDSeries,
1350
- }, {
1351
- replaceMerge: [
1352
- "series",
1353
- "xAxis3D",
1354
- "yAxis3D",
1355
- "zAxis3D",
1356
- "visualMap",
1357
- "legend",
1358
- "tooltip",
1359
- ],
1360
- });
1330
+ // echarts-gl builds its GL scene inside setOption, and that can
1331
+ // throw after the module loaded fine — claygl compiles compositor
1332
+ // sizes with `new Function`, which a CSP without 'unsafe-eval'
1333
+ // blocks (rowsncolumns/spreadsheet#1187). Latch the failure so no
1334
+ // chart retries 3-D, drop the half-built instance and draw the 2-D
1335
+ // fallback instead of leaving the chart blank.
1336
+ try {
1337
+ chartRef.current?.setOption({
1338
+ tooltip: {
1339
+ textStyle: { fontSize: 12 },
1340
+ formatter: threeDTooltipFormatter,
1341
+ },
1342
+ legend: threeDRenderKind === "line3D" || stackedBar3D
1343
+ ? applyLegendOverrides({
1344
+ ...defaultLegendConfig,
1345
+ show: seriesNames.length > 1,
1346
+ data: seriesNames,
1347
+ }, spec.legend)
1348
+ : { show: false },
1349
+ xAxis3D: { ...xAxis3D, name: spec.horizontalAxisTitle ?? "" },
1350
+ yAxis3D: { ...yAxis3D, name: "" },
1351
+ zAxis3D: { type: "value", name: spec.verticalAxisTitle ?? "" },
1352
+ grid3D: {
1353
+ boxDepth: Math.max(20, Math.min(100, seriesNames.length * 20)),
1354
+ viewControl: { autoRotate: false },
1355
+ },
1356
+ ...(visualMap ? { visualMap: [visualMap] } : {}),
1357
+ series: threeDSeries,
1358
+ }, {
1359
+ replaceMerge: [
1360
+ "series",
1361
+ "xAxis3D",
1362
+ "yAxis3D",
1363
+ "zAxis3D",
1364
+ "visualMap",
1365
+ "legend",
1366
+ "tooltip",
1367
+ ],
1368
+ });
1369
+ }
1370
+ catch (error) {
1371
+ markEchartsGlFailed(error);
1372
+ try {
1373
+ chartRef.current?.dispose();
1374
+ }
1375
+ catch {
1376
+ // A GL instance that threw mid-build may not dispose cleanly.
1377
+ }
1378
+ chartRef.current = undefined;
1379
+ renderedIn3D.current = false;
1380
+ previousChartType.current = undefined;
1381
+ previousSeriesCount.current = undefined;
1382
+ initializeChart();
1383
+ applyThemeOptions();
1384
+ await updateChart();
1385
+ return;
1386
+ }
1361
1387
  // Re-apply theme-derived title / palette / tooltip colors — lost
1362
1388
  // when the instance was re-initialized on entry into 3-D.
1363
1389
  renderedIn3D.current = true;
@@ -3175,28 +3201,20 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
3175
3201
  const options = {
3176
3202
  title: {
3177
3203
  text: title ?? undefined,
3178
- textStyle: {
3179
- color: authoredTitleFmt?.color ?? textColor,
3180
- ...(authoredTitleFmt?.fontFamily
3181
- ? { fontFamily: authoredTitleFmt.fontFamily }
3182
- : {}),
3183
- ...(typeof authoredTitleFmt?.fontSize === "number"
3184
- ? { fontSize: authoredTitleFmt.fontSize }
3185
- : {}),
3186
- ...(authoredTitleFmt?.bold ? { fontWeight: "bold" } : {}),
3187
- ...(authoredTitleFmt?.italic ? { fontStyle: "italic" } : {}),
3188
- },
3204
+ // Every key is written (echarts merges setOption calls, so a key
3205
+ // left out keeps its previous value — turning bold off used to
3206
+ // leave the title bold, rowsncolumns/spreadsheet#1105).
3207
+ textStyle: themedTextStyle(authoredTitleFmt, {
3208
+ color: textColor,
3209
+ fontSize: 18,
3210
+ fontWeight: "bold",
3211
+ }),
3189
3212
  },
3190
3213
  legend: {
3191
- textStyle: {
3192
- color: authoredLegendFmt?.color ?? textColor,
3193
- ...(authoredLegendFmt?.fontFamily
3194
- ? { fontFamily: authoredLegendFmt.fontFamily }
3195
- : {}),
3196
- ...(typeof authoredLegendFmt?.fontSize === "number"
3197
- ? { fontSize: authoredLegendFmt.fontSize }
3198
- : {}),
3199
- },
3214
+ textStyle: themedTextStyle(authoredLegendFmt, {
3215
+ color: textColor,
3216
+ fontSize: 12,
3217
+ }),
3200
3218
  },
3201
3219
  axisLabel: {
3202
3220
  color: authoredDataLabelFmt?.color ?? textColor,
@@ -3239,7 +3257,9 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
3239
3257
  chartRef.current.setOption(options);
3240
3258
  }
3241
3259
  };
3242
- // Update chart properties
3260
+ // Update chart properties — the authored text formats are inputs too, so
3261
+ // a font change applies at once instead of waiting for the next title
3262
+ // edit (rowsncolumns/spreadsheet#1105).
3243
3263
  useIsomorphicLayoutEffect(() => {
3244
3264
  applyThemeOptions();
3245
3265
  }, [
@@ -3249,6 +3269,9 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
3249
3269
  chart.spec.chartType,
3250
3270
  chart.spec.palette,
3251
3271
  chart.spec.backgroundColor,
3272
+ chart.spec.titleTextFormat,
3273
+ chart.spec.legend?.textFormat,
3274
+ chart.spec.dataLabels?.textFormat,
3252
3275
  ]);
3253
3276
  // Draw chart. `glUpgradeTick` re-runs the draw when the lazily loaded
3254
3277
  // echarts-gl module resolves, upgrading a 3-D spec's immediate 2-D
@@ -16,7 +16,13 @@ type ChartEditorProps = {
16
16
  * from the data range. Without it the switched series are unnamed.
17
17
  */
18
18
  getFormattedValue?: ChartCellLabelGetter;
19
+ /**
20
+ * Mirror of the renderer's `enable3D`: `false` hides the presets that
21
+ * render through echarts-gl (3-D Column / Bar / Line / Area / Surface).
22
+ * An existing 3-D spec keeps its `sourceChartType`. Default `true`.
23
+ */
24
+ enable3D?: boolean;
19
25
  };
20
- export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, }: ChartEditorProps) => React.JSX.Element;
26
+ export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, enable3D, }: ChartEditorProps) => React.JSX.Element;
21
27
  export default ChartEditor;
22
28
  //# sourceMappingURL=chart-editor.d.ts.map
@@ -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;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,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,sBAkhClB,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;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,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;IACzC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAuBF,eAAO,MAAM,WAAW,GAAI,gFAOzB,gBAAgB,sBAmhClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -7,7 +7,7 @@ import { uuid } from "@rowsncolumns/utils";
7
7
  import { useFormik } from "formik";
8
8
  import React, { useMemo } from "react";
9
9
  import { useSetChartEditorDialogState } from "../../atoms/editing-chart.atom";
10
- import { CHART_TYPES, getChartPresetLabel } from "../../config";
10
+ import { getChartPresetLabel, getChartTypes } from "../../config";
11
11
  import { canSwitchRowColumn, inferSeriesOrientation, switchRowColumn, } from "../../utils/chart-orientation";
12
12
  import { isBasicChartSpec, isBubbleChartSpec, isHierarchyChartSpec, mergeChartSpec, } from "../../utils/chart-spec-utils";
13
13
  import { applyChartColorPalette, applyChartQuickLayout, applyChartStyle, CHART_COLOR_PALETTES, CHART_QUICK_LAYOUTS, CHART_STYLES, resetChartToMatchStyle, } from "../../utils/chart-styles";
@@ -47,8 +47,9 @@ const Section = ({ title, defaultOpen = false, children, }) => (React.createElem
47
47
  React.createElement(ChevronRightIcon, { className: "shrink-0 transition-transform group-open:rotate-90" }),
48
48
  title),
49
49
  React.createElement("div", { className: "flex flex-col gap-2 pb-3" }, children)));
50
- export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, }) => {
50
+ export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, enable3D, }) => {
51
51
  const setChartDialogState = useSetChartEditorDialogState();
52
+ const chartTypes = getChartTypes({ enable3D });
52
53
  // Close dialog
53
54
  const closeDialog = () => setChartDialogState(false);
54
55
  // Keyed on chart identity so a position sync (move/resize while the
@@ -218,7 +219,7 @@ export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getF
218
219
  React.createElement(DropdownRightSlot, null,
219
220
  React.createElement(TriangleDownIcon, null)))),
220
221
  React.createElement(DropdownMenuPortal, null,
221
- React.createElement(DropdownMenuContent, { align: "start", sideOffset: 0 }, CHART_TYPES.map(([category, types]) => {
222
+ React.createElement(DropdownMenuContent, { align: "start", sideOffset: 0 }, chartTypes.map(([category, types]) => {
222
223
  return (React.createElement(DropdownMenuSub, { key: category },
223
224
  React.createElement(DropdownMenuSubTrigger, null,
224
225
  React.createElement(DropdownLeftSlot, null,
@@ -1,9 +1,11 @@
1
1
  import type { ChartTextFormat } from "@rowsncolumns/spreadsheet";
2
2
  import React from "react";
3
3
  /**
4
- * Font family / size / colour / bold / italic / underline / strikethrough
5
- * of one text element — the chart title, the legend, an axis or the data
6
- * labels (`ChartTextFormat`, OOXML `<c:txPr>`).
4
+ * Font family / size / colour / bold / italic of one text element — the
5
+ * chart title, the legend, an axis or the data labels (`ChartTextFormat`,
6
+ * OOXML `<c:txPr>`). `underline` / `strikethrough` stay on the spec for the
7
+ * xlsx round trip but have no control: neither renderer draws them
8
+ * (rowsncolumns/spreadsheet#1105).
7
9
  */
8
10
  export declare const TextFormatFields: ({ label, value, onChange, collapsible, ariaLabels, }: {
9
11
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"text-format-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/text-format-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,sDAM9B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IAClD,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,sBA6EA,CAAC"}
1
+ {"version":3,"file":"text-format-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/text-format-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,sDAM9B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IAClD,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,sBAmEA,CAAC"}
@@ -2,9 +2,11 @@ import { Input } from "@rowsncolumns/ui";
2
2
  import React, { useState } from "react";
3
3
  import { CheckboxField, COLOR_CLASS } from "./primitives";
4
4
  /**
5
- * Font family / size / colour / bold / italic / underline / strikethrough
6
- * of one text element — the chart title, the legend, an axis or the data
7
- * labels (`ChartTextFormat`, OOXML `<c:txPr>`).
5
+ * Font family / size / colour / bold / italic of one text element — the
6
+ * chart title, the legend, an axis or the data labels (`ChartTextFormat`,
7
+ * OOXML `<c:txPr>`). `underline` / `strikethrough` stay on the spec for the
8
+ * xlsx round trip but have no control: neither renderer draws them
9
+ * (rowsncolumns/spreadsheet#1105).
8
10
  */
9
11
  export const TextFormatFields = ({ label, value, onChange, collapsible = false, ariaLabels, }) => {
10
12
  const [open, setOpen] = useState(!collapsible);
@@ -28,7 +30,5 @@ export const TextFormatFields = ({ label, value, onChange, collapsible = false,
28
30
  }), className: "text-xs w-16", placeholder: "Size", "aria-label": ariaLabels?.size ?? `${label} size` }),
29
31
  React.createElement("input", { type: "color", value: value?.color ?? "#000000", onChange: (e) => set({ color: e.target.value }), className: COLOR_CLASS, "aria-label": ariaLabels?.color ?? `${label} color` }),
30
32
  React.createElement(CheckboxField, { label: "Bold", checked: Boolean(value?.bold), onChange: (bold) => set({ bold }) }),
31
- React.createElement(CheckboxField, { label: "Italic", checked: Boolean(value?.italic), onChange: (italic) => set({ italic }) }),
32
- React.createElement(CheckboxField, { label: "Underline", checked: Boolean(value?.underline), onChange: (underline) => set({ underline }) }),
33
- React.createElement(CheckboxField, { label: "Strikethrough", checked: Boolean(value?.strikethrough), onChange: (strikethrough) => set({ strikethrough }) }))));
33
+ React.createElement(CheckboxField, { label: "Italic", checked: Boolean(value?.italic), onChange: (italic) => set({ italic }) }))));
34
34
  };
@@ -1,5 +1,15 @@
1
1
  import type { ChartSpec } from "@rowsncolumns/spreadsheet";
2
+ import { type ThreeDRenderOptions } from "./utils/three-d";
2
3
  export declare const CHART_TYPES: Array<[string, Array<[string, Partial<ChartSpec>]>]>;
4
+ /**
5
+ * The Chart editor's preset list. With `enable3D: false` the presets the
6
+ * renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
7
+ * their stacked variants and 3-D Surface) are left out; 3-D Pie and
8
+ * Contour stay since they never render in WebGL. A spec that already
9
+ * carries a 3-D `sourceChartType` is not rewritten — only the picker
10
+ * changes (rowsncolumns/spreadsheet#1187).
11
+ */
12
+ export declare const getChartTypes: (options?: ThreeDRenderOptions) => Array<[string, Array<[string, Partial<ChartSpec>]>]>;
3
13
  /**
4
14
  * True when a spec is doughnut-shaped: the first-class
5
15
  * `chartType: "doughnut"` token, or the two legacy pie encodings —
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAwR3D,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAgB1E,CAAC;AAYJ;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAQzD,CAAC;AAuBF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,MA4B9D,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAsRhF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAgB1E,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,mBAAmB,KAC5B,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAarD,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAQzD,CAAC;AAuBF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,MA4B9D,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { DEFAULT_PIE_EXPLOSION } from "./utils/pie-explosion";
2
+ import { resolve3DRenderKind } from "./utils/three-d";
2
3
  // Excel's 3-D chart classes degrade to a 2-D chartType with the authored
3
4
  // class kept as `sourceChartType` (BAR_3D, LINE_3D, PIE_3D, AREA_3D,
4
5
  // SURFACE, SURFACE_3D). The renderer draws BAR_3D / LINE_3D / AREA_3D /
@@ -273,6 +274,25 @@ export const CHART_TYPES = [
273
274
  ["Stock", STOCK_CHART_TYPES],
274
275
  ["Combo", COMBO_CHART_TYPES],
275
276
  ];
277
+ /**
278
+ * The Chart editor's preset list. With `enable3D: false` the presets the
279
+ * renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
280
+ * their stacked variants and 3-D Surface) are left out; 3-D Pie and
281
+ * Contour stay since they never render in WebGL. A spec that already
282
+ * carries a 3-D `sourceChartType` is not rewritten — only the picker
283
+ * changes (rowsncolumns/spreadsheet#1187).
284
+ */
285
+ export const getChartTypes = (options) => {
286
+ if (options?.enable3D !== false)
287
+ return CHART_TYPES;
288
+ const groups = [];
289
+ for (const [category, presets] of CHART_TYPES) {
290
+ const kept = presets.filter(([, preset]) => resolve3DRenderKind(preset.sourceChartType) === null);
291
+ if (kept.length > 0)
292
+ groups.push([category, kept]);
293
+ }
294
+ return groups;
295
+ };
276
296
  /** Parse a radius entry ("40%" | 40 | 0) into a number, NaN-safe. */
277
297
  const parseRadiusValue = (value) => {
278
298
  if (typeof value === "number")
@@ -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;AA+ZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA2rFjB,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;AAkcxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA8rFjB,CAAC"}
@@ -230,6 +230,15 @@ const applyDataLabelsToTracePlotly = (trace, opts, chartType, sourceNumberFormat
230
230
  parts.push("percent");
231
231
  next.textinfo = parts.length ? parts.join("+") : "value";
232
232
  next.textposition = position;
233
+ if (opts.textFormat) {
234
+ const fmt = opts.textFormat;
235
+ next.textfont = {
236
+ ...(next.textfont ?? {}),
237
+ ...(fmt.fontFamily ? { family: fmt.fontFamily } : {}),
238
+ ...(typeof fmt.fontSize === "number" && fmt.fontSize > 0 ? { size: fmt.fontSize } : {}),
239
+ ...(fmt.color ? { color: fmt.color } : {}),
240
+ };
241
+ }
233
242
  // Values format like their source cells (or the authored `<c:numFmt>`):
234
243
  // plotly's own `%{value}` is a raw number, so the formatted strings
235
244
  // ride on `text` and a `texttemplate` mirrors the textinfo parts.
@@ -263,6 +272,39 @@ const applyDataLabelsToTracePlotly = (trace, opts, chartType, sourceNumberFormat
263
272
  if (isPoint)
264
273
  next.mode = withTextMode(next.mode);
265
274
  }
275
+ return applyDataLabelFontPlotly(next, opts.textFormat);
276
+ };
277
+ /**
278
+ * Excel's Format Data Labels → Font for a plotly trace: `textfont` carries
279
+ * family / size / colour, bold / italic are pseudo-HTML tags around each
280
+ * label (plotly fonts have no weight) — rowsncolumns/spreadsheet#1105.
281
+ */
282
+ const applyDataLabelFontPlotly = (trace, fmt) => {
283
+ if (!fmt)
284
+ return trace;
285
+ const next = { ...trace };
286
+ const textfont = { ...(next.textfont ?? {}) };
287
+ if (fmt.fontFamily)
288
+ textfont.family = fmt.fontFamily;
289
+ if (typeof fmt.fontSize === "number" && fmt.fontSize > 0)
290
+ textfont.size = fmt.fontSize;
291
+ if (fmt.color)
292
+ textfont.color = fmt.color;
293
+ if (Object.keys(textfont).length)
294
+ next.textfont = textfont;
295
+ const wrap = (text) => {
296
+ if (text === null || text === undefined || text === "")
297
+ return text;
298
+ let out = String(text);
299
+ if (fmt.italic)
300
+ out = `<i>${out}</i>`;
301
+ if (fmt.bold)
302
+ out = `<b>${out}</b>`;
303
+ return out;
304
+ };
305
+ if ((fmt.bold || fmt.italic) && next.text !== undefined) {
306
+ next.text = Array.isArray(next.text) ? next.text.map(wrap) : wrap(next.text);
307
+ }
266
308
  return next;
267
309
  };
268
310
  const BUBBLE_CHART_TYPES = new Set([
@@ -617,12 +659,12 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
617
659
  "top center"
618
660
  : undefined;
619
661
  const withLabels = (trace) => labelText
620
- ? {
662
+ ? applyDataLabelFontPlotly({
621
663
  ...trace,
622
664
  mode: withTextMode(trace.mode),
623
665
  text: labelText,
624
666
  textposition: labelPosition,
625
- }
667
+ }, labelOpts?.textFormat)
626
668
  : trace;
627
669
  if (isScatter) {
628
670
  // Per-series marker.symbol = "none" → pure line (no markers).
@@ -21,6 +21,16 @@ export type EChartComponentProps = ChartComponentProps & {
21
21
  * honored.
22
22
  */
23
23
  getFormattingFromRange?: ReturnType<typeof useSpreadsheetState>["getFormattingFromRange"];
24
+ /**
25
+ * Draw BAR_3D / LINE_3D / AREA_3D / SURFACE_3D specs through echarts-gl
26
+ * (WebGL). `false` keeps them on their 2-D fallback and never loads
27
+ * echarts-gl — for a page whose Content-Security-Policy has no
28
+ * `'unsafe-eval'`, which claygl needs. The spec keeps its
29
+ * `sourceChartType`, so the xlsx export still writes the 3-D chart. Pass
30
+ * the same value to `ChartEditor` so it hides the 3-D presets. Default
31
+ * `true`.
32
+ */
33
+ enable3D?: boolean;
24
34
  /**
25
35
  * Request edit chart
26
36
  * @param chart
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
@@ -1,5 +1,11 @@
1
1
  export type EchartsGlLoadState = "unloaded" | "loading" | "ready" | "failed";
2
2
  export declare const getEchartsGlState: () => EchartsGlLoadState;
3
+ /**
4
+ * Record that the loaded module failed at render time (echarts-gl threw
5
+ * from `setOption`), so the renderer keeps the 2-D fallback and never
6
+ * retries 3-D for the rest of the page's lifetime. Warns once per page.
7
+ */
8
+ export declare const markEchartsGlFailed: (error?: unknown) => void;
3
9
  /**
4
10
  * Kick off (or join) the echarts-gl dynamic import and register the 3-D
5
11
  * charts/components the renderer uses. Resolves true when 3-D rendering is
@@ -1 +1 @@
1
- {"version":3,"file":"echarts-gl-loader.d.ts","sourceRoot":"","sources":["../../../utils/echarts-gl-loader.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAK7E,eAAO,MAAM,iBAAiB,QAAO,kBAA2B,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,OAAO,CAyB/C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,QAAO,IAGjD,CAAC"}
1
+ {"version":3,"file":"echarts-gl-loader.d.ts","sourceRoot":"","sources":["../../../utils/echarts-gl-loader.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAK7E,eAAO,MAAM,iBAAiB,QAAO,kBAA2B,CAAC;AAgBjE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,OAAO,KAAG,IAUrD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,OAAO,CA8B/C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,QAAO,IAGjD,CAAC"}
@@ -7,12 +7,47 @@
7
7
  * draws the 2-D fallback immediately, and upgrades to 3-D when the module
8
8
  * resolves. A failed import latches the "failed" state so the renderer
9
9
  * keeps the 2-D fallback without retrying on every update.
10
+ *
11
+ * A page whose Content-Security-Policy has no `'unsafe-eval'` is treated
12
+ * the same way: echarts-gl's `EffectCompositor` makes claygl compile its
13
+ * size expressions with `new Function`, which the browser blocks there
14
+ * (`EvalError`, surfaced by claygl as "Invalid expression."). The import
15
+ * itself still succeeds, so the loader probes `new Function` once before
16
+ * importing and latches "failed" instead of letting `setOption` throw
17
+ * later (rowsncolumns/spreadsheet#1187).
10
18
  */
11
19
  import { VisualMapComponent } from "echarts/components";
12
20
  import * as echarts from "echarts/core";
13
21
  let state = "unloaded";
14
22
  let loadPromise = null;
15
23
  export const getEchartsGlState = () => state;
24
+ /**
25
+ * True when the page lets scripts construct functions from source — what
26
+ * claygl needs for every GL chart. False under a CSP whose `script-src`
27
+ * lacks `'unsafe-eval'`.
28
+ */
29
+ const canEvaluateCode = () => {
30
+ try {
31
+ new Function("");
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ };
38
+ /**
39
+ * Record that the loaded module failed at render time (echarts-gl threw
40
+ * from `setOption`), so the renderer keeps the 2-D fallback and never
41
+ * retries 3-D for the rest of the page's lifetime. Warns once per page.
42
+ */
43
+ export const markEchartsGlFailed = (error) => {
44
+ if (state !== "failed") {
45
+ // eslint-disable-next-line no-console
46
+ console.warn("echarts-gl failed to render a 3-D chart; 3-D charts render as their 2-D fallback on this page.", error);
47
+ }
48
+ state = "failed";
49
+ loadPromise = Promise.resolve(false);
50
+ };
16
51
  /**
17
52
  * Kick off (or join) the echarts-gl dynamic import and register the 3-D
18
53
  * charts/components the renderer uses. Resolves true when 3-D rendering is
@@ -20,6 +55,11 @@ export const getEchartsGlState = () => state;
20
55
  */
21
56
  export const loadEchartsGl = () => {
22
57
  if (!loadPromise) {
58
+ if (!canEvaluateCode()) {
59
+ state = "failed";
60
+ loadPromise = Promise.resolve(false);
61
+ return loadPromise;
62
+ }
23
63
  state = "loading";
24
64
  loadPromise = Promise.all([
25
65
  import("echarts-gl/charts"),
@@ -1,4 +1,24 @@
1
1
  import type { LegendComponentOption } from "echarts";
2
+ /**
3
+ * A complete echarts `textStyle` for a text element: the authored
4
+ * `ChartTextFormat` over the theme defaults, with every key present so a
5
+ * cleared setting (bold off, size blank) resets the element instead of
6
+ * keeping the previous merged value (rowsncolumns/spreadsheet#1105).
7
+ * Underline / strikethrough have no canvas text decoration in echarts and
8
+ * are not drawn.
9
+ */
10
+ export declare const themedTextStyle: (fmt: any, defaults: {
11
+ color: string;
12
+ fontSize: number;
13
+ fontFamily?: string;
14
+ fontWeight?: "normal" | "bold";
15
+ }) => {
16
+ color: any;
17
+ fontFamily: any;
18
+ fontSize: any;
19
+ fontWeight: "bold" | "normal";
20
+ fontStyle: "italic" | "normal";
21
+ };
2
22
  /** Build an echarts `textStyle` from a parsed `ChartTextFormat`. */
3
23
  export declare const textFormatToEchartsTextStyle: (fmt: any) => Record<string, any> | undefined;
4
24
  export declare const applyLegendOverrides: (legend: LegendComponentOption, opts: any) => LegendComponentOption;
@@ -1 +1 @@
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,GAC7B,MAAM,GAAG,EACT,SAAS,MAAM,EAEf,eAAa,MACT,QAAQ,GAAG,WAoDhB,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCAlGH,GAAG;aA+GhB,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;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,GAAG,EACR,UAAU;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC;;;;gBASG,MAAM,GACN,QAAQ;eACsC,QAAQ,GAAG,QAAQ;CACrE,CAAC;AAEH,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,GAC7B,MAAM,GAAG,EACT,SAAS,MAAM,EAEf,eAAa,MACT,QAAQ,GAAG,WAoDhB,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCAlGH,GAAG;aAoHhB,CAAC"}
@@ -5,6 +5,23 @@ import { formatAxisValue, valueAxisLabelFormatter } from "./axis-number-format";
5
5
  // option assembly and the bubble / hierarchy / radar / stock early
6
6
  // branches in `basic-chart.tsx` so every chart type honors the same
7
7
  // spec-level overrides.
8
+ /**
9
+ * A complete echarts `textStyle` for a text element: the authored
10
+ * `ChartTextFormat` over the theme defaults, with every key present so a
11
+ * cleared setting (bold off, size blank) resets the element instead of
12
+ * keeping the previous merged value (rowsncolumns/spreadsheet#1105).
13
+ * Underline / strikethrough have no canvas text decoration in echarts and
14
+ * are not drawn.
15
+ */
16
+ export const themedTextStyle = (fmt, defaults) => ({
17
+ color: fmt?.color ?? defaults.color,
18
+ fontFamily: fmt?.fontFamily ?? defaults.fontFamily ?? "sans-serif",
19
+ fontSize: typeof fmt?.fontSize === "number" && fmt.fontSize > 0
20
+ ? fmt.fontSize
21
+ : defaults.fontSize,
22
+ fontWeight: (fmt ? (fmt.bold ? "bold" : "normal") : defaults.fontWeight ?? "normal"),
23
+ fontStyle: (fmt?.italic ? "italic" : "normal"),
24
+ });
8
25
  /** Build an echarts `textStyle` from a parsed `ChartTextFormat`. */
9
26
  export const textFormatToEchartsTextStyle = (fmt) => {
10
27
  if (!fmt)
@@ -201,9 +218,14 @@ export const buildSeriesLabelOption = (opts, seriesType, locale) => {
201
218
  ? ECHARTS_POINT_DLBL_POS
202
219
  : ECHARTS_DLBL_POS;
203
220
  const position = (opts.position && positions[opts.position]) ?? "top";
221
+ // Excel's Format Data Labels → Font: colour, family, size, bold, italic
222
+ // (rowsncolumns/spreadsheet#1105). Keys are only written when authored so
223
+ // a label keeps its series-aware default colour otherwise.
224
+ const font = textFormatToEchartsTextStyle(opts.textFormat) ?? {};
204
225
  return {
205
226
  show: true,
206
227
  position,
207
228
  formatter: dataLabelFormatter(opts, locale),
229
+ ...font,
208
230
  };
209
231
  };
@@ -44,14 +44,25 @@ export declare const normalize3DSourceType: (sourceChartType?: string | null) =>
44
44
  export declare const is3DSpec: (spec: {
45
45
  sourceChartType?: string | null;
46
46
  } | null | undefined) => boolean;
47
+ /** Host opt-out of the WebGL pipeline (`enable3D` on the renderer / editor). */
48
+ export type ThreeDRenderOptions = {
49
+ /**
50
+ * `false` keeps every spec on its 2-D fallback: echarts-gl is never
51
+ * loaded and the Chart editor offers no echarts-gl preset. The spec's
52
+ * `sourceChartType` is untouched, so the xlsx export still writes the
53
+ * 3-D chart (rowsncolumns/spreadsheet#1187). Default `true`.
54
+ */
55
+ enable3D?: boolean;
56
+ };
47
57
  /**
48
58
  * Map a `sourceChartType` token to the echarts-gl series kind it renders
49
59
  * as, or null when the 3-D pipeline should not run:
50
60
  * - PIE_3D — echarts-gl has no pie3D, so the 2-D pie fallback stays.
51
61
  * - AREA_3D — echarts-gl has no area3D; rendered as line3D.
52
62
  * - non-3-D / unknown tokens.
63
+ * - any token when the host turned 3-D off (`enable3D: false`).
53
64
  */
54
- export declare const resolve3DRenderKind: (sourceChartType?: string | null) => ThreeDRenderKind | null;
65
+ export declare const resolve3DRenderKind: (sourceChartType?: string | null, options?: ThreeDRenderOptions) => ThreeDRenderKind | null;
55
66
  /** Excel's Contour: the surface grid seen from above, as a flat heatmap. */
56
67
  export declare const isContourSpec: (spec: {
57
68
  sourceChartType?: string | null;