@rowsncolumns/charts 27.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +100 -0
- package/Readme.md +81 -0
- package/dist/cjs/atoms/editing-chart.atom.d.ts +13 -0
- package/dist/cjs/atoms/editing-chart.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/editing-chart.atom.js +26 -0
- package/dist/cjs/basic-chart/basic-chart.d.ts +5 -0
- package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -0
- package/dist/cjs/basic-chart/basic-chart.js +2250 -0
- package/dist/cjs/basic-chart/helpers.d.ts +12 -0
- package/dist/cjs/basic-chart/helpers.d.ts.map +1 -0
- package/dist/cjs/basic-chart/helpers.js +105 -0
- package/dist/cjs/basic-chart/index.d.ts +5 -0
- package/dist/cjs/basic-chart/index.d.ts.map +1 -0
- package/dist/cjs/basic-chart/index.js +12 -0
- package/dist/cjs/components/dialogs/chart-editor-dialog.d.ts +5 -0
- package/dist/cjs/components/dialogs/chart-editor-dialog.d.ts.map +1 -0
- package/dist/cjs/components/dialogs/chart-editor-dialog.js +25 -0
- package/dist/cjs/components/editors/chart-editor.d.ts +10 -0
- package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/chart-editor.js +631 -0
- package/dist/cjs/components/editors/chart-range-input.d.ts +17 -0
- package/dist/cjs/components/editors/chart-range-input.d.ts.map +1 -0
- package/dist/cjs/components/editors/chart-range-input.js +16 -0
- package/dist/cjs/config.d.ts +19 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/config.js +196 -0
- package/dist/cjs/hooks/use-chart-editor.d.ts +8 -0
- package/dist/cjs/hooks/use-chart-editor.d.ts.map +1 -0
- package/dist/cjs/hooks/use-chart-editor.js +29 -0
- package/dist/cjs/hooks/use-charts.d.ts +35 -0
- package/dist/cjs/hooks/use-charts.d.ts.map +1 -0
- package/dist/cjs/hooks/use-charts.js +67 -0
- package/dist/cjs/hooks/use-on-create-chart.d.ts +13 -0
- package/dist/cjs/hooks/use-on-create-chart.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-create-chart.js +24 -0
- package/dist/cjs/hooks/use-on-delete-chart.d.ts +8 -0
- package/dist/cjs/hooks/use-on-delete-chart.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-chart.js +19 -0
- package/dist/cjs/hooks/use-on-move-chart.d.ts +8 -0
- package/dist/cjs/hooks/use-on-move-chart.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-chart.js +15 -0
- package/dist/cjs/hooks/use-on-resize-chart.d.ts +8 -0
- package/dist/cjs/hooks/use-on-resize-chart.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-resize-chart.js +15 -0
- package/dist/cjs/hooks/use-on-update-chart.d.ts +9 -0
- package/dist/cjs/hooks/use-on-update-chart.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-update-chart.js +15 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/interface/create-chart.d.ts +9 -0
- package/dist/cjs/interface/create-chart.d.ts.map +1 -0
- package/dist/cjs/interface/create-chart.js +110 -0
- package/dist/cjs/interface/delete-chart.d.ts +4 -0
- package/dist/cjs/interface/delete-chart.d.ts.map +1 -0
- package/dist/cjs/interface/delete-chart.js +26 -0
- package/dist/cjs/interface/move-chart.d.ts +5 -0
- package/dist/cjs/interface/move-chart.d.ts.map +1 -0
- package/dist/cjs/interface/move-chart.js +28 -0
- package/dist/cjs/interface/resize-chart.d.ts +5 -0
- package/dist/cjs/interface/resize-chart.d.ts.map +1 -0
- package/dist/cjs/interface/resize-chart.js +30 -0
- package/dist/cjs/interface/update-chart.d.ts +4 -0
- package/dist/cjs/interface/update-chart.d.ts.map +1 -0
- package/dist/cjs/interface/update-chart.js +29 -0
- package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +5 -0
- package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -0
- package/dist/cjs/plotly/basic-chart/basic-chart.js +1586 -0
- package/dist/cjs/plotly/basic-chart/helpers.d.ts +20 -0
- package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -0
- package/dist/cjs/plotly/basic-chart/helpers.js +114 -0
- package/dist/cjs/plotly/basic-chart/index.d.ts +5 -0
- package/dist/cjs/plotly/basic-chart/index.d.ts.map +1 -0
- package/dist/cjs/plotly/basic-chart/index.js +12 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/cjs/types.d.ts +27 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/utils/aggregation.d.ts +6 -0
- package/dist/cjs/utils/aggregation.d.ts.map +1 -0
- package/dist/cjs/utils/aggregation.js +127 -0
- package/dist/cjs/utils/bar-layout.d.ts +57 -0
- package/dist/cjs/utils/bar-layout.d.ts.map +1 -0
- package/dist/cjs/utils/bar-layout.js +81 -0
- package/dist/cjs/utils/boxplot.d.ts +62 -0
- package/dist/cjs/utils/boxplot.d.ts.map +1 -0
- package/dist/cjs/utils/boxplot.js +105 -0
- package/dist/cjs/utils/bubble.d.ts +52 -0
- package/dist/cjs/utils/bubble.d.ts.map +1 -0
- package/dist/cjs/utils/bubble.js +139 -0
- package/dist/cjs/utils/chart-spec-utils.d.ts +67 -0
- package/dist/cjs/utils/chart-spec-utils.d.ts.map +1 -0
- package/dist/cjs/utils/chart-spec-utils.js +355 -0
- package/dist/cjs/utils/echarts-gl-loader.d.ts +11 -0
- package/dist/cjs/utils/echarts-gl-loader.d.ts.map +1 -0
- package/dist/cjs/utils/echarts-gl-loader.js +59 -0
- package/dist/cjs/utils/error-bars.d.ts +58 -0
- package/dist/cjs/utils/error-bars.d.ts.map +1 -0
- package/dist/cjs/utils/error-bars.js +154 -0
- package/dist/cjs/utils/gradient.d.ts +52 -0
- package/dist/cjs/utils/gradient.d.ts.map +1 -0
- package/dist/cjs/utils/gradient.js +93 -0
- package/dist/cjs/utils/hierarchy.d.ts +28 -0
- package/dist/cjs/utils/hierarchy.d.ts.map +1 -0
- package/dist/cjs/utils/hierarchy.js +186 -0
- package/dist/cjs/utils/histogram.d.ts +46 -0
- package/dist/cjs/utils/histogram.d.ts.map +1 -0
- package/dist/cjs/utils/histogram.js +125 -0
- package/dist/cjs/utils/of-pie.d.ts +101 -0
- package/dist/cjs/utils/of-pie.d.ts.map +1 -0
- package/dist/cjs/utils/of-pie.js +159 -0
- package/dist/cjs/utils/overrides.d.ts +12 -0
- package/dist/cjs/utils/overrides.d.ts.map +1 -0
- package/dist/cjs/utils/overrides.js +171 -0
- package/dist/cjs/utils/radar.d.ts +37 -0
- package/dist/cjs/utils/radar.d.ts.map +1 -0
- package/dist/cjs/utils/radar.js +70 -0
- package/dist/cjs/utils/region-map-loader.d.ts +22 -0
- package/dist/cjs/utils/region-map-loader.d.ts.map +1 -0
- package/dist/cjs/utils/region-map-loader.js +174 -0
- package/dist/cjs/utils/region-map.d.ts +100 -0
- package/dist/cjs/utils/region-map.d.ts.map +1 -0
- package/dist/cjs/utils/region-map.js +327 -0
- package/dist/cjs/utils/stock.d.ts +64 -0
- package/dist/cjs/utils/stock.d.ts.map +1 -0
- package/dist/cjs/utils/stock.js +153 -0
- package/dist/cjs/utils/three-d.d.ts +96 -0
- package/dist/cjs/utils/three-d.d.ts.map +1 -0
- package/dist/cjs/utils/three-d.js +191 -0
- package/dist/cjs/utils/trendline.d.ts +41 -0
- package/dist/cjs/utils/trendline.d.ts.map +1 -0
- package/dist/cjs/utils/trendline.js +303 -0
- package/dist/cjs/utils/waterfall.d.ts +24 -0
- package/dist/cjs/utils/waterfall.d.ts.map +1 -0
- package/dist/cjs/utils/waterfall.js +61 -0
- package/dist/cjs/utils/webgl.d.ts +12 -0
- package/dist/cjs/utils/webgl.d.ts.map +1 -0
- package/dist/cjs/utils/webgl.js +36 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +9 -0
- package/dist/esm/atoms/editing-chart.atom.d.ts +13 -0
- package/dist/esm/atoms/editing-chart.atom.d.ts.map +1 -0
- package/dist/esm/atoms/editing-chart.atom.js +12 -0
- package/dist/esm/basic-chart/basic-chart.d.ts +5 -0
- package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -0
- package/dist/esm/basic-chart/basic-chart.js +2343 -0
- package/dist/esm/basic-chart/helpers.d.ts +12 -0
- package/dist/esm/basic-chart/helpers.d.ts.map +1 -0
- package/dist/esm/basic-chart/helpers.js +98 -0
- package/dist/esm/basic-chart/index.d.ts +5 -0
- package/dist/esm/basic-chart/index.d.ts.map +1 -0
- package/dist/esm/basic-chart/index.js +7 -0
- package/dist/esm/components/dialogs/chart-editor-dialog.d.ts +5 -0
- package/dist/esm/components/dialogs/chart-editor-dialog.d.ts.map +1 -0
- package/dist/esm/components/dialogs/chart-editor-dialog.js +19 -0
- package/dist/esm/components/editors/chart-editor.d.ts +10 -0
- package/dist/esm/components/editors/chart-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/chart-editor.js +550 -0
- package/dist/esm/components/editors/chart-range-input.d.ts +17 -0
- package/dist/esm/components/editors/chart-range-input.d.ts.map +1 -0
- package/dist/esm/components/editors/chart-range-input.js +10 -0
- package/dist/esm/config.d.ts +19 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +161 -0
- package/dist/esm/hooks/use-chart-editor.d.ts +8 -0
- package/dist/esm/hooks/use-chart-editor.d.ts.map +1 -0
- package/dist/esm/hooks/use-chart-editor.js +32 -0
- package/dist/esm/hooks/use-charts.d.ts +35 -0
- package/dist/esm/hooks/use-charts.d.ts.map +1 -0
- package/dist/esm/hooks/use-charts.js +62 -0
- package/dist/esm/hooks/use-on-create-chart.d.ts +13 -0
- package/dist/esm/hooks/use-on-create-chart.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-create-chart.js +19 -0
- package/dist/esm/hooks/use-on-delete-chart.d.ts +8 -0
- package/dist/esm/hooks/use-on-delete-chart.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-chart.js +14 -0
- package/dist/esm/hooks/use-on-move-chart.d.ts +8 -0
- package/dist/esm/hooks/use-on-move-chart.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-chart.js +10 -0
- package/dist/esm/hooks/use-on-resize-chart.d.ts +8 -0
- package/dist/esm/hooks/use-on-resize-chart.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-resize-chart.js +10 -0
- package/dist/esm/hooks/use-on-update-chart.d.ts +9 -0
- package/dist/esm/hooks/use-on-update-chart.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-update-chart.js +10 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/interface/create-chart.d.ts +9 -0
- package/dist/esm/interface/create-chart.d.ts.map +1 -0
- package/dist/esm/interface/create-chart.js +126 -0
- package/dist/esm/interface/delete-chart.d.ts +4 -0
- package/dist/esm/interface/delete-chart.d.ts.map +1 -0
- package/dist/esm/interface/delete-chart.js +20 -0
- package/dist/esm/interface/move-chart.d.ts +5 -0
- package/dist/esm/interface/move-chart.d.ts.map +1 -0
- package/dist/esm/interface/move-chart.js +22 -0
- package/dist/esm/interface/resize-chart.d.ts +5 -0
- package/dist/esm/interface/resize-chart.d.ts.map +1 -0
- package/dist/esm/interface/resize-chart.js +24 -0
- package/dist/esm/interface/update-chart.d.ts +4 -0
- package/dist/esm/interface/update-chart.d.ts.map +1 -0
- package/dist/esm/interface/update-chart.js +26 -0
- package/dist/esm/plotly/basic-chart/basic-chart.d.ts +5 -0
- package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -0
- package/dist/esm/plotly/basic-chart/basic-chart.js +1682 -0
- package/dist/esm/plotly/basic-chart/helpers.d.ts +20 -0
- package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -0
- package/dist/esm/plotly/basic-chart/helpers.js +107 -0
- package/dist/esm/plotly/basic-chart/index.d.ts +5 -0
- package/dist/esm/plotly/basic-chart/index.d.ts.map +1 -0
- package/dist/esm/plotly/basic-chart/index.js +7 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +27 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/aggregation.d.ts +6 -0
- package/dist/esm/utils/aggregation.d.ts.map +1 -0
- package/dist/esm/utils/aggregation.js +96 -0
- package/dist/esm/utils/bar-layout.d.ts +57 -0
- package/dist/esm/utils/bar-layout.d.ts.map +1 -0
- package/dist/esm/utils/bar-layout.js +70 -0
- package/dist/esm/utils/boxplot.d.ts +62 -0
- package/dist/esm/utils/boxplot.d.ts.map +1 -0
- package/dist/esm/utils/boxplot.js +91 -0
- package/dist/esm/utils/bubble.d.ts +52 -0
- package/dist/esm/utils/bubble.d.ts.map +1 -0
- package/dist/esm/utils/bubble.js +122 -0
- package/dist/esm/utils/chart-spec-utils.d.ts +67 -0
- package/dist/esm/utils/chart-spec-utils.d.ts.map +1 -0
- package/dist/esm/utils/chart-spec-utils.js +270 -0
- package/dist/esm/utils/echarts-gl-loader.d.ts +11 -0
- package/dist/esm/utils/echarts-gl-loader.d.ts.map +1 -0
- package/dist/esm/utils/echarts-gl-loader.js +51 -0
- package/dist/esm/utils/error-bars.d.ts +58 -0
- package/dist/esm/utils/error-bars.d.ts.map +1 -0
- package/dist/esm/utils/error-bars.js +134 -0
- package/dist/esm/utils/gradient.d.ts +52 -0
- package/dist/esm/utils/gradient.d.ts.map +1 -0
- package/dist/esm/utils/gradient.js +84 -0
- package/dist/esm/utils/hierarchy.d.ts +28 -0
- package/dist/esm/utils/hierarchy.d.ts.map +1 -0
- package/dist/esm/utils/hierarchy.js +150 -0
- package/dist/esm/utils/histogram.d.ts +46 -0
- package/dist/esm/utils/histogram.d.ts.map +1 -0
- package/dist/esm/utils/histogram.js +95 -0
- package/dist/esm/utils/of-pie.d.ts +101 -0
- package/dist/esm/utils/of-pie.d.ts.map +1 -0
- package/dist/esm/utils/of-pie.js +141 -0
- package/dist/esm/utils/overrides.d.ts +12 -0
- package/dist/esm/utils/overrides.d.ts.map +1 -0
- package/dist/esm/utils/overrides.js +159 -0
- package/dist/esm/utils/radar.d.ts +37 -0
- package/dist/esm/utils/radar.d.ts.map +1 -0
- package/dist/esm/utils/radar.js +49 -0
- package/dist/esm/utils/region-map-loader.d.ts +22 -0
- package/dist/esm/utils/region-map-loader.d.ts.map +1 -0
- package/dist/esm/utils/region-map-loader.js +141 -0
- package/dist/esm/utils/region-map.d.ts +100 -0
- package/dist/esm/utils/region-map.d.ts.map +1 -0
- package/dist/esm/utils/region-map.js +266 -0
- package/dist/esm/utils/stock.d.ts +64 -0
- package/dist/esm/utils/stock.d.ts.map +1 -0
- package/dist/esm/utils/stock.js +123 -0
- package/dist/esm/utils/three-d.d.ts +96 -0
- package/dist/esm/utils/three-d.d.ts.map +1 -0
- package/dist/esm/utils/three-d.js +162 -0
- package/dist/esm/utils/trendline.d.ts +41 -0
- package/dist/esm/utils/trendline.d.ts.map +1 -0
- package/dist/esm/utils/trendline.js +257 -0
- package/dist/esm/utils/waterfall.d.ts +24 -0
- package/dist/esm/utils/waterfall.d.ts.map +1 -0
- package/dist/esm/utils/waterfall.js +55 -0
- package/dist/esm/utils/webgl.d.ts +12 -0
- package/dist/esm/utils/webgl.d.ts.map +1 -0
- package/dist/esm/utils/webgl.js +30 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +7 -0
- package/package.json +96 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EmbeddedChart } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
export declare const chartTypeToPlotlyType: (type: EmbeddedChart["spec"]["chartType"]) => string;
|
|
3
|
+
export declare const getPlotlyTraceStyle: (type: EmbeddedChart["spec"]["chartType"]) => {
|
|
4
|
+
mode: "lines";
|
|
5
|
+
fill?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
mode: "lines";
|
|
8
|
+
fill: "tozeroy";
|
|
9
|
+
} | {
|
|
10
|
+
mode?: undefined;
|
|
11
|
+
fill?: undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Map OOXML `<c:marker><c:symbol val=…>` to plotly marker symbol names.
|
|
15
|
+
* OOXML symbols don't all have direct plotly equivalents — closest
|
|
16
|
+
* visual analog is used.
|
|
17
|
+
*/
|
|
18
|
+
export declare const mapMarkerSymbolToPlotly: (symbol: string | undefined | null) => string | undefined;
|
|
19
|
+
export declare const showXAxis: (type: EmbeddedChart["spec"]["chartType"]) => boolean;
|
|
20
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export const chartTypeToPlotlyType = (type) => {
|
|
2
|
+
switch (type) {
|
|
3
|
+
case "column":
|
|
4
|
+
return "bar";
|
|
5
|
+
case "line":
|
|
6
|
+
return "scatter";
|
|
7
|
+
case "area":
|
|
8
|
+
return "scatter";
|
|
9
|
+
case "bar":
|
|
10
|
+
return "bar";
|
|
11
|
+
case "pie":
|
|
12
|
+
return "pie";
|
|
13
|
+
case "treemap":
|
|
14
|
+
return "treemap";
|
|
15
|
+
case "sunburst":
|
|
16
|
+
return "sunburst";
|
|
17
|
+
case "bubble":
|
|
18
|
+
return "scatter";
|
|
19
|
+
case "scatter":
|
|
20
|
+
return "scatter";
|
|
21
|
+
case "histogram":
|
|
22
|
+
return "histogram";
|
|
23
|
+
case "boxplot":
|
|
24
|
+
return "box";
|
|
25
|
+
// Radar maps to plotly's polar scatter trace; the caller also sets a
|
|
26
|
+
// `polar` layout block. See basic-chart.tsx.
|
|
27
|
+
case "radar":
|
|
28
|
+
return "scatterpolar";
|
|
29
|
+
// Stock is rendered "line-derived" — each price role becomes its own
|
|
30
|
+
// scatter line trace. See basic-chart.tsx.
|
|
31
|
+
case "stock":
|
|
32
|
+
return "scatter";
|
|
33
|
+
case "waterfall":
|
|
34
|
+
return "waterfall";
|
|
35
|
+
case "funnel":
|
|
36
|
+
return "funnel";
|
|
37
|
+
// Combo defaults to bar; per-series seriesChartType overrides each
|
|
38
|
+
// trace independently. See chart-editor "Series type" selector.
|
|
39
|
+
case "combo":
|
|
40
|
+
return "bar";
|
|
41
|
+
// Region map (filled map) — plotly's built-in choropleth trace
|
|
42
|
+
// (plotly ships its own world geometry). See basic-chart.tsx.
|
|
43
|
+
case "regionMap":
|
|
44
|
+
return "choropleth";
|
|
45
|
+
default:
|
|
46
|
+
return "scatter";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export const getPlotlyTraceStyle = (type) => {
|
|
50
|
+
switch (type) {
|
|
51
|
+
case "line":
|
|
52
|
+
return { mode: "lines" };
|
|
53
|
+
case "area":
|
|
54
|
+
return { mode: "lines", fill: "tozeroy" };
|
|
55
|
+
// Stock price roles render as plain lines.
|
|
56
|
+
case "stock":
|
|
57
|
+
return { mode: "lines" };
|
|
58
|
+
default:
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Map OOXML `<c:marker><c:symbol val=…>` to plotly marker symbol names.
|
|
64
|
+
* OOXML symbols don't all have direct plotly equivalents — closest
|
|
65
|
+
* visual analog is used.
|
|
66
|
+
*/
|
|
67
|
+
export const mapMarkerSymbolToPlotly = (symbol) => {
|
|
68
|
+
switch (symbol) {
|
|
69
|
+
case "circle":
|
|
70
|
+
case "dot":
|
|
71
|
+
return "circle";
|
|
72
|
+
case "square":
|
|
73
|
+
return "square";
|
|
74
|
+
case "diamond":
|
|
75
|
+
return "diamond";
|
|
76
|
+
case "triangle":
|
|
77
|
+
return "triangle-up";
|
|
78
|
+
case "x":
|
|
79
|
+
return "x";
|
|
80
|
+
case "plus":
|
|
81
|
+
return "cross";
|
|
82
|
+
case "star":
|
|
83
|
+
return "star";
|
|
84
|
+
case "dash":
|
|
85
|
+
return "line-ew";
|
|
86
|
+
case "auto":
|
|
87
|
+
case undefined:
|
|
88
|
+
case null:
|
|
89
|
+
return undefined;
|
|
90
|
+
default:
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export const showXAxis = (type) => {
|
|
95
|
+
if (type === "line" ||
|
|
96
|
+
type === "area" ||
|
|
97
|
+
type === "bar" ||
|
|
98
|
+
type === "column" ||
|
|
99
|
+
type === "bubble" ||
|
|
100
|
+
type === "histogram" ||
|
|
101
|
+
// Stock is line-derived on a category x-axis. Radar is polar and
|
|
102
|
+
// does not use the cartesian x-axis.
|
|
103
|
+
type === "stock") {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,eAAO,MAAM,cAAc,GAAI,OAAO,oBAAoB,sBAMzD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BasicChart } from "./basic-chart";
|
|
3
|
+
export const ChartComponent = (props) => {
|
|
4
|
+
return (React.createElement("div", { className: "shadow-lg bg-rnc-background flex-1 flex break-words flex-col" },
|
|
5
|
+
React.createElement(BasicChart, { ...props })));
|
|
6
|
+
};
|
|
7
|
+
export default ChartComponent;
|
|
@@ -0,0 +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/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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChartComponentProps, EmbeddedChart } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import type { useCalculation } from "@rowsncolumns/spreadsheet-state";
|
|
3
|
+
import type { useSpreadsheetState } from "@rowsncolumns/spreadsheet-state";
|
|
4
|
+
export type EChartComponentProps = ChartComponentProps & {
|
|
5
|
+
/**
|
|
6
|
+
* Dark mode
|
|
7
|
+
*/
|
|
8
|
+
isDarkMode?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get all formatted values from a domain
|
|
11
|
+
*/
|
|
12
|
+
getDomainValuesFromRange: ReturnType<typeof useSpreadsheetState>["getDomainValuesFromRange"];
|
|
13
|
+
/**
|
|
14
|
+
* Get all effective values from a series
|
|
15
|
+
*/
|
|
16
|
+
getSeriesValuesFromRange: ReturnType<typeof useSpreadsheetState>["getSeriesValuesFromRange"];
|
|
17
|
+
/**
|
|
18
|
+
* Request edit chart
|
|
19
|
+
* @param chart
|
|
20
|
+
*/
|
|
21
|
+
onRequestEdit?(chart: EmbeddedChart): void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback to trigger a calculation request
|
|
24
|
+
*/
|
|
25
|
+
onRequestCalculate: ReturnType<typeof useCalculation>["onRequestCalculate"];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ChartAggregateType, ChartData } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
export declare const sanitizeDomainValues: (values: (string | number | null | undefined)[]) => string[];
|
|
3
|
+
export declare const shouldAggregateSeries: (series?: ChartData[]) => boolean;
|
|
4
|
+
export declare const getDomainValuesForAxis: (domainValues: string[], aggregate: boolean) => string[];
|
|
5
|
+
export declare const aggregateSeriesByDomain: (rawDomainValues: string[], seriesValues: (string | number | boolean | undefined)[], aggregateType: ChartAggregateType, orderedDomainValues: string[]) => (number | null)[];
|
|
6
|
+
//# sourceMappingURL=aggregation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregation.d.ts","sourceRoot":"","sources":["../../../utils/aggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACV,MAAM,2BAA2B,CAAC;AA0EnC,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KAC7C,MAAM,EAA+B,CAAC;AAEzC,eAAO,MAAM,qBAAqB,GAAI,SAAS,SAAS,EAAE,KAAG,OAM5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,cAAc,MAAM,EAAE,EACtB,WAAW,OAAO,aACyC,CAAC;AAE9D,eAAO,MAAM,uBAAuB,GAClC,iBAAiB,MAAM,EAAE,EACzB,cAAc,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAAE,EACvD,eAAe,kBAAkB,EACjC,qBAAqB,MAAM,EAAE,KAC5B,CAAC,MAAM,GAAG,IAAI,CAAC,EA8BjB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const toDomainLabel = (value) => {
|
|
2
|
+
if (value === null || value === undefined) {
|
|
3
|
+
return "";
|
|
4
|
+
}
|
|
5
|
+
return String(value);
|
|
6
|
+
};
|
|
7
|
+
const toNumericValue = (value) => {
|
|
8
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === "string") {
|
|
12
|
+
const parsed = Number(value);
|
|
13
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value === "boolean") {
|
|
16
|
+
return value ? 1 : 0;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
const uniqueDomains = (values) => {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const ordered = [];
|
|
23
|
+
for (const value of values) {
|
|
24
|
+
if (!seen.has(value)) {
|
|
25
|
+
seen.add(value);
|
|
26
|
+
ordered.push(value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return ordered;
|
|
30
|
+
};
|
|
31
|
+
const median = (values) => {
|
|
32
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
33
|
+
const mid = Math.floor(sorted.length / 2);
|
|
34
|
+
if (sorted.length % 2 === 0) {
|
|
35
|
+
return (sorted[mid - 1] + sorted[mid]) / 2;
|
|
36
|
+
}
|
|
37
|
+
return sorted[mid];
|
|
38
|
+
};
|
|
39
|
+
const aggregateValues = (values, aggregateType) => {
|
|
40
|
+
if (values.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
switch (aggregateType) {
|
|
44
|
+
case "SUM":
|
|
45
|
+
return values.reduce((total, value) => total + value, 0);
|
|
46
|
+
case "AVERAGE": {
|
|
47
|
+
const sum = values.reduce((total, value) => total + value, 0);
|
|
48
|
+
return sum / values.length;
|
|
49
|
+
}
|
|
50
|
+
case "COUNT":
|
|
51
|
+
return values.length;
|
|
52
|
+
case "MAX":
|
|
53
|
+
return Math.max(...values);
|
|
54
|
+
case "MIN":
|
|
55
|
+
return Math.min(...values);
|
|
56
|
+
case "MEDIAN":
|
|
57
|
+
return median(values);
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const sanitizeDomainValues = (values) => values.map(toDomainLabel);
|
|
63
|
+
export const shouldAggregateSeries = (series) => {
|
|
64
|
+
if (!series || series.length === 0) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return series.every((item) => !!item.aggregateType);
|
|
68
|
+
};
|
|
69
|
+
export const getDomainValuesForAxis = (domainValues, aggregate) => (aggregate ? uniqueDomains(domainValues) : domainValues);
|
|
70
|
+
export const aggregateSeriesByDomain = (rawDomainValues, seriesValues, aggregateType, orderedDomainValues) => {
|
|
71
|
+
const grouped = new Map();
|
|
72
|
+
for (const domain of orderedDomainValues) {
|
|
73
|
+
grouped.set(domain, []);
|
|
74
|
+
}
|
|
75
|
+
rawDomainValues.forEach((domainValue, index) => {
|
|
76
|
+
const currentGroup = grouped.get(domainValue);
|
|
77
|
+
if (!currentGroup) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (aggregateType === "COUNT") {
|
|
81
|
+
const source = seriesValues[index];
|
|
82
|
+
if (source !== undefined && source !== null && source !== "") {
|
|
83
|
+
currentGroup.push(1);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const numericValue = toNumericValue(seriesValues[index]);
|
|
88
|
+
if (numericValue !== undefined) {
|
|
89
|
+
currentGroup.push(numericValue);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return orderedDomainValues.map((domain) => {
|
|
93
|
+
const values = grouped.get(domain) ?? [];
|
|
94
|
+
return aggregateValues(values, aggregateType);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bar/column layout mapping — Excel `<c:overlap>` / `<c:gapWidth>` to
|
|
3
|
+
* echarts `barGap` / `barCategoryGap`.
|
|
4
|
+
*
|
|
5
|
+
* Excel semantics:
|
|
6
|
+
* - `overlap` (-100..100): how much adjacent bars *within* a category
|
|
7
|
+
* cluster overlap, as a percentage of one bar's width. 100 = bars
|
|
8
|
+
* fully stacked on the same X slot, 0 = side-by-side touching,
|
|
9
|
+
* -100 = a full bar-width gap between them.
|
|
10
|
+
* - `gapWidth` (0..500): the gap *between* category clusters, as a
|
|
11
|
+
* percentage of one bar's width. Excel default is 150.
|
|
12
|
+
*
|
|
13
|
+
* echarts semantics:
|
|
14
|
+
* - `barGap` ("<p>%"): gap between bars of different series in the same
|
|
15
|
+
* category, as a percentage of the bar width. Negative values overlap
|
|
16
|
+
* ("-100%" = fully overlapped).
|
|
17
|
+
* - `barCategoryGap` ("<p>%"): the gap reserved for each category slot,
|
|
18
|
+
* as a percentage of the *band width* (the whole category slot), i.e.
|
|
19
|
+
* `barWidth = (band - categoryGap) / (n + (n - 1) * barGapPercent)`.
|
|
20
|
+
*/
|
|
21
|
+
type MaybeNumber = number | null | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Map Excel series overlap (-100..100) to an echarts `barGap`
|
|
24
|
+
* percentage string.
|
|
25
|
+
*
|
|
26
|
+
* Both express the same quantity in bar-width units with opposite
|
|
27
|
+
* sign conventions (Excel measures overlap, echarts measures gap), so
|
|
28
|
+
* the mapping is a negation:
|
|
29
|
+
* overlap 100 → barGap "-100%" (fully overlapped)
|
|
30
|
+
* overlap 0 → barGap "0%" (touching)
|
|
31
|
+
* overlap -100 → barGap "100%" (one bar-width gap)
|
|
32
|
+
*
|
|
33
|
+
* Returns undefined when overlap is unset so echarts keeps its own
|
|
34
|
+
* default ("30%").
|
|
35
|
+
*/
|
|
36
|
+
export declare const overlapToBarGap: (overlap?: MaybeNumber) => string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Map Excel `gapWidth` (0..500, % of bar width) to an echarts
|
|
39
|
+
* `barCategoryGap` percentage string (% of the category band width).
|
|
40
|
+
*
|
|
41
|
+
* Derivation — measure the whole band in bar-width units:
|
|
42
|
+
* bars + in-cluster gaps: n - (n - 1) * overlap / 100
|
|
43
|
+
* category gap: gapWidth / 100
|
|
44
|
+
* so the gap's share of the band is
|
|
45
|
+
* gapWidth / (100 * n - (n - 1) * overlap + gapWidth)
|
|
46
|
+
* e.g. one series with the Excel default gapWidth=150 → 150/250 = "60%".
|
|
47
|
+
*
|
|
48
|
+
* `seriesCount` is the number of side-by-side bars per category (1 for
|
|
49
|
+
* stacked charts, where all series share one slot). Returns undefined
|
|
50
|
+
* when gapWidth is unset so echarts keeps its default ("20%").
|
|
51
|
+
*/
|
|
52
|
+
export declare const gapWidthToBarCategoryGap: (gapWidth?: MaybeNumber, options?: {
|
|
53
|
+
seriesCount?: number;
|
|
54
|
+
overlap?: MaybeNumber;
|
|
55
|
+
}) => string | undefined;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=bar-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-layout.d.ts","sourceRoot":"","sources":["../../../utils/bar-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,KAAK,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAQ7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,WAAW,KAAG,MAAM,GAAG,SAGhE,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,WAAW,EACtB,UAAS;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,KAC5D,MAAM,GAAG,SAWX,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bar/column layout mapping — Excel `<c:overlap>` / `<c:gapWidth>` to
|
|
3
|
+
* echarts `barGap` / `barCategoryGap`.
|
|
4
|
+
*
|
|
5
|
+
* Excel semantics:
|
|
6
|
+
* - `overlap` (-100..100): how much adjacent bars *within* a category
|
|
7
|
+
* cluster overlap, as a percentage of one bar's width. 100 = bars
|
|
8
|
+
* fully stacked on the same X slot, 0 = side-by-side touching,
|
|
9
|
+
* -100 = a full bar-width gap between them.
|
|
10
|
+
* - `gapWidth` (0..500): the gap *between* category clusters, as a
|
|
11
|
+
* percentage of one bar's width. Excel default is 150.
|
|
12
|
+
*
|
|
13
|
+
* echarts semantics:
|
|
14
|
+
* - `barGap` ("<p>%"): gap between bars of different series in the same
|
|
15
|
+
* category, as a percentage of the bar width. Negative values overlap
|
|
16
|
+
* ("-100%" = fully overlapped).
|
|
17
|
+
* - `barCategoryGap` ("<p>%"): the gap reserved for each category slot,
|
|
18
|
+
* as a percentage of the *band width* (the whole category slot), i.e.
|
|
19
|
+
* `barWidth = (band - categoryGap) / (n + (n - 1) * barGapPercent)`.
|
|
20
|
+
*/
|
|
21
|
+
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
22
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
23
|
+
/**
|
|
24
|
+
* Map Excel series overlap (-100..100) to an echarts `barGap`
|
|
25
|
+
* percentage string.
|
|
26
|
+
*
|
|
27
|
+
* Both express the same quantity in bar-width units with opposite
|
|
28
|
+
* sign conventions (Excel measures overlap, echarts measures gap), so
|
|
29
|
+
* the mapping is a negation:
|
|
30
|
+
* overlap 100 → barGap "-100%" (fully overlapped)
|
|
31
|
+
* overlap 0 → barGap "0%" (touching)
|
|
32
|
+
* overlap -100 → barGap "100%" (one bar-width gap)
|
|
33
|
+
*
|
|
34
|
+
* Returns undefined when overlap is unset so echarts keeps its own
|
|
35
|
+
* default ("30%").
|
|
36
|
+
*/
|
|
37
|
+
export const overlapToBarGap = (overlap) => {
|
|
38
|
+
if (!isFiniteNumber(overlap))
|
|
39
|
+
return undefined;
|
|
40
|
+
return `${-clamp(overlap, -100, 100)}%`;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Map Excel `gapWidth` (0..500, % of bar width) to an echarts
|
|
44
|
+
* `barCategoryGap` percentage string (% of the category band width).
|
|
45
|
+
*
|
|
46
|
+
* Derivation — measure the whole band in bar-width units:
|
|
47
|
+
* bars + in-cluster gaps: n - (n - 1) * overlap / 100
|
|
48
|
+
* category gap: gapWidth / 100
|
|
49
|
+
* so the gap's share of the band is
|
|
50
|
+
* gapWidth / (100 * n - (n - 1) * overlap + gapWidth)
|
|
51
|
+
* e.g. one series with the Excel default gapWidth=150 → 150/250 = "60%".
|
|
52
|
+
*
|
|
53
|
+
* `seriesCount` is the number of side-by-side bars per category (1 for
|
|
54
|
+
* stacked charts, where all series share one slot). Returns undefined
|
|
55
|
+
* when gapWidth is unset so echarts keeps its default ("20%").
|
|
56
|
+
*/
|
|
57
|
+
export const gapWidthToBarCategoryGap = (gapWidth, options = {}) => {
|
|
58
|
+
if (!isFiniteNumber(gapWidth))
|
|
59
|
+
return undefined;
|
|
60
|
+
const gap = clamp(gapWidth, 0, 500);
|
|
61
|
+
const seriesCount = Math.max(1, Math.floor(options.seriesCount ?? 1));
|
|
62
|
+
const overlap = isFiniteNumber(options.overlap)
|
|
63
|
+
? clamp(options.overlap, -100, 100)
|
|
64
|
+
: 0;
|
|
65
|
+
const band = 100 * seriesCount - (seriesCount - 1) * overlap + gap;
|
|
66
|
+
if (band <= 0)
|
|
67
|
+
return undefined;
|
|
68
|
+
const percent = (100 * gap) / band;
|
|
69
|
+
return `${Math.round(percent * 100) / 100}%`;
|
|
70
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box-and-whisker statistics shared by chart renderers.
|
|
3
|
+
*
|
|
4
|
+
* Plotly's box trace computes quartiles itself from raw values.
|
|
5
|
+
* Echarts' boxplot series requires pre-computed [min, Q1, median, Q3, max]
|
|
6
|
+
* tuples per box; this helper produces that shape.
|
|
7
|
+
*/
|
|
8
|
+
export type BoxplotStats = [number, number, number, number, number];
|
|
9
|
+
/**
|
|
10
|
+
* Quartile computation method, mirroring Excel's box & whisker
|
|
11
|
+
* "quartile calculation" option:
|
|
12
|
+
* - "inclusive" — QUARTILE.INC: linear interpolation over positions
|
|
13
|
+
* `(n - 1) * q` (median included in both halves).
|
|
14
|
+
* - "exclusive" — QUARTILE.EXC: linear interpolation over positions
|
|
15
|
+
* `(n + 1) * q` (median excluded), Tukey-style hinges.
|
|
16
|
+
*/
|
|
17
|
+
export type QuartileMethod = "inclusive" | "exclusive";
|
|
18
|
+
/**
|
|
19
|
+
* QUARTILE.INC — linear interpolation at position `(n - 1) * q`
|
|
20
|
+
* (0-indexed). Identical to the interpolation echarts' built-in
|
|
21
|
+
* boxplot transform uses.
|
|
22
|
+
*/
|
|
23
|
+
export declare const quartileInc: (sorted: number[], q: number) => number;
|
|
24
|
+
/**
|
|
25
|
+
* QUARTILE.EXC — linear interpolation at 1-indexed position
|
|
26
|
+
* `(n + 1) * q`. Excel returns #NUM! when the position falls outside
|
|
27
|
+
* `[1, n]` (tiny samples); for charting we clamp to the nearest order
|
|
28
|
+
* statistic instead so every box still renders.
|
|
29
|
+
*/
|
|
30
|
+
export declare const quartileExc: (sorted: number[], q: number) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Full box-and-whisker summary. Quartiles follow the requested method
|
|
33
|
+
* ("inclusive" when omitted — the same interpolation
|
|
34
|
+
* `computeBoxplotStats` has always used). Outliers are points beyond
|
|
35
|
+
* the Tukey fences `Q1 - 1.5×IQR` / `Q3 + 1.5×IQR`; the whisker ends
|
|
36
|
+
* are the most extreme data points still inside the fences (Excel's
|
|
37
|
+
* behavior when "show outlier points" is on).
|
|
38
|
+
*/
|
|
39
|
+
export type BoxplotSummary = {
|
|
40
|
+
min: number;
|
|
41
|
+
q1: number;
|
|
42
|
+
median: number;
|
|
43
|
+
q3: number;
|
|
44
|
+
max: number;
|
|
45
|
+
mean: number;
|
|
46
|
+
/** Smallest data point >= Q1 - 1.5×IQR. */
|
|
47
|
+
lowerWhisker: number;
|
|
48
|
+
/** Largest data point <= Q3 + 1.5×IQR. */
|
|
49
|
+
upperWhisker: number;
|
|
50
|
+
/** Data points outside the 1.5×IQR fences, ascending. */
|
|
51
|
+
outliers: number[];
|
|
52
|
+
};
|
|
53
|
+
export declare const computeBoxplotSummary: (values: (number | null | undefined)[], options?: {
|
|
54
|
+
quartileMethod?: QuartileMethod | null;
|
|
55
|
+
}) => BoxplotSummary | null;
|
|
56
|
+
/**
|
|
57
|
+
* Compute [min, Q1, median, Q3, max] using linear interpolation between
|
|
58
|
+
* order statistics — matches echarts' built-in `dataset.transform: 'boxplot'`
|
|
59
|
+
* behavior.
|
|
60
|
+
*/
|
|
61
|
+
export declare const computeBoxplotStats: (values: (number | null | undefined)[]) => BoxplotStats | null;
|
|
62
|
+
//# sourceMappingURL=boxplot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxplot.d.ts","sourceRoot":"","sources":["../../../utils/boxplot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpE;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,WAAW,CAAC;AAUvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,EAAE,GAAG,MAAM,KAAG,MACrC,CAAC;AAEtB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,EAAE,GAAG,MAAM,KAAG,MAQzD,CAAC;AAeF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACrC,UAAU;IAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,KACnD,cAAc,GAAG,IA0BnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KACpC,YAAY,GAAG,IAejB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box-and-whisker statistics shared by chart renderers.
|
|
3
|
+
*
|
|
4
|
+
* Plotly's box trace computes quartiles itself from raw values.
|
|
5
|
+
* Echarts' boxplot series requires pre-computed [min, Q1, median, Q3, max]
|
|
6
|
+
* tuples per box; this helper produces that shape.
|
|
7
|
+
*/
|
|
8
|
+
const quantile = (sorted, q) => {
|
|
9
|
+
const idx = (sorted.length - 1) * q;
|
|
10
|
+
const lo = Math.floor(idx);
|
|
11
|
+
const hi = Math.ceil(idx);
|
|
12
|
+
if (lo === hi)
|
|
13
|
+
return sorted[lo];
|
|
14
|
+
return sorted[lo] + (sorted[hi] - sorted[lo]) * (idx - lo);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* QUARTILE.INC — linear interpolation at position `(n - 1) * q`
|
|
18
|
+
* (0-indexed). Identical to the interpolation echarts' built-in
|
|
19
|
+
* boxplot transform uses.
|
|
20
|
+
*/
|
|
21
|
+
export const quartileInc = (sorted, q) => quantile(sorted, q);
|
|
22
|
+
/**
|
|
23
|
+
* QUARTILE.EXC — linear interpolation at 1-indexed position
|
|
24
|
+
* `(n + 1) * q`. Excel returns #NUM! when the position falls outside
|
|
25
|
+
* `[1, n]` (tiny samples); for charting we clamp to the nearest order
|
|
26
|
+
* statistic instead so every box still renders.
|
|
27
|
+
*/
|
|
28
|
+
export const quartileExc = (sorted, q) => {
|
|
29
|
+
const n = sorted.length;
|
|
30
|
+
const pos = (n + 1) * q; // 1-indexed
|
|
31
|
+
if (pos <= 1)
|
|
32
|
+
return sorted[0];
|
|
33
|
+
if (pos >= n)
|
|
34
|
+
return sorted[n - 1];
|
|
35
|
+
const lo = Math.floor(pos);
|
|
36
|
+
const frac = pos - lo;
|
|
37
|
+
return sorted[lo - 1] + (sorted[lo] - sorted[lo - 1]) * frac;
|
|
38
|
+
};
|
|
39
|
+
const quartile = (sorted, q, method) => method === "exclusive" ? quartileExc(sorted, q) : quartileInc(sorted, q);
|
|
40
|
+
const toSortedNumeric = (values) => values
|
|
41
|
+
.filter((v) => typeof v === "number" && Number.isFinite(v))
|
|
42
|
+
.slice()
|
|
43
|
+
.sort((a, b) => a - b);
|
|
44
|
+
export const computeBoxplotSummary = (values, options) => {
|
|
45
|
+
const numeric = toSortedNumeric(values);
|
|
46
|
+
if (numeric.length === 0)
|
|
47
|
+
return null;
|
|
48
|
+
const method = options?.quartileMethod ?? "inclusive";
|
|
49
|
+
const q1 = quartile(numeric, 0.25, method);
|
|
50
|
+
const median = quartile(numeric, 0.5, method);
|
|
51
|
+
const q3 = quartile(numeric, 0.75, method);
|
|
52
|
+
const iqr = q3 - q1;
|
|
53
|
+
const lowerFence = q1 - 1.5 * iqr;
|
|
54
|
+
const upperFence = q3 + 1.5 * iqr;
|
|
55
|
+
const inliers = numeric.filter((v) => v >= lowerFence && v <= upperFence);
|
|
56
|
+
const outliers = numeric.filter((v) => v < lowerFence || v > upperFence);
|
|
57
|
+
const mean = numeric.reduce((sum, v) => sum + v, 0) / numeric.length;
|
|
58
|
+
return {
|
|
59
|
+
min: numeric[0],
|
|
60
|
+
q1,
|
|
61
|
+
median,
|
|
62
|
+
q3,
|
|
63
|
+
max: numeric[numeric.length - 1],
|
|
64
|
+
mean,
|
|
65
|
+
// Degenerate fences (all points outliers) can't happen — Q1/Q3 are
|
|
66
|
+
// always inside [min, max] — so inliers is never empty.
|
|
67
|
+
lowerWhisker: inliers[0],
|
|
68
|
+
upperWhisker: inliers[inliers.length - 1],
|
|
69
|
+
outliers,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Compute [min, Q1, median, Q3, max] using linear interpolation between
|
|
74
|
+
* order statistics — matches echarts' built-in `dataset.transform: 'boxplot'`
|
|
75
|
+
* behavior.
|
|
76
|
+
*/
|
|
77
|
+
export const computeBoxplotStats = (values) => {
|
|
78
|
+
const numeric = values
|
|
79
|
+
.filter((v) => typeof v === "number" && Number.isFinite(v))
|
|
80
|
+
.slice()
|
|
81
|
+
.sort((a, b) => a - b);
|
|
82
|
+
if (numeric.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
return [
|
|
85
|
+
numeric[0],
|
|
86
|
+
quantile(numeric, 0.25),
|
|
87
|
+
quantile(numeric, 0.5),
|
|
88
|
+
quantile(numeric, 0.75),
|
|
89
|
+
numeric[numeric.length - 1],
|
|
90
|
+
];
|
|
91
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const toLabelString: (value: unknown) => string;
|
|
2
|
+
export declare const toNumericValue: (value: unknown) => number | null;
|
|
3
|
+
export declare const createBubbleSizeScale: (values: number[]) => (value: number) => number;
|
|
4
|
+
export type BubbleSeriesInput = {
|
|
5
|
+
name?: string | null;
|
|
6
|
+
values: (string | number | boolean | null | undefined)[];
|
|
7
|
+
/**
|
|
8
|
+
* Per-series X values. Excel's scatter charts always carry per-series
|
|
9
|
+
* `xVal` (each series has its own x/y pair). Excel's bubble charts
|
|
10
|
+
* typically share an X axis but the OOXML format allows per-series.
|
|
11
|
+
* When omitted, the shared `xValues` arg on `PrepareBubbleSeriesArgs`
|
|
12
|
+
* is used — preserves the old shared-X behaviour for fixtures that
|
|
13
|
+
* pass a single domain.
|
|
14
|
+
*/
|
|
15
|
+
xValues?: (string | number | boolean | null | undefined)[];
|
|
16
|
+
/**
|
|
17
|
+
* Per-series bubble sizes. Bubble charts may carry one `bubbleSize`
|
|
18
|
+
* per series; falls back to the shared `sizeValues` when omitted.
|
|
19
|
+
*/
|
|
20
|
+
sizeValues?: (string | number | boolean | null | undefined)[];
|
|
21
|
+
};
|
|
22
|
+
export type BubbleSeriesPoint = {
|
|
23
|
+
value: [number, number, number];
|
|
24
|
+
name: string;
|
|
25
|
+
xLabel?: string;
|
|
26
|
+
};
|
|
27
|
+
export type PreparedBubbleSeries = {
|
|
28
|
+
name: string;
|
|
29
|
+
points: BubbleSeriesPoint[];
|
|
30
|
+
};
|
|
31
|
+
export type PrepareBubbleSeriesArgs = {
|
|
32
|
+
/**
|
|
33
|
+
* Shared X values across all series. Used as the fallback when a
|
|
34
|
+
* series doesn't carry its own `xValues`. For pure-scatter charts
|
|
35
|
+
* (per-series xVal) this is typically `[]` and each series provides
|
|
36
|
+
* its own.
|
|
37
|
+
*/
|
|
38
|
+
xValues: (string | number | boolean | null | undefined)[];
|
|
39
|
+
labelValues: (string | number | boolean | null | undefined)[];
|
|
40
|
+
/**
|
|
41
|
+
* Shared size values. Same fallback semantics as `xValues`.
|
|
42
|
+
*/
|
|
43
|
+
sizeValues: (string | number | boolean | null | undefined)[];
|
|
44
|
+
series: BubbleSeriesInput[];
|
|
45
|
+
};
|
|
46
|
+
export type BubbleSeriesResult = {
|
|
47
|
+
categories: string[];
|
|
48
|
+
series: PreparedBubbleSeries[];
|
|
49
|
+
sizeValues: number[];
|
|
50
|
+
};
|
|
51
|
+
export declare const prepareBubbleSeriesData: ({ xValues, labelValues, sizeValues, series, }: PrepareBubbleSeriesArgs) => BubbleSeriesResult;
|
|
52
|
+
//# sourceMappingURL=bubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../../../utils/bubble.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MACU,CAAC;AAE1D,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,IAYxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,aAQrC,MAAM,WAOtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IACzD;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC3D;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1D,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9D;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC7D,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAwCF,eAAO,MAAM,uBAAuB,GAAI,+CAKrC,uBAAuB,KAAG,kBAsF5B,CAAC"}
|