@rowsncolumns/charts 28.0.0 → 28.1.1

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 +13 -9
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,qBAAqB,GAChC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,KACvC,MA+DF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;;;;;;;;;CAgBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,GAAG,SAAS,GAAG,IAAI,KAChC,MAAM,GAAG,SA0BX,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,YAejE,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,qBAAqB,GAChC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,KACvC,MAmEF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;;;;;;;;;CAgBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,GAAG,SAAS,GAAG,IAAI,KAChC,MAAM,GAAG,SA0BX,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,YAejE,CAAC"}
@@ -10,6 +10,9 @@ export const chartTypeToPlotlyType = (type) => {
10
10
  return "bar";
11
11
  case "pie":
12
12
  return "pie";
13
+ // Doughnut is a pie trace with `hole` set (see basic-chart.tsx).
14
+ case "doughnut":
15
+ return "pie";
13
16
  case "treemap":
14
17
  return "treemap";
15
18
  case "sunburst":
@@ -1 +1 @@
1
- {"root":["../../config.ts","../../echarts-gl.d.ts","../../geo-modules.d.ts","../../index.ts","../../types.ts","../../vitest.config.ts","../../atoms/editing-chart.atom.ts","../../basic-chart/basic-chart.tsx","../../basic-chart/helpers.ts","../../basic-chart/index.tsx","../../components/dialogs/chart-editor-dialog.tsx","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../hooks/use-chart-editor.ts","../../hooks/use-charts.ts","../../hooks/use-on-create-chart.ts","../../hooks/use-on-delete-chart.ts","../../hooks/use-on-move-chart.ts","../../hooks/use-on-resize-chart.ts","../../hooks/use-on-update-chart.ts","../../interface/create-chart.ts","../../interface/delete-chart.ts","../../interface/move-chart.ts","../../interface/resize-chart.ts","../../interface/shift-chart-ranges.ts","../../interface/update-chart.ts","../../plotly/basic-chart/basic-chart.tsx","../../plotly/basic-chart/helpers.ts","../../plotly/basic-chart/index.tsx","../../utils/aggregation.ts","../../utils/bar-layout.ts","../../utils/boxplot.ts","../../utils/bubble.ts","../../utils/chart-spec-utils.ts","../../utils/echarts-gl-loader.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/of-pie.ts","../../utils/overrides.ts","../../utils/radar.ts","../../utils/region-map-loader.ts","../../utils/region-map.ts","../../utils/stock.ts","../../utils/three-d.ts","../../utils/trendline.ts","../../utils/waterfall.ts","../../utils/webgl.ts"],"version":"5.8.3"}
1
+ {"root":["../../config.ts","../../echarts-gl.d.ts","../../geo-modules.d.ts","../../index.ts","../../plotly-dist.d.ts","../../types.ts","../../vitest.config.ts","../../atoms/editing-chart.atom.ts","../../atoms/pivot-chart.atom.ts","../../basic-chart/basic-chart.tsx","../../basic-chart/helpers.ts","../../basic-chart/index.tsx","../../components/dialogs/chart-editor-dialog.tsx","../../components/dialogs/pivot-chart-dialog.tsx","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../hooks/use-chart-editor.ts","../../hooks/use-charts.ts","../../hooks/use-on-create-chart.ts","../../hooks/use-on-delete-chart.ts","../../hooks/use-on-move-chart-to-sheet.ts","../../hooks/use-on-move-chart.ts","../../hooks/use-on-resize-chart.ts","../../hooks/use-on-update-chart.ts","../../interface/create-chart.ts","../../interface/delete-chart.ts","../../interface/move-chart-to-sheet.ts","../../interface/move-chart.ts","../../interface/resize-chart.ts","../../interface/shift-chart-ranges.ts","../../interface/update-chart.ts","../../plotly/basic-chart/basic-chart.tsx","../../plotly/basic-chart/helpers.ts","../../plotly/basic-chart/index.tsx","../../utils/aggregation.ts","../../utils/axis-number-format.ts","../../utils/bar-layout.ts","../../utils/boxplot.ts","../../utils/bubble.ts","../../utils/category-levels.ts","../../utils/chart-image.ts","../../utils/chart-orientation.ts","../../utils/chart-spec-utils.ts","../../utils/chart-styles.ts","../../utils/echarts-gl-loader.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/of-pie.ts","../../utils/overrides.ts","../../utils/pie-explosion.ts","../../utils/plotly-click.ts","../../utils/plotly-surface.ts","../../utils/plotly-title.ts","../../utils/radar.ts","../../utils/region-map-loader.ts","../../utils/region-map.ts","../../utils/series-click.ts","../../utils/stock.ts","../../utils/three-d.ts","../../utils/trendline.ts","../../utils/waterfall.ts","../../utils/webgl.ts"],"version":"5.8.3"}
@@ -14,6 +14,13 @@ export type EChartComponentProps = ChartComponentProps & {
14
14
  * Get all effective values from a series
15
15
  */
16
16
  getSeriesValuesFromRange: ReturnType<typeof useSpreadsheetState>["getSeriesValuesFromRange"];
17
+ /**
18
+ * Get the effective cell formats of a range. Feeds Excel's "Linked to
19
+ * source" number format for value-axis tick labels, data labels and
20
+ * tooltips. Without it only an explicit axis `numberFormatPattern` is
21
+ * honored.
22
+ */
23
+ getFormattingFromRange?: ReturnType<typeof useSpreadsheetState>["getFormattingFromRange"];
17
24
  /**
18
25
  * Request edit chart
19
26
  * @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;;;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;;;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"}
@@ -0,0 +1,69 @@
1
+ import type { ChartData, HIDDEN_DIMENSION_STRATEGY, Maybe, SheetRange } from "@rowsncolumns/spreadsheet";
2
+ type RangeFormatReader = (sheetRange: SheetRange, hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY) => unknown[];
3
+ /**
4
+ * `General` (or nothing) means "let the renderer pick" — it carries no
5
+ * formatting. So does the bare-`#` shape the engines infer when a plain
6
+ * number is typed (`#`, `#.0`): Excel leaves such cells General, and `#`
7
+ * would blank every fractional tick below 0.5.
8
+ */
9
+ export declare const isGeneralNumberFormat: (pattern: Maybe<string> | undefined) => boolean;
10
+ /**
11
+ * The number format of a series' source cells — the first formatted cell of
12
+ * its first source range, matching Excel which links the axis to the first
13
+ * series' cell format.
14
+ */
15
+ export declare const resolveSourceNumberFormat: (sources: SheetRange[] | undefined, getFormattingFromRange: RangeFormatReader | undefined, hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY | null) => string | undefined;
16
+ /**
17
+ * Effective number format of one value axis: the axis' explicit
18
+ * `numberFormatPattern` wins, else the format of the first series bound to
19
+ * that axis ("Linked to source"), else `undefined` (renderer default).
20
+ */
21
+ export declare const resolveValueAxisNumberFormat: ({ axisOptions, series, getFormattingFromRange, hiddenDimensionStrategy, }: {
22
+ axisOptions: Maybe<{
23
+ numberFormatPattern?: Maybe<string>;
24
+ }> | undefined;
25
+ series: Pick<ChartData, "sources">[];
26
+ getFormattingFromRange: RangeFormatReader | undefined;
27
+ hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY | null;
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;
33
+ /**
34
+ * echarts `tooltip.valueFormatter` for a series whose data items are
35
+ * tuples (candlestick, 3-D points): every number formats through the
36
+ * pattern; `undefined` when there is no pattern so echarts keeps its
37
+ * default.
38
+ */
39
+ export declare const tooltipValueFormatter: (pattern: string | undefined) => ((value: unknown) => string | string[]) | undefined;
40
+ /**
41
+ * Excel's data labels and tooltips are linked to *each series' own* source
42
+ * cells, not to the axis: a revenue series formatted `$#,##0` next to a
43
+ * margin series formatted `0.0%` labels each with its own pattern. One
44
+ * entry per `spec.series`, `undefined` where the cells are General.
45
+ */
46
+ export declare const resolveSeriesNumberFormats: (series: Pick<ChartData, "sources">[] | undefined, getFormattingFromRange: RangeFormatReader | undefined, hiddenDimensionStrategy?: HIDDEN_DIMENSION_STRATEGY | null) => (string | undefined)[];
47
+ /** echarts pie / doughnut tooltip: `name: value (percent%)` with the value formatted. */
48
+ export declare const circularTooltipFormatter: (pattern: string | undefined) => (params: {
49
+ name?: string;
50
+ value?: unknown;
51
+ percent?: number;
52
+ }) => string;
53
+ export type PlotlyTickFormat = {
54
+ tickformat?: string;
55
+ tickprefix?: string;
56
+ ticksuffix?: string;
57
+ };
58
+ /**
59
+ * Translate the numeric subset of a SpreadsheetML pattern into plotly's
60
+ * d3-format axis settings (`tickformat` + literal prefix / suffix). Plotly
61
+ * has no per-tick callback, so only patterns made of digit placeholders,
62
+ * grouping, decimals, `%` and quoted / currency literals convert; anything
63
+ * else (dates, fractions, scientific, text sections) returns `undefined`
64
+ * and the axis keeps plotly's default labels. Only the first (positive)
65
+ * section is used — plotly applies one format to every tick.
66
+ */
67
+ export declare const numberFormatToPlotlyTicks: (pattern: string | undefined) => PlotlyTickFormat | undefined;
68
+ export {};
69
+ //# sourceMappingURL=axis-number-format.d.ts.map
@@ -0,0 +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,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC;IACrC,sBAAsB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtD,uBAAuB,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC5D,KAAG,MAAM,GAAG,SAQZ,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,GAAG,SAAS,EAC3B,OAAO,OAAO,KACb,MAIF,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,GAAI,SAAS,MAAM,GAAG,SAAS,cAC/C,OAAO,wBAAgD,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,MAAM,GAAG,SAAS,cAEnD,OAAO,mCAIN,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,EAChD,wBAAwB,iBAAiB,GAAG,SAAS,EACrD,0BAA0B,yBAAyB,GAAG,IAAI,KACzD,CAAC,MAAM,GAAG,SAAS,CAAC,EAOpB,CAAC;AAEJ,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,GAClC,SAAS,MAAM,GAAG,SAAS,MAC3B,QAAQ;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,WAGvD,CAAC;AAET,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,MAAM,GAAG,SAAS,KAC1B,gBAAgB,GAAG,SA4DrB,CAAC"}
@@ -0,0 +1,170 @@
1
+ import { ssfFormat } from "@rowsncolumns/utils";
2
+ const patternOf = (format) => format
3
+ ?.numberFormat?.pattern;
4
+ /**
5
+ * `General` (or nothing) means "let the renderer pick" — it carries no
6
+ * formatting. So does the bare-`#` shape the engines infer when a plain
7
+ * number is typed (`#`, `#.0`): Excel leaves such cells General, and `#`
8
+ * would blank every fractional tick below 0.5.
9
+ */
10
+ export const isGeneralNumberFormat = (pattern) => !pattern ||
11
+ pattern.trim().toLowerCase() === "general" ||
12
+ /^#+(\.[#0]*)?$/.test(pattern.trim());
13
+ /**
14
+ * The number format of a series' source cells — the first formatted cell of
15
+ * its first source range, matching Excel which links the axis to the first
16
+ * series' cell format.
17
+ */
18
+ export const resolveSourceNumberFormat = (sources, getFormattingFromRange, hiddenDimensionStrategy) => {
19
+ const source = sources?.[0];
20
+ if (!source || !getFormattingFromRange)
21
+ return undefined;
22
+ for (const format of getFormattingFromRange(source, hiddenDimensionStrategy ?? undefined) ?? []) {
23
+ const pattern = patternOf(format);
24
+ if (!isGeneralNumberFormat(pattern))
25
+ return pattern ?? undefined;
26
+ }
27
+ return undefined;
28
+ };
29
+ /**
30
+ * Effective number format of one value axis: the axis' explicit
31
+ * `numberFormatPattern` wins, else the format of the first series bound to
32
+ * that axis ("Linked to source"), else `undefined` (renderer default).
33
+ */
34
+ export const resolveValueAxisNumberFormat = ({ axisOptions, series, getFormattingFromRange, hiddenDimensionStrategy, }) => {
35
+ const explicit = axisOptions?.numberFormatPattern;
36
+ if (explicit)
37
+ return isGeneralNumberFormat(explicit) ? undefined : explicit;
38
+ return resolveSourceNumberFormat(series[0]?.sources, getFormattingFromRange, hiddenDimensionStrategy);
39
+ };
40
+ /** Format one numeric value through the resolved pattern; non-numbers pass through. */
41
+ export const formatAxisValue = (pattern, value) => {
42
+ if (value === undefined || value === null)
43
+ return "";
44
+ if (pattern && typeof value === "number")
45
+ return ssfFormat(pattern, value);
46
+ return String(value);
47
+ };
48
+ /** echarts `axisLabel.formatter` / `tooltip.valueFormatter` for a value axis. */
49
+ export const valueAxisLabelFormatter = (pattern) => pattern ? (value) => formatAxisValue(pattern, value) : undefined;
50
+ /**
51
+ * echarts `tooltip.valueFormatter` for a series whose data items are
52
+ * tuples (candlestick, 3-D points): every number formats through the
53
+ * pattern; `undefined` when there is no pattern so echarts keeps its
54
+ * default.
55
+ */
56
+ export const tooltipValueFormatter = (pattern) => pattern
57
+ ? (value) => Array.isArray(value)
58
+ ? value.map((entry) => formatAxisValue(pattern, entry))
59
+ : formatAxisValue(pattern, value)
60
+ : undefined;
61
+ /**
62
+ * Excel's data labels and tooltips are linked to *each series' own* source
63
+ * cells, not to the axis: a revenue series formatted `$#,##0` next to a
64
+ * margin series formatted `0.0%` labels each with its own pattern. One
65
+ * entry per `spec.series`, `undefined` where the cells are General.
66
+ */
67
+ export const resolveSeriesNumberFormats = (series, getFormattingFromRange, hiddenDimensionStrategy) => (series ?? []).map((entry) => resolveSourceNumberFormat(entry?.sources, getFormattingFromRange, hiddenDimensionStrategy));
68
+ /** echarts pie / doughnut tooltip: `name: value (percent%)` with the value formatted. */
69
+ export const circularTooltipFormatter = (pattern) => (params) => `${params.name ?? ""}: ${formatAxisValue(pattern, params.value)} (${params.percent ?? ""}%)`;
70
+ /**
71
+ * Translate the numeric subset of a SpreadsheetML pattern into plotly's
72
+ * d3-format axis settings (`tickformat` + literal prefix / suffix). Plotly
73
+ * has no per-tick callback, so only patterns made of digit placeholders,
74
+ * grouping, decimals, `%` and quoted / currency literals convert; anything
75
+ * else (dates, fractions, scientific, text sections) returns `undefined`
76
+ * and the axis keeps plotly's default labels. Only the first (positive)
77
+ * section is used — plotly applies one format to every tick.
78
+ */
79
+ export const numberFormatToPlotlyTicks = (pattern) => {
80
+ if (isGeneralNumberFormat(pattern))
81
+ return undefined;
82
+ const section = firstSection(pattern);
83
+ let prefix = "";
84
+ let suffix = "";
85
+ let digits = "";
86
+ let percent = false;
87
+ let seenDigit = false;
88
+ for (let i = 0; i < section.length; i++) {
89
+ const ch = section[i];
90
+ const literal = (text) => {
91
+ if (seenDigit)
92
+ suffix += text;
93
+ else
94
+ prefix += text;
95
+ };
96
+ if (ch === '"') {
97
+ const end = section.indexOf('"', i + 1);
98
+ if (end === -1)
99
+ return undefined;
100
+ literal(section.slice(i + 1, end));
101
+ i = end;
102
+ }
103
+ else if (ch === "\\") {
104
+ literal(section[i + 1] ?? "");
105
+ i += 1;
106
+ }
107
+ else if (ch === "[") {
108
+ const end = section.indexOf("]", i + 1);
109
+ if (end === -1)
110
+ return undefined;
111
+ const token = section.slice(i + 1, end);
112
+ // `[$€-407]` locale currency → the symbol; color / condition tokens
113
+ // carry no text.
114
+ if (token.startsWith("$")) {
115
+ const dash = token.indexOf("-");
116
+ literal(dash === -1 ? token.slice(1) : token.slice(1, dash));
117
+ }
118
+ i = end;
119
+ }
120
+ else if (ch === "_") {
121
+ literal(" ");
122
+ i += 1;
123
+ }
124
+ else if (ch === "*") {
125
+ i += 1;
126
+ }
127
+ else if (ch === "#" || ch === "0" || ch === "," || ch === ".") {
128
+ if (seenDigit && suffix)
129
+ return undefined;
130
+ seenDigit = true;
131
+ digits += ch;
132
+ }
133
+ else if (ch === "%") {
134
+ if (!seenDigit)
135
+ return undefined;
136
+ percent = true;
137
+ }
138
+ else if ("$€£¥₹ -+()/:".includes(ch)) {
139
+ literal(ch);
140
+ }
141
+ else {
142
+ return undefined;
143
+ }
144
+ }
145
+ if (!seenDigit)
146
+ return undefined;
147
+ const [, fraction = ""] = digits.split(".");
148
+ const grouping = digits.includes(",") ? "," : "";
149
+ const decimals = fraction.replace(/[^0#]/g, "").length;
150
+ const tickformat = `${grouping}.${decimals}${percent ? "%" : "f"}`;
151
+ const result = { tickformat };
152
+ if (prefix)
153
+ result.tickprefix = prefix;
154
+ if (suffix)
155
+ result.ticksuffix = suffix;
156
+ return result;
157
+ };
158
+ const firstSection = (pattern) => {
159
+ let quoted = false;
160
+ for (let i = 0; i < pattern.length; i++) {
161
+ const ch = pattern[i];
162
+ if (ch === '"')
163
+ quoted = !quoted;
164
+ else if (ch === "\\")
165
+ i += 1;
166
+ else if (ch === ";" && !quoted)
167
+ return pattern.slice(0, i);
168
+ }
169
+ return pattern;
170
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Hierarchical (multi-level) category axes — what Excel draws for a PivotChart
3
+ * over nested row fields: the leaf items along the axis with their parent
4
+ * labels grouped underneath. `ChartSpec.categoryLevels` carries the levels
5
+ * outermost first, the last one being the plotted categories.
6
+ */
7
+ export type CategoryLevels = {
8
+ /** Outer levels, outermost first; each aligned to `leaf` (a parent label repeats per leaf). */
9
+ outer: string[][];
10
+ /** The plotted categories. */
11
+ leaf: string[];
12
+ };
13
+ /** The resolved level values → the axis shape, or `undefined` when there is nothing to group. */
14
+ export declare const resolveCategoryLevels: (levels: ReadonlyArray<ReadonlyArray<unknown>> | undefined | null) => CategoryLevels | undefined;
15
+ /** plotly `multicategory` x: the outer levels first, the leaf labels last. */
16
+ export declare const plotlyMulticategoryX: (levels: CategoryLevels) => string[][];
17
+ /** Index of the first leaf of every run of equal labels in `level`. */
18
+ export declare const groupStarts: (level: ReadonlyArray<string>) => number[];
19
+ /**
20
+ * echarts has no multi-level category axis: the leaf axis is the real one
21
+ * (`base` — the caller's styled category axis, series bind to it) and every
22
+ * outer level becomes a label-only axis below it whose ticks sit on the group
23
+ * boundaries and whose label is written once per group, at the group's first
24
+ * leaf.
25
+ */
26
+ export declare const echartsGroupedCategoryAxes: <T extends Record<string, unknown>>(levels: CategoryLevels, base: T, labelOffset?: number) => Array<Record<string, unknown>>;
27
+ //# sourceMappingURL=category-levels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category-levels.d.ts","sourceRoot":"","sources":["../../../utils/category-levels.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,+FAA+F;IAC/F,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;IAClB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAKF,iGAAiG;AACjG,eAAO,MAAM,qBAAqB,GAChC,QAAQ,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,KAC/D,cAAc,GAAG,SAQnB,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,GAAI,QAAQ,cAAc,KAAG,MAAM,EAAE,EAGrE,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,WAAW,GAAI,OAAO,aAAa,CAAC,MAAM,CAAC,KAAG,MAAM,EAIzD,CAAC;AAET;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1E,QAAQ,cAAc,EACtB,MAAM,CAAC,EACP,oBAAgB,KACf,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4B/B,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Hierarchical (multi-level) category axes — what Excel draws for a PivotChart
3
+ * over nested row fields: the leaf items along the axis with their parent
4
+ * labels grouped underneath. `ChartSpec.categoryLevels` carries the levels
5
+ * outermost first, the last one being the plotted categories.
6
+ */
7
+ const text = (value) => value === null || value === undefined ? "" : String(value);
8
+ /** The resolved level values → the axis shape, or `undefined` when there is nothing to group. */
9
+ export const resolveCategoryLevels = (levels) => {
10
+ if (!levels || levels.length === 0)
11
+ return undefined;
12
+ const leaf = levels[levels.length - 1].map(text);
13
+ if (leaf.length === 0)
14
+ return undefined;
15
+ const outer = levels
16
+ .slice(0, -1)
17
+ .map((level) => leaf.map((_, index) => text(level[index])));
18
+ return { outer, leaf };
19
+ };
20
+ /** plotly `multicategory` x: the outer levels first, the leaf labels last. */
21
+ export const plotlyMulticategoryX = (levels) => [
22
+ ...levels.outer,
23
+ levels.leaf,
24
+ ];
25
+ /** Index of the first leaf of every run of equal labels in `level`. */
26
+ export const groupStarts = (level) => level.reduce((starts, label, index) => {
27
+ if (index === 0 || label !== level[index - 1])
28
+ starts.push(index);
29
+ return starts;
30
+ }, []);
31
+ /**
32
+ * echarts has no multi-level category axis: the leaf axis is the real one
33
+ * (`base` — the caller's styled category axis, series bind to it) and every
34
+ * outer level becomes a label-only axis below it whose ticks sit on the group
35
+ * boundaries and whose label is written once per group, at the group's first
36
+ * leaf.
37
+ */
38
+ export const echartsGroupedCategoryAxes = (levels, base, labelOffset = 24) => {
39
+ const axes = [{ ...base, data: levels.leaf }];
40
+ // Innermost outer level sits closest to the leaf axis.
41
+ [...levels.outer].reverse().forEach((level, depth) => {
42
+ const starts = new Set(groupStarts(level));
43
+ axes.push({
44
+ type: "category",
45
+ position: base.position ?? "bottom",
46
+ offset: labelOffset * (depth + 1),
47
+ data: levels.leaf.map((_, index) => `${index}`),
48
+ show: base.show ?? true,
49
+ axisLine: { show: false },
50
+ splitLine: { show: false },
51
+ axisTick: {
52
+ show: true,
53
+ length: labelOffset,
54
+ interval: (index) => starts.has(index),
55
+ alignWithLabel: false,
56
+ },
57
+ axisLabel: {
58
+ interval: 0,
59
+ formatter: (_, index) => starts.has(index) ? level[index] : "",
60
+ },
61
+ nameLocation: "middle",
62
+ });
63
+ });
64
+ return axes;
65
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A `data:image/png;base64,…` URL (what echarts' `getDataURL` and plotly's
3
+ * `toImage` hand back) as a Blob for the clipboard / print pipeline.
4
+ * Decoded locally so no fetch is needed. `undefined` for anything that is
5
+ * not a base64 data URL.
6
+ */
7
+ export declare const dataUrlToBlob: (dataUrl: string | undefined) => Blob | undefined;
8
+ //# sourceMappingURL=chart-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-image.d.ts","sourceRoot":"","sources":["../../../utils/chart-image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,KAAG,IAAI,GAAG,SAalE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A `data:image/png;base64,…` URL (what echarts' `getDataURL` and plotly's
3
+ * `toImage` hand back) as a Blob for the clipboard / print pipeline.
4
+ * Decoded locally so no fetch is needed. `undefined` for anything that is
5
+ * not a base64 data URL.
6
+ */
7
+ export const dataUrlToBlob = (dataUrl) => {
8
+ if (!dataUrl)
9
+ return undefined;
10
+ const match = /^data:([^;,]+)?(;base64)?,([\s\S]*)$/.exec(dataUrl);
11
+ if (!match || !match[2])
12
+ return undefined;
13
+ const mime = match[1] || "image/png";
14
+ try {
15
+ const binary = atob(match[3]);
16
+ const bytes = new Uint8Array(binary.length);
17
+ for (let i = 0; i < binary.length; i++)
18
+ bytes[i] = binary.charCodeAt(i);
19
+ return new Blob([bytes], { type: mime });
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ };
@@ -0,0 +1,67 @@
1
+ import type { ChartData, EmbeddedChart, HIDDEN_DIMENSION_STRATEGY, SheetRange } from "@rowsncolumns/spreadsheet";
2
+ type ChartSpec = EmbeddedChart["spec"];
3
+ export type SeriesOrientation = NonNullable<ChartSpec["seriesOrientation"]>;
4
+ /** Formatted text of one cell — the series name / category label source. */
5
+ export type ChartCellLabelGetter = (sheetId: number, rowIndex: number, columnIndex: number) => string | null | undefined;
6
+ /**
7
+ * Adapt a range reader (the renderers' `getDomainValuesFromRange`) into
8
+ * the single-cell label getter the orientation helpers take.
9
+ */
10
+ export declare const cellLabelGetterFromRangeReader: (readRange: (range: SheetRange, hiddenStrategy?: HIDDEN_DIMENSION_STRATEGY | null) => readonly unknown[]) => ChartCellLabelGetter;
11
+ /**
12
+ * Which way a chart's series run. The explicit flag wins; otherwise a
13
+ * chart whose every series is a single row spanning several columns is
14
+ * Excel's series-in-rows shape (OOXML carries no flag — each `<c:ser>` is
15
+ * its own reference — so imported charts are read this way).
16
+ */
17
+ export declare const inferSeriesOrientation: (spec: ChartSpec) => SeriesOrientation;
18
+ export declare const flipSeriesOrientation: (orientation: SeriesOrientation) => SeriesOrientation;
19
+ /**
20
+ * Excel's chart wizard picks series-in-rows when the selection is wider
21
+ * than it is tall.
22
+ */
23
+ export declare const pickSeriesOrientationForRange: (range: Omit<SheetRange, "sheetId">) => SeriesOrientation;
24
+ /**
25
+ * Split a data range the way Excel's chart wizard does. Series in
26
+ * columns: the first column (beneath the header row) is the category
27
+ * axis and every further column is one series named by its header cell.
28
+ * Series in rows is the transpose: the first row (right of the header
29
+ * column) is the category axis and every further row is a series named
30
+ * by its first cell. A range only one row (column) tall still yields a
31
+ * one-cell-deep axis so the chart has something to plot.
32
+ */
33
+ export declare const deriveChartSeriesFromRange: ({ range, orientation, getFormattedValue, }: {
34
+ range: SheetRange;
35
+ orientation: SeriesOrientation;
36
+ getFormattedValue?: ChartCellLabelGetter;
37
+ }) => {
38
+ domains: ChartData[];
39
+ series: ChartData[];
40
+ };
41
+ /**
42
+ * The block the series tile when they form one rectangle: every series
43
+ * is a single source on the same sheet, all single columns sharing one
44
+ * row span (series in columns) or all single rows sharing one column
45
+ * span (series in rows), and adjacent to each other in order. Undefined
46
+ * for anything else — there is no meaningful transpose of scattered
47
+ * sources.
48
+ */
49
+ export declare const rectangularSeriesBounds: (spec: ChartSpec, orientation: SeriesOrientation) => SheetRange | undefined;
50
+ /** Whether `switchRowColumn` has a transpose to offer for this chart. */
51
+ export declare const canSwitchRowColumn: (spec: ChartSpec) => boolean;
52
+ /**
53
+ * Excel's "Switch Row/Column". With a `dataRange` the series and
54
+ * category axis are re-derived from it the other way round. Without one,
55
+ * rectangular series sources are transposed: each row (column) of the
56
+ * block becomes a series, named after the old category cell beside it,
57
+ * and the old series names become the categories (Excel's behaviour —
58
+ * the names are carried as inline values because the spec stores them
59
+ * as text, not as a cell reference). Per-series presentation (colours,
60
+ * trendlines, …) does not survive the transpose, as in Excel. Returns
61
+ * undefined when the sources cannot be transposed.
62
+ */
63
+ export declare const switchRowColumn: (spec: ChartSpec, { getFormattedValue }?: {
64
+ getFormattedValue?: ChartCellLabelGetter;
65
+ }) => ChartSpec | undefined;
66
+ export {};
67
+ //# sourceMappingURL=chart-orientation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-orientation.d.ts","sourceRoot":"","sources":["../../../utils/chart-orientation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,yBAAyB,EACzB,UAAU,EACX,MAAM,2BAA2B,CAAC;AAInC,KAAK,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAE5E,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,KAChB,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/B;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GAEvC,WAAW,CACT,KAAK,EAAE,UAAU,EACjB,cAAc,CAAC,EAAE,yBAAyB,GAAG,IAAI,KAC9C,SAAS,OAAO,EAAE,KACtB,oBAaF,CAAC;AAOJ;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,SAAS,KAAG,iBAQxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,aAAa,iBAAiB,KAC7B,iBAAkE,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,6BAA6B,GACxC,OAAO,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,KACjC,iBAIY,CAAC;AAEhB;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GAAI,4CAIxC;IACD,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;CAC1C,KAAG;IAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAA;CA4D9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,SAAS,EACf,aAAa,iBAAiB,KAC7B,UAAU,GAAG,SAsCf,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,GAAI,MAAM,SAAS,KAAG,OAIrC,CAAC;AAEjB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,SAAS,EACf,wBAAuB;IAAE,iBAAiB,CAAC,EAAE,oBAAoB,CAAA;CAAO,KACvE,SAAS,GAAG,SA8Ed,CAAC"}