@rowsncolumns/charts 28.0.0 → 28.1.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.
Files changed (193) hide show
  1. package/dist/cjs/atoms/pivot-chart.atom.d.ts +14 -0
  2. package/dist/cjs/atoms/pivot-chart.atom.d.ts.map +1 -0
  3. package/dist/cjs/atoms/pivot-chart.atom.js +9 -0
  4. package/dist/cjs/basic-chart/basic-chart.d.ts +1 -1
  5. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  6. package/dist/cjs/basic-chart/basic-chart.js +863 -371
  7. package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts +39 -0
  8. package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
  9. package/dist/cjs/components/dialogs/pivot-chart-dialog.js +100 -0
  10. package/dist/cjs/components/editors/chart-editor.d.ts +13 -1
  11. package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
  12. package/dist/cjs/components/editors/chart-editor.js +225 -59
  13. package/dist/cjs/config.d.ts.map +1 -1
  14. package/dist/cjs/config.js +149 -12
  15. package/dist/cjs/hooks/use-charts.d.ts +21 -6
  16. package/dist/cjs/hooks/use-charts.d.ts.map +1 -1
  17. package/dist/cjs/hooks/use-charts.js +13 -1
  18. package/dist/cjs/hooks/use-on-create-chart.d.ts.map +1 -1
  19. package/dist/cjs/hooks/use-on-create-chart.js +7 -1
  20. package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
  21. package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
  22. package/dist/cjs/hooks/use-on-move-chart-to-sheet.js +26 -0
  23. package/dist/cjs/hooks/use-on-move-chart.d.ts +1 -1
  24. package/dist/cjs/hooks/use-on-move-chart.d.ts.map +1 -1
  25. package/dist/cjs/hooks/use-on-move-chart.js +2 -2
  26. package/dist/cjs/hooks/use-on-resize-chart.d.ts +1 -1
  27. package/dist/cjs/hooks/use-on-resize-chart.d.ts.map +1 -1
  28. package/dist/cjs/hooks/use-on-resize-chart.js +2 -2
  29. package/dist/cjs/index.d.ts +11 -0
  30. package/dist/cjs/index.d.ts.map +1 -1
  31. package/dist/cjs/index.js +34 -1
  32. package/dist/cjs/interface/create-chart.d.ts.map +1 -1
  33. package/dist/cjs/interface/create-chart.js +33 -42
  34. package/dist/cjs/interface/delete-chart.d.ts.map +1 -1
  35. package/dist/cjs/interface/delete-chart.js +4 -0
  36. package/dist/cjs/interface/move-chart-to-sheet.d.ts +13 -0
  37. package/dist/cjs/interface/move-chart-to-sheet.d.ts.map +1 -0
  38. package/dist/cjs/interface/move-chart-to-sheet.js +136 -0
  39. package/dist/cjs/interface/move-chart.d.ts +2 -2
  40. package/dist/cjs/interface/move-chart.d.ts.map +1 -1
  41. package/dist/cjs/interface/move-chart.js +7 -1
  42. package/dist/cjs/interface/resize-chart.d.ts +2 -2
  43. package/dist/cjs/interface/resize-chart.d.ts.map +1 -1
  44. package/dist/cjs/interface/resize-chart.js +7 -1
  45. package/dist/cjs/interface/update-chart.d.ts.map +1 -1
  46. package/dist/cjs/interface/update-chart.js +4 -0
  47. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +1 -1
  48. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  49. package/dist/cjs/plotly/basic-chart/basic-chart.js +970 -585
  50. package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -1
  51. package/dist/cjs/plotly/basic-chart/helpers.js +3 -0
  52. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  53. package/dist/cjs/types.d.ts +7 -0
  54. package/dist/cjs/types.d.ts.map +1 -1
  55. package/dist/cjs/utils/axis-number-format.d.ts +69 -0
  56. package/dist/cjs/utils/axis-number-format.d.ts.map +1 -0
  57. package/dist/cjs/utils/axis-number-format.js +217 -0
  58. package/dist/cjs/utils/category-levels.d.ts +27 -0
  59. package/dist/cjs/utils/category-levels.d.ts.map +1 -0
  60. package/dist/cjs/utils/category-levels.js +80 -0
  61. package/dist/cjs/utils/chart-image.d.ts +8 -0
  62. package/dist/cjs/utils/chart-image.d.ts.map +1 -0
  63. package/dist/cjs/utils/chart-image.js +28 -0
  64. package/dist/cjs/utils/chart-orientation.d.ts +67 -0
  65. package/dist/cjs/utils/chart-orientation.d.ts.map +1 -0
  66. package/dist/cjs/utils/chart-orientation.js +265 -0
  67. package/dist/cjs/utils/chart-spec-utils.d.ts +3 -0
  68. package/dist/cjs/utils/chart-spec-utils.d.ts.map +1 -1
  69. package/dist/cjs/utils/chart-spec-utils.js +12 -4
  70. package/dist/cjs/utils/chart-styles.d.ts +75 -0
  71. package/dist/cjs/utils/chart-styles.d.ts.map +1 -0
  72. package/dist/cjs/utils/chart-styles.js +283 -0
  73. package/dist/cjs/utils/empty-cells.d.ts +30 -0
  74. package/dist/cjs/utils/empty-cells.d.ts.map +1 -0
  75. package/dist/cjs/utils/empty-cells.js +91 -0
  76. package/dist/cjs/utils/overrides.d.ts +6 -1
  77. package/dist/cjs/utils/overrides.d.ts.map +1 -1
  78. package/dist/cjs/utils/overrides.js +19 -7
  79. package/dist/cjs/utils/pie-explosion.d.ts +30 -0
  80. package/dist/cjs/utils/pie-explosion.d.ts.map +1 -0
  81. package/dist/cjs/utils/pie-explosion.js +55 -0
  82. package/dist/cjs/utils/plotly-click.d.ts +34 -0
  83. package/dist/cjs/utils/plotly-click.d.ts.map +1 -0
  84. package/dist/cjs/utils/plotly-click.js +49 -0
  85. package/dist/cjs/utils/plotly-surface.d.ts +14 -0
  86. package/dist/cjs/utils/plotly-surface.d.ts.map +1 -0
  87. package/dist/cjs/utils/plotly-surface.js +64 -0
  88. package/dist/cjs/utils/plotly-title.d.ts +12 -0
  89. package/dist/cjs/utils/plotly-title.d.ts.map +1 -0
  90. package/dist/cjs/utils/plotly-title.js +24 -0
  91. package/dist/cjs/utils/series-click.d.ts +39 -0
  92. package/dist/cjs/utils/series-click.d.ts.map +1 -0
  93. package/dist/cjs/utils/series-click.js +75 -0
  94. package/dist/cjs/utils/three-d.d.ts +17 -1
  95. package/dist/cjs/utils/three-d.d.ts.map +1 -1
  96. package/dist/cjs/utils/three-d.js +32 -4
  97. package/dist/esm/atoms/pivot-chart.atom.d.ts +14 -0
  98. package/dist/esm/atoms/pivot-chart.atom.d.ts.map +1 -0
  99. package/dist/esm/atoms/pivot-chart.atom.js +4 -0
  100. package/dist/esm/basic-chart/basic-chart.d.ts +1 -1
  101. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  102. package/dist/esm/basic-chart/basic-chart.js +680 -178
  103. package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts +39 -0
  104. package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
  105. package/dist/esm/components/dialogs/pivot-chart-dialog.js +89 -0
  106. package/dist/esm/components/editors/chart-editor.d.ts +13 -1
  107. package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
  108. package/dist/esm/components/editors/chart-editor.js +164 -20
  109. package/dist/esm/config.d.ts.map +1 -1
  110. package/dist/esm/config.js +149 -12
  111. package/dist/esm/hooks/use-charts.d.ts +21 -6
  112. package/dist/esm/hooks/use-charts.d.ts.map +1 -1
  113. package/dist/esm/hooks/use-charts.js +13 -1
  114. package/dist/esm/hooks/use-on-create-chart.d.ts.map +1 -1
  115. package/dist/esm/hooks/use-on-create-chart.js +7 -1
  116. package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
  117. package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
  118. package/dist/esm/hooks/use-on-move-chart-to-sheet.js +19 -0
  119. package/dist/esm/hooks/use-on-move-chart.d.ts +1 -1
  120. package/dist/esm/hooks/use-on-move-chart.d.ts.map +1 -1
  121. package/dist/esm/hooks/use-on-move-chart.js +2 -2
  122. package/dist/esm/hooks/use-on-resize-chart.d.ts +1 -1
  123. package/dist/esm/hooks/use-on-resize-chart.d.ts.map +1 -1
  124. package/dist/esm/hooks/use-on-resize-chart.js +2 -2
  125. package/dist/esm/index.d.ts +11 -0
  126. package/dist/esm/index.d.ts.map +1 -1
  127. package/dist/esm/index.js +14 -0
  128. package/dist/esm/interface/create-chart.d.ts.map +1 -1
  129. package/dist/esm/interface/create-chart.js +36 -58
  130. package/dist/esm/interface/delete-chart.d.ts.map +1 -1
  131. package/dist/esm/interface/delete-chart.js +4 -0
  132. package/dist/esm/interface/move-chart-to-sheet.d.ts +13 -0
  133. package/dist/esm/interface/move-chart-to-sheet.d.ts.map +1 -0
  134. package/dist/esm/interface/move-chart-to-sheet.js +126 -0
  135. package/dist/esm/interface/move-chart.d.ts +2 -2
  136. package/dist/esm/interface/move-chart.d.ts.map +1 -1
  137. package/dist/esm/interface/move-chart.js +7 -1
  138. package/dist/esm/interface/resize-chart.d.ts +2 -2
  139. package/dist/esm/interface/resize-chart.d.ts.map +1 -1
  140. package/dist/esm/interface/resize-chart.js +7 -1
  141. package/dist/esm/interface/update-chart.d.ts.map +1 -1
  142. package/dist/esm/interface/update-chart.js +4 -0
  143. package/dist/esm/plotly/basic-chart/basic-chart.d.ts +1 -1
  144. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  145. package/dist/esm/plotly/basic-chart/basic-chart.js +858 -463
  146. package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -1
  147. package/dist/esm/plotly/basic-chart/helpers.js +3 -0
  148. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  149. package/dist/esm/types.d.ts +7 -0
  150. package/dist/esm/types.d.ts.map +1 -1
  151. package/dist/esm/utils/axis-number-format.d.ts +69 -0
  152. package/dist/esm/utils/axis-number-format.d.ts.map +1 -0
  153. package/dist/esm/utils/axis-number-format.js +170 -0
  154. package/dist/esm/utils/category-levels.d.ts +27 -0
  155. package/dist/esm/utils/category-levels.d.ts.map +1 -0
  156. package/dist/esm/utils/category-levels.js +65 -0
  157. package/dist/esm/utils/chart-image.d.ts +8 -0
  158. package/dist/esm/utils/chart-image.d.ts.map +1 -0
  159. package/dist/esm/utils/chart-image.js +24 -0
  160. package/dist/esm/utils/chart-orientation.d.ts +67 -0
  161. package/dist/esm/utils/chart-orientation.d.ts.map +1 -0
  162. package/dist/esm/utils/chart-orientation.js +234 -0
  163. package/dist/esm/utils/chart-spec-utils.d.ts +3 -0
  164. package/dist/esm/utils/chart-spec-utils.d.ts.map +1 -1
  165. package/dist/esm/utils/chart-spec-utils.js +10 -2
  166. package/dist/esm/utils/chart-styles.d.ts +75 -0
  167. package/dist/esm/utils/chart-styles.d.ts.map +1 -0
  168. package/dist/esm/utils/chart-styles.js +357 -0
  169. package/dist/esm/utils/empty-cells.d.ts +30 -0
  170. package/dist/esm/utils/empty-cells.d.ts.map +1 -0
  171. package/dist/esm/utils/empty-cells.js +67 -0
  172. package/dist/esm/utils/overrides.d.ts +6 -1
  173. package/dist/esm/utils/overrides.d.ts.map +1 -1
  174. package/dist/esm/utils/overrides.js +14 -2
  175. package/dist/esm/utils/pie-explosion.d.ts +30 -0
  176. package/dist/esm/utils/pie-explosion.d.ts.map +1 -0
  177. package/dist/esm/utils/pie-explosion.js +43 -0
  178. package/dist/esm/utils/plotly-click.d.ts +34 -0
  179. package/dist/esm/utils/plotly-click.d.ts.map +1 -0
  180. package/dist/esm/utils/plotly-click.js +44 -0
  181. package/dist/esm/utils/plotly-surface.d.ts +14 -0
  182. package/dist/esm/utils/plotly-surface.d.ts.map +1 -0
  183. package/dist/esm/utils/plotly-surface.js +45 -0
  184. package/dist/esm/utils/plotly-title.d.ts +12 -0
  185. package/dist/esm/utils/plotly-title.d.ts.map +1 -0
  186. package/dist/esm/utils/plotly-title.js +20 -0
  187. package/dist/esm/utils/series-click.d.ts +39 -0
  188. package/dist/esm/utils/series-click.d.ts.map +1 -0
  189. package/dist/esm/utils/series-click.js +66 -0
  190. package/dist/esm/utils/three-d.d.ts +17 -1
  191. package/dist/esm/utils/three-d.d.ts.map +1 -1
  192. package/dist/esm/utils/three-d.js +29 -3
  193. package/package.json +10 -6
@@ -0,0 +1,14 @@
1
+ /**
2
+ * plotly traces for Excel's Surface family (rowsncolumns/spreadsheet#668
3
+ * C-33): `surface3DChart` (3-D Surface) is a WebGL `surface`, `surfaceChart`
4
+ * (Contour) is the same height grid seen from above as an SVG `contour`.
5
+ * Both take z as one row per series, one column per category.
6
+ */
7
+ import { type ThreeDSeriesInput } from "./three-d";
8
+ export type SurfaceToken = "SURFACE" | "SURFACE_3D";
9
+ /** plotly `colorscale` — the shared surface ramp spread over 0..1. */
10
+ export declare const surfaceColorscale: () => Array<[number, string]>;
11
+ /** The z matrix (series rows × category columns) plotly's grid traces take. */
12
+ export declare const buildSurfaceZ: (series: ThreeDSeriesInput[]) => number[][];
13
+ export declare const buildPlotlySurfaceTrace: (token: SurfaceToken, series: ThreeDSeriesInput[], categories: string[], seriesNames: string[], seriesNumberFormats?: (string | undefined)[]) => Record<string, unknown>;
14
+ //# sourceMappingURL=plotly-surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plotly-surface.d.ts","sourceRoot":"","sources":["../../../utils/plotly-surface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC;AAEpD,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,QAAO,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAIvD,CAAC;AAEL,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,QAAQ,iBAAiB,EAAE,KAAG,MAAM,EAAE,EASnE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,YAAY,EACnB,QAAQ,iBAAiB,EAAE,EAC3B,YAAY,MAAM,EAAE,EACpB,aAAa,MAAM,EAAE,EACrB,sBAAqB,CAAC,MAAM,GAAG,SAAS,CAAC,EAAO,KAC/C,MAAM,CAAC,MAAM,EAAE,OAAO,CAwBxB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * plotly traces for Excel's Surface family (rowsncolumns/spreadsheet#668
3
+ * C-33): `surface3DChart` (3-D Surface) is a WebGL `surface`, `surfaceChart`
4
+ * (Contour) is the same height grid seen from above as an SVG `contour`.
5
+ * Both take z as one row per series, one column per category.
6
+ */
7
+ import { formatAxisValue } from "./axis-number-format";
8
+ import { buildSurfaceData, getCategoryCount, SURFACE_COLOR_RAMP, } from "./three-d";
9
+ /** plotly `colorscale` — the shared surface ramp spread over 0..1. */
10
+ export const surfaceColorscale = () => SURFACE_COLOR_RAMP.map((color, index) => [
11
+ index / Math.max(1, SURFACE_COLOR_RAMP.length - 1),
12
+ color,
13
+ ]);
14
+ /** The z matrix (series rows × category columns) plotly's grid traces take. */
15
+ export const buildSurfaceZ = (series) => {
16
+ const categoryCount = getCategoryCount(series);
17
+ const rows = series.map(() => new Array(categoryCount).fill(0));
18
+ for (const [x, y, z] of buildSurfaceData(series)) {
19
+ rows[y][x] = z;
20
+ }
21
+ return rows;
22
+ };
23
+ export const buildPlotlySurfaceTrace = (token, series, categories, seriesNames, seriesNumberFormats = []) => {
24
+ const z = buildSurfaceZ(series);
25
+ // Hover text formats each cell with its series' own source cells.
26
+ const text = z.map((row, y) => row.map((value) => formatAxisValue(seriesNumberFormats[y], value)));
27
+ const shared = {
28
+ z,
29
+ x: categories,
30
+ y: seriesNames,
31
+ text,
32
+ colorscale: surfaceColorscale(),
33
+ showscale: true,
34
+ hovertemplate: "%{y}<br>%{x}: %{text}<extra></extra>",
35
+ meta: { rncSeriesIndex: 0 },
36
+ };
37
+ return token === "SURFACE"
38
+ ? {
39
+ type: "contour",
40
+ ...shared,
41
+ contours: { coloring: "heatmap", showlines: true },
42
+ line: { width: 1 },
43
+ }
44
+ : { type: "surface", ...shared };
45
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The chart title text for a plotly layout. Plotly's `layout.title.font`
3
+ * carries family / size / colour but no weight or style, while the title
4
+ * text itself is rendered as pseudo-HTML — so an authored bold / italic
5
+ * (`titleTextFormat`, from OOXML `<a:rPr b="1" i="1">`) is emitted as `<b>`
6
+ * / `<i>` tags around the text, which plotly renders (#668 C-51).
7
+ */
8
+ export declare const plotlyTitleText: (title: string | null | undefined, format?: {
9
+ bold?: boolean | null;
10
+ italic?: boolean | null;
11
+ } | null) => string | undefined;
12
+ //# sourceMappingURL=plotly-title.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plotly-title.d.ts","sourceRoot":"","sources":["../../../utils/plotly-title.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,SAAS;IAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,KACjE,MAAM,GAAG,SAYX,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The chart title text for a plotly layout. Plotly's `layout.title.font`
3
+ * carries family / size / colour but no weight or style, while the title
4
+ * text itself is rendered as pseudo-HTML — so an authored bold / italic
5
+ * (`titleTextFormat`, from OOXML `<a:rPr b="1" i="1">`) is emitted as `<b>`
6
+ * / `<i>` tags around the text, which plotly renders (#668 C-51).
7
+ */
8
+ export const plotlyTitleText = (title, format) => {
9
+ if (title === undefined || title === null) {
10
+ return undefined;
11
+ }
12
+ let text = title;
13
+ if (format?.italic) {
14
+ text = `<i>${text}</i>`;
15
+ }
16
+ if (format?.bold) {
17
+ text = `<b>${text}</b>`;
18
+ }
19
+ return text;
20
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Maps a click inside a rendered chart back to the `spec.series` entry it
3
+ * belongs to, so the grid can highlight that series' source range like
4
+ * Excel does when a series is selected.
5
+ */
6
+ /**
7
+ * echarts series id for `spec.series[specIndex]`. `sourceIndex` is `0` for the
8
+ * base series — a series drawn from several ranges renders as ONE echarts
9
+ * series over their union (Excel). Base series carry it so a click resolves
10
+ * without depending on the order overlays (trendlines, error bars) are
11
+ * appended in.
12
+ */
13
+ export declare const chartSeriesId: (specIndex: number, sourceIndex: number) => string;
14
+ /**
15
+ * The `spec.series` index a tagged echarts series id carries, or
16
+ * `undefined` for untagged (overlay / echarts auto) ids.
17
+ */
18
+ export declare const chartSeriesSpecIndex: (id: string | null | undefined) => number | undefined;
19
+ /**
20
+ * The data point a chart click lands on, as a category index into the
21
+ * series' source range, or `undefined` when the click has no per-point
22
+ * meaning (a radar item is a whole series; overlays carry none).
23
+ */
24
+ export declare const resolveClickedDataIndex: (params: SeriesClickParams | null | undefined) => number | undefined;
25
+ export type SeriesClickParams = {
26
+ seriesId?: string | null;
27
+ seriesIndex?: number | null;
28
+ seriesType?: string | null;
29
+ dataIndex?: number | null;
30
+ };
31
+ /**
32
+ * The `spec.series` index a chart click lands on, or `undefined` when the
33
+ * click cannot be attributed to a series (overlay, connector, empty area).
34
+ * Tagged base series resolve through their id; a radar chart is one echarts
35
+ * series whose data items are the spec series; other untagged series
36
+ * (pie slices, stock roles, waterfall bars…) map by position while it fits.
37
+ */
38
+ export declare const resolveClickedSeriesIndex: (params: SeriesClickParams | null | undefined, seriesCount: number) => number | undefined;
39
+ //# sourceMappingURL=series-click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"series-click.d.ts","sourceRoot":"","sources":["../../../utils/series-click.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,EAAE,aAAa,MAAM,WAClB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,KAC5B,MAAM,GAAG,SAMX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,iBAAiB,GAAG,IAAI,GAAG,SAAS,KAC3C,MAAM,GAAG,SAMX,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACpC,QAAQ,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAC5C,aAAa,MAAM,KAClB,MAAM,GAAG,SAmBX,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Maps a click inside a rendered chart back to the `spec.series` entry it
3
+ * belongs to, so the grid can highlight that series' source range like
4
+ * Excel does when a series is selected.
5
+ */
6
+ const SERIES_ID_PREFIX = "rnc-series-";
7
+ /**
8
+ * echarts series id for `spec.series[specIndex]`. `sourceIndex` is `0` for the
9
+ * base series — a series drawn from several ranges renders as ONE echarts
10
+ * series over their union (Excel). Base series carry it so a click resolves
11
+ * without depending on the order overlays (trendlines, error bars) are
12
+ * appended in.
13
+ */
14
+ export const chartSeriesId = (specIndex, sourceIndex) => `${SERIES_ID_PREFIX}${specIndex}-${sourceIndex}`;
15
+ /**
16
+ * The `spec.series` index a tagged echarts series id carries, or
17
+ * `undefined` for untagged (overlay / echarts auto) ids.
18
+ */
19
+ export const chartSeriesSpecIndex = (id) => {
20
+ if (typeof id !== "string" || !id.startsWith(SERIES_ID_PREFIX)) {
21
+ return undefined;
22
+ }
23
+ const specIndex = Number.parseInt(id.slice(SERIES_ID_PREFIX.length), 10);
24
+ return Number.isFinite(specIndex) ? specIndex : undefined;
25
+ };
26
+ /**
27
+ * The data point a chart click lands on, as a category index into the
28
+ * series' source range, or `undefined` when the click has no per-point
29
+ * meaning (a radar item is a whole series; overlays carry none).
30
+ */
31
+ export const resolveClickedDataIndex = (params) => {
32
+ if (!params || params.seriesType === "radar")
33
+ return undefined;
34
+ const dataIndex = params.dataIndex;
35
+ return typeof dataIndex === "number" && dataIndex >= 0
36
+ ? dataIndex
37
+ : undefined;
38
+ };
39
+ /**
40
+ * The `spec.series` index a chart click lands on, or `undefined` when the
41
+ * click cannot be attributed to a series (overlay, connector, empty area).
42
+ * Tagged base series resolve through their id; a radar chart is one echarts
43
+ * series whose data items are the spec series; other untagged series
44
+ * (pie slices, stock roles, waterfall bars…) map by position while it fits.
45
+ */
46
+ export const resolveClickedSeriesIndex = (params, seriesCount) => {
47
+ if (!params)
48
+ return undefined;
49
+ const id = typeof params.seriesId === "string" ? params.seriesId : "";
50
+ if (id.startsWith(SERIES_ID_PREFIX)) {
51
+ const specIndex = chartSeriesSpecIndex(id);
52
+ return specIndex !== undefined && specIndex < seriesCount
53
+ ? specIndex
54
+ : undefined;
55
+ }
56
+ if (params.seriesType === "radar") {
57
+ const dataIndex = params.dataIndex;
58
+ return typeof dataIndex === "number" && dataIndex < seriesCount
59
+ ? dataIndex
60
+ : undefined;
61
+ }
62
+ const seriesIndex = params.seriesIndex;
63
+ return typeof seriesIndex === "number" && seriesIndex < seriesCount
64
+ ? seriesIndex
65
+ : undefined;
66
+ };
@@ -16,8 +16,12 @@
16
16
  * - LINE_3D -> `line3D` (one polyline per series at its series-index depth)
17
17
  * - AREA_3D -> `line3D` (echarts-gl has no area3D; the polyline keeps the
18
18
  * authored depth layout)
19
- * - SURFACE / SURFACE_3D -> `surface` (values grid as z-heights over the
19
+ * - SURFACE_3D -> `surface` (values grid as z-heights over the
20
20
  * categories × series plane)
21
+ * - SURFACE -> null (Excel's Contour is the top-down view of the same
22
+ * grid; the renderer draws it as a 2-D heatmap over
23
+ * categories × series — `buildContourData` — with
24
+ * no WebGL involved)
21
25
  * - PIE_3D -> null (echarts-gl has no pie3D; the renderer keeps the
22
26
  * existing 2-D pie fallback rather than faking it)
23
27
  */
@@ -48,6 +52,18 @@ export declare const is3DSpec: (spec: {
48
52
  * - non-3-D / unknown tokens.
49
53
  */
50
54
  export declare const resolve3DRenderKind: (sourceChartType?: string | null) => ThreeDRenderKind | null;
55
+ /** Excel's Contour: the surface grid seen from above, as a flat heatmap. */
56
+ export declare const isContourSpec: (spec: {
57
+ sourceChartType?: string | null;
58
+ } | null | undefined) => boolean;
59
+ /** One heatmap cell: [category index, series index, value]; `"-"` is an empty cell. */
60
+ export type ContourPoint = [number, number, number | "-"];
61
+ /**
62
+ * Flatten the categories × series value matrix into echarts `heatmap`
63
+ * data. Unlike `buildSurfaceData` (which needs a full grid of heights)
64
+ * an empty cell stays empty (`"-"`) instead of dropping to 0.
65
+ */
66
+ export declare const buildContourData: (series: ThreeDSeriesInput[]) => ContourPoint[];
51
67
  export type ThreeDSeriesInput = {
52
68
  /** Resolved series display name (legend / y-axis label). */
53
69
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"three-d.d.ts","sourceRoot":"","sources":["../../../utils/three-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,QAAA,MAAM,cAAc,8EAOV,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAI9D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,kBAAkB,MAAM,GAAG,IAAI,KAC9B,gBAAgB,GAAG,IAIrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,MAAM;IAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC3D,OAAgE,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,kBAAkB,MAAM,GAAG,IAAI,KAC9B,gBAAgB,GAAG,IAcrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,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;IAAC,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,EASpC,CAAC;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,iBAAiB,EAAE,KAC1B,WAAW,EAcb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,EAAE,KAAG,CAAC,MAAM,EAAE,MAAM,CASrE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAY/C,CAAC"}
@@ -16,8 +16,12 @@
16
16
  * - LINE_3D -> `line3D` (one polyline per series at its series-index depth)
17
17
  * - AREA_3D -> `line3D` (echarts-gl has no area3D; the polyline keeps the
18
18
  * authored depth layout)
19
- * - SURFACE / SURFACE_3D -> `surface` (values grid as z-heights over the
19
+ * - SURFACE_3D -> `surface` (values grid as z-heights over the
20
20
  * categories × series plane)
21
+ * - SURFACE -> null (Excel's Contour is the top-down view of the same
22
+ * grid; the renderer draws it as a 2-D heatmap over
23
+ * categories × series — `buildContourData` — with
24
+ * no WebGL involved)
21
25
  * - PIE_3D -> null (echarts-gl has no pie3D; the renderer keeps the
22
26
  * existing 2-D pie fallback rather than faking it)
23
27
  */
@@ -62,14 +66,36 @@ export const resolve3DRenderKind = (sourceChartType) => {
62
66
  case "LINE_3D":
63
67
  case "AREA_3D":
64
68
  return "line3D";
65
- case "SURFACE":
66
69
  case "SURFACE_3D":
67
70
  return "surface";
68
71
  default:
69
- // PIE_3D and non-3-D tokens: keep the 2-D fallback rendering.
72
+ // SURFACE (contour — drawn flat), PIE_3D and non-3-D tokens: keep
73
+ // the 2-D rendering.
70
74
  return null;
71
75
  }
72
76
  };
77
+ /** Excel's Contour: the surface grid seen from above, as a flat heatmap. */
78
+ export const isContourSpec = (spec) => normalize3DSourceType(spec?.sourceChartType) === "SURFACE";
79
+ /**
80
+ * Flatten the categories × series value matrix into echarts `heatmap`
81
+ * data. Unlike `buildSurfaceData` (which needs a full grid of heights)
82
+ * an empty cell stays empty (`"-"`) instead of dropping to 0.
83
+ */
84
+ export const buildContourData = (series) => {
85
+ const categoryCount = getCategoryCount(series);
86
+ const points = [];
87
+ series.forEach((entry, seriesIndex) => {
88
+ for (let categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) {
89
+ const value = entry.values[categoryIndex];
90
+ points.push([
91
+ categoryIndex,
92
+ seriesIndex,
93
+ isFiniteNumber(value) ? value : "-",
94
+ ]);
95
+ }
96
+ });
97
+ return points;
98
+ };
73
99
  const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
74
100
  /** Number of categories = the longest series' value count. */
75
101
  export const getCategoryCount = (series) => series.reduce((max, entry) => Math.max(max, entry.values.length), 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/charts",
3
- "version": "28.0.0",
3
+ "version": "28.1.0",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./dist/cjs/index.js",
@@ -51,6 +51,8 @@
51
51
  "test": "vitest --run",
52
52
  "lint": "eslint . --ext .ts,.tsx",
53
53
  "types": "tsc -p . --noEmit",
54
+ "types:specs": "node ../../scripts/typecheck-specs.mjs",
55
+ "types:specs:update": "node ../../scripts/typecheck-specs.mjs --update",
54
56
  "list": "tsc --listFiles"
55
57
  },
56
58
  "files": [
@@ -65,13 +67,14 @@
65
67
  },
66
68
  "devDependencies": {
67
69
  "@rowsncolumns/calculator": ">=7.3.0",
70
+ "@rowsncolumns/common-types": ">=5.2.34",
68
71
  "@rowsncolumns/grid": ">=13.2.33",
69
72
  "@rowsncolumns/icons": ">=7.2.32",
70
- "@rowsncolumns/spreadsheet": ">=10.3.0",
71
- "@rowsncolumns/spreadsheet-state": ">=29.0.0",
72
- "@rowsncolumns/toolkit": ">=24.4.5",
73
- "@rowsncolumns/ui": ">=16.0.0",
74
- "@rowsncolumns/utils": ">=9.3.0",
73
+ "@rowsncolumns/spreadsheet": ">=10.4.0",
74
+ "@rowsncolumns/spreadsheet-state": ">=29.1.0",
75
+ "@rowsncolumns/toolkit": ">=24.5.0",
76
+ "@rowsncolumns/ui": ">=16.0.1",
77
+ "@rowsncolumns/utils": ">=9.4.0",
75
78
  "@types/react-plotly.js": "^2.6.3",
76
79
  "echarts": "^5.6.0",
77
80
  "formik": "^2.4.6",
@@ -81,6 +84,7 @@
81
84
  },
82
85
  "peerDependencies": {
83
86
  "@rowsncolumns/calculator": ">=7.3.0",
87
+ "@rowsncolumns/common-types": ">=5.2.33",
84
88
  "@rowsncolumns/grid": ">=13.2.33",
85
89
  "@rowsncolumns/icons": ">=7.2.32",
86
90
  "@rowsncolumns/spreadsheet": ">=10.3.0",