@rowsncolumns/charts 28.1.18 → 28.1.19
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/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/cjs/basic-chart/basic-chart.js +338 -233
- package/dist/cjs/basic-chart/helpers.d.ts +7 -3
- package/dist/cjs/basic-chart/helpers.d.ts.map +1 -1
- package/dist/cjs/basic-chart/helpers.js +30 -4
- package/dist/cjs/basic-chart/index.d.ts +7 -0
- package/dist/cjs/basic-chart/index.d.ts.map +1 -1
- package/dist/cjs/basic-chart/index.js +19 -2
- package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/chart-editor.js +21 -12
- package/dist/cjs/components/editors/fields/axis-options-fields.d.ts +6 -3
- package/dist/cjs/components/editors/fields/axis-options-fields.d.ts.map +1 -1
- package/dist/cjs/components/editors/fields/axis-options-fields.js +69 -7
- package/dist/cjs/components/editors/fields/chart-elements-fields.d.ts +15 -0
- package/dist/cjs/components/editors/fields/chart-elements-fields.d.ts.map +1 -0
- package/dist/cjs/components/editors/fields/chart-elements-fields.js +23 -0
- package/dist/cjs/components/editors/fields/series-format-fields.d.ts.map +1 -1
- package/dist/cjs/components/editors/fields/series-format-fields.js +16 -2
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils/chart-lines.d.ts +36 -0
- package/dist/cjs/utils/chart-lines.d.ts.map +1 -0
- package/dist/cjs/utils/chart-lines.js +111 -0
- package/dist/cjs/utils/data-table.d.ts +31 -0
- package/dist/cjs/utils/data-table.d.ts.map +1 -0
- package/dist/cjs/utils/data-table.js +61 -0
- package/dist/cjs/utils/excel-axis-scale.d.ts +35 -0
- package/dist/cjs/utils/excel-axis-scale.d.ts.map +1 -0
- package/dist/cjs/utils/excel-axis-scale.js +210 -0
- package/dist/cjs/utils/overrides.d.ts +24 -3
- package/dist/cjs/utils/overrides.d.ts.map +1 -1
- package/dist/cjs/utils/overrides.js +119 -14
- package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/esm/basic-chart/basic-chart.js +177 -38
- package/dist/esm/basic-chart/helpers.d.ts +7 -3
- package/dist/esm/basic-chart/helpers.d.ts.map +1 -1
- package/dist/esm/basic-chart/helpers.js +26 -3
- package/dist/esm/basic-chart/index.d.ts +7 -0
- package/dist/esm/basic-chart/index.d.ts.map +1 -1
- package/dist/esm/basic-chart/index.js +15 -1
- package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/chart-editor.js +12 -1
- package/dist/esm/components/editors/fields/axis-options-fields.d.ts +6 -3
- package/dist/esm/components/editors/fields/axis-options-fields.d.ts.map +1 -1
- package/dist/esm/components/editors/fields/axis-options-fields.js +56 -5
- package/dist/esm/components/editors/fields/chart-elements-fields.d.ts +15 -0
- package/dist/esm/components/editors/fields/chart-elements-fields.d.ts.map +1 -0
- package/dist/esm/components/editors/fields/chart-elements-fields.js +17 -0
- package/dist/esm/components/editors/fields/series-format-fields.d.ts.map +1 -1
- package/dist/esm/components/editors/fields/series-format-fields.js +9 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/chart-lines.d.ts +36 -0
- package/dist/esm/utils/chart-lines.d.ts.map +1 -0
- package/dist/esm/utils/chart-lines.js +121 -0
- package/dist/esm/utils/data-table.d.ts +31 -0
- package/dist/esm/utils/data-table.d.ts.map +1 -0
- package/dist/esm/utils/data-table.js +48 -0
- package/dist/esm/utils/excel-axis-scale.d.ts +35 -0
- package/dist/esm/utils/excel-axis-scale.d.ts.map +1 -0
- package/dist/esm/utils/excel-axis-scale.js +122 -0
- package/dist/esm/utils/overrides.d.ts +24 -3
- package/dist/esm/utils/overrides.d.ts.map +1 -1
- package/dist/esm/utils/overrides.js +111 -10
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axis-options-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/axis-options-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"axis-options-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/axis-options-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAgC1B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,qDAM/B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,sBAkNA,CAAC"}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CheckboxField, NumberField, TextField } from "./primitives";
|
|
2
|
+
import { CheckboxField, NumberField, SelectField, TextField, } from "./primitives";
|
|
3
3
|
import { TextFormatFields } from "./text-format-fields";
|
|
4
|
+
const TICK_MARKS = [
|
|
5
|
+
{ value: "none", label: "None" },
|
|
6
|
+
{ value: "in", label: "Inside" },
|
|
7
|
+
{ value: "out", label: "Outside" },
|
|
8
|
+
{ value: "cross", label: "Cross" },
|
|
9
|
+
];
|
|
10
|
+
const DISPLAY_UNIT_OPTIONS = [
|
|
11
|
+
{ value: "", label: "None" },
|
|
12
|
+
{ value: "hundreds", label: "Hundreds" },
|
|
13
|
+
{ value: "thousands", label: "Thousands" },
|
|
14
|
+
{ value: "tenThousands", label: "10000" },
|
|
15
|
+
{ value: "hundredThousands", label: "100000" },
|
|
16
|
+
{ value: "millions", label: "Millions" },
|
|
17
|
+
{ value: "tenMillions", label: "10000000" },
|
|
18
|
+
{ value: "hundredMillions", label: "100000000" },
|
|
19
|
+
{ value: "billions", label: "Billions" },
|
|
20
|
+
{ value: "trillions", label: "Trillions" },
|
|
21
|
+
];
|
|
4
22
|
/**
|
|
5
|
-
* One axis' options (`ChartAxisOptions`)
|
|
6
|
-
* (
|
|
7
|
-
* and
|
|
23
|
+
* One axis' options (`ChartAxisOptions`) — Excel's Format Axis pane
|
|
24
|
+
* (demo-app-monorepo#49969 FT-08): a value axis has its bounds, log scale
|
|
25
|
+
* and base, major / minor units, display units and number format; a
|
|
26
|
+
* category axis its label / tick-mark intervals; both have where the other
|
|
27
|
+
* axis crosses, direction, major / minor gridlines, tick marks, visibility
|
|
28
|
+
* and tick-label font.
|
|
8
29
|
*/
|
|
9
30
|
export const AxisOptionsFields = ({ label, kind, value, onChange, gridlinesDefault = true, }) => {
|
|
10
31
|
const set = (patch) => onChange({ ...(value ?? {}), ...patch });
|
|
@@ -13,9 +34,39 @@ export const AxisOptionsFields = ({ label, kind, value, onChange, gridlinesDefau
|
|
|
13
34
|
kind === "value" ? (React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
14
35
|
React.createElement(NumberField, { label: "Min", ariaLabel: `${label} min`, value: value?.min, onChange: (min) => set({ min }), placeholder: "Auto" }),
|
|
15
36
|
React.createElement(NumberField, { label: "Max", ariaLabel: `${label} max`, value: value?.max, onChange: (max) => set({ max }), placeholder: "Auto" }))) : null,
|
|
16
|
-
kind === "value" ? (React.createElement(
|
|
37
|
+
kind === "value" ? (React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
38
|
+
React.createElement(NumberField, { label: "Major unit", ariaLabel: `${label} major unit`, value: value?.majorUnit, min: 0, onChange: (majorUnit) => set({ majorUnit }), placeholder: "Auto" }),
|
|
39
|
+
React.createElement(NumberField, { label: "Minor unit", ariaLabel: `${label} minor unit`, value: value?.minorUnit, min: 0, onChange: (minorUnit) => set({ minorUnit }), placeholder: "Auto" }))) : (React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
40
|
+
React.createElement(NumberField, { label: "Label interval", ariaLabel: `${label} interval between labels`, value: value?.tickLabelSkip, min: 1, step: 1, onChange: (tickLabelSkip) => set({ tickLabelSkip }), placeholder: "Auto" }),
|
|
41
|
+
React.createElement(NumberField, { label: "Tick interval", ariaLabel: `${label} interval between tick marks`, value: value?.tickMarkSkip, min: 1, step: 1, onChange: (tickMarkSkip) => set({ tickMarkSkip }), placeholder: "1" }))),
|
|
42
|
+
kind === "value" ? (React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
43
|
+
React.createElement(CheckboxField, { label: "Logarithmic scale", ariaLabel: `${label} logarithmic scale`, checked: Boolean(value?.logarithmic), onChange: (on) => set({ logarithmic: on || undefined }) }),
|
|
44
|
+
value?.logarithmic ? (React.createElement(NumberField, { label: "Base", ariaLabel: `${label} logarithmic base`, value: value?.logBase, min: 2, max: 1000, onChange: (logBase) => set({ logBase }), placeholder: "10" })) : null)) : null,
|
|
45
|
+
kind === "value" ? (React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
46
|
+
React.createElement(SelectField, { label: "Display units", ariaLabel: `${label} display units`, value: (value?.displayUnits ?? ""), options: DISPLAY_UNIT_OPTIONS, onChange: (unit) => set({ displayUnits: unit === "" ? undefined : unit }) }),
|
|
47
|
+
value?.displayUnits ? (React.createElement(CheckboxField, { label: "Show display units label", ariaLabel: `${label} show display units label`, checked: value?.showDisplayUnitsLabel !== false, onChange: (on) => set({ showDisplayUnitsLabel: on ? undefined : false }) })) : null)) : null,
|
|
48
|
+
React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
49
|
+
React.createElement(SelectField, { label: "Crosses other axis", ariaLabel: `${label} crosses`, value: typeof value?.crossesAt === "number"
|
|
50
|
+
? "value"
|
|
51
|
+
: value?.crosses === "max"
|
|
52
|
+
? "max"
|
|
53
|
+
: "autoZero", options: [
|
|
54
|
+
{ value: "autoZero", label: "Automatic" },
|
|
55
|
+
{ value: "value", label: "At value" },
|
|
56
|
+
{ value: "max", label: "At maximum" },
|
|
57
|
+
], onChange: (crossing) => set(crossing === "value"
|
|
58
|
+
? { crosses: undefined, crossesAt: value?.crossesAt ?? 0 }
|
|
59
|
+
: {
|
|
60
|
+
crosses: crossing === "max" ? "max" : undefined,
|
|
61
|
+
crossesAt: undefined,
|
|
62
|
+
}) }),
|
|
63
|
+
typeof value?.crossesAt === "number" ? (React.createElement(NumberField, { label: "At", ariaLabel: `${label} crosses at`, value: value.crossesAt, onChange: (crossesAt) => set({ crossesAt: crossesAt ?? 0 }) })) : null),
|
|
17
64
|
React.createElement(CheckboxField, { label: "Reverse direction", ariaLabel: `${label} reverse direction`, checked: Boolean(value?.reverse), onChange: (on) => set({ reverse: on || undefined }) }),
|
|
18
65
|
React.createElement(CheckboxField, { label: "Gridlines", ariaLabel: `${label} gridlines`, checked: value?.showMajorGridlines ?? gridlinesDefault, onChange: (showMajorGridlines) => set({ showMajorGridlines }) }),
|
|
66
|
+
kind === "value" ? (React.createElement(CheckboxField, { label: "Minor gridlines", ariaLabel: `${label} minor gridlines`, checked: Boolean(value?.showMinorGridlines), onChange: (on) => set({ showMinorGridlines: on || undefined }) })) : null,
|
|
67
|
+
React.createElement("div", { className: "flex flex-wrap gap-2 items-end" },
|
|
68
|
+
React.createElement(SelectField, { label: "Major tick marks", ariaLabel: `${label} major tick marks`, value: value?.majorTickMark ?? "out", options: TICK_MARKS, onChange: (mark) => set({ majorTickMark: mark === "out" ? undefined : mark }) }),
|
|
69
|
+
React.createElement(SelectField, { label: "Minor tick marks", ariaLabel: `${label} minor tick marks`, value: value?.minorTickMark ?? "none", options: TICK_MARKS, onChange: (mark) => set({ minorTickMark: mark === "none" ? undefined : mark }) })),
|
|
19
70
|
React.createElement(CheckboxField, { label: "Show axis", ariaLabel: `${label} visible`, checked: value?.visible !== false, onChange: (on) => set({ visible: on ? undefined : false }) }),
|
|
20
71
|
kind === "value" ? (React.createElement(TextField, { label: "Number format", ariaLabel: `${label} number format`, value: value?.numberFormatPattern, onChange: (numberFormatPattern) => set({ numberFormatPattern }), placeholder: "Linked to source" })) : null,
|
|
21
72
|
React.createElement(TextFormatFields, { label: `${label} font`, collapsible: true, value: value?.textFormat, onChange: (textFormat) => set({ textFormat }) })));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type ElementKey = "hiLowLines" | "dropLines" | "upDownBars" | "dataTable";
|
|
3
|
+
/**
|
|
4
|
+
* Excel's Add Chart Element → Lines (High-Low, Drop), Up/Down Bars and Data
|
|
5
|
+
* Table (demo-app-monorepo#49969 FT-08). High-low lines and up/down bars are
|
|
6
|
+
* line-chart elements, drop lines line and area; every category chart can
|
|
7
|
+
* carry a data table.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ChartElementsFields: ({ chartType, spec, onChange, }: {
|
|
10
|
+
chartType: string;
|
|
11
|
+
spec: Partial<Record<ElementKey, any>>;
|
|
12
|
+
onChange(key: ElementKey | "dataTable.showLegendKeys", value: unknown): void;
|
|
13
|
+
}) => React.JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=chart-elements-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-elements-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/chart-elements-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,gCAIjC;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,0BAA0B,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9E,sBAuCA,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CheckboxField } from "./primitives";
|
|
3
|
+
/**
|
|
4
|
+
* Excel's Add Chart Element → Lines (High-Low, Drop), Up/Down Bars and Data
|
|
5
|
+
* Table (demo-app-monorepo#49969 FT-08). High-low lines and up/down bars are
|
|
6
|
+
* line-chart elements, drop lines line and area; every category chart can
|
|
7
|
+
* carry a data table.
|
|
8
|
+
*/
|
|
9
|
+
export const ChartElementsFields = ({ chartType, spec, onChange, }) => {
|
|
10
|
+
const isLine = chartType === "line";
|
|
11
|
+
return (React.createElement("div", { className: "flex flex-col gap-1 pb-2" },
|
|
12
|
+
isLine ? (React.createElement(CheckboxField, { label: "High-low lines", checked: Boolean(spec.hiLowLines), onChange: (on) => onChange("hiLowLines", on || undefined) })) : null,
|
|
13
|
+
isLine || chartType === "area" ? (React.createElement(CheckboxField, { label: "Drop lines", checked: Boolean(spec.dropLines), onChange: (on) => onChange("dropLines", on || undefined) })) : null,
|
|
14
|
+
isLine ? (React.createElement(CheckboxField, { label: "Up/down bars", checked: Boolean(spec.upDownBars), onChange: (on) => onChange("upDownBars", on ? {} : undefined) })) : null,
|
|
15
|
+
React.createElement(CheckboxField, { label: "Data table", checked: Boolean(spec.dataTable), onChange: (on) => onChange("dataTable", on ? {} : undefined) }),
|
|
16
|
+
spec.dataTable ? (React.createElement(CheckboxField, { label: "Show legend keys", checked: spec.dataTable.showLegendKeys !== false, onChange: (on) => onChange("dataTable.showLegendKeys", on ? undefined : false) })) : null));
|
|
17
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"series-format-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/series-format-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAqC5E;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,8CAKhC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,uBAAuB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;CAC3C,
|
|
1
|
+
{"version":3,"file":"series-format-fields.d.ts","sourceRoot":"","sources":["../../../../../components/editors/fields/series-format-fields.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAqC5E;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,8CAKhC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,uBAAuB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;CAC3C,sBAkZA,CAAC"}
|
|
@@ -139,5 +139,13 @@ export const SeriesFormatFields = ({ sheetId, series, capabilities, onChange, })
|
|
|
139
139
|
},
|
|
140
140
|
],
|
|
141
141
|
}) }, "Add point color")))) : null,
|
|
142
|
-
capabilities.hasDataLabels ? (React.createElement(DataLabelsFields, { perSeries: true, value: series.dataLabels, capabilities: capabilities, onChange: (dataLabels) => onChange({ dataLabels }) })) : null
|
|
142
|
+
capabilities.hasDataLabels ? (React.createElement(DataLabelsFields, { perSeries: true, value: series.dataLabels, capabilities: capabilities, onChange: (dataLabels) => onChange({ dataLabels }) })) : null,
|
|
143
|
+
capabilities.hasDataLabels ? (React.createElement("div", { className: "flex flex-col gap-1" },
|
|
144
|
+
React.createElement("label", { className: "font-system text-xs" }, "Label values from cells"),
|
|
145
|
+
React.createElement(ChartRangeInput, { sheetId: sheetId, range: series.dataLabels?.valueFromCells ?? undefined, onChangeRange: (valueFromCells) => onChange({
|
|
146
|
+
dataLabels: { ...(series.dataLabels ?? {}), show: true, valueFromCells },
|
|
147
|
+
}), placeholder: "Select a label range", className: "mb-0" }),
|
|
148
|
+
series.dataLabels?.valueFromCells ? (React.createElement("button", { type: "button", className: "font-system text-xs text-rnc-muted-foreground underline self-start", onClick: () => onChange({
|
|
149
|
+
dataLabels: { ...(series.dataLabels ?? {}), valueFromCells: undefined },
|
|
150
|
+
}) }, "Clear label range")) : null)) : null));
|
|
143
151
|
};
|
|
@@ -1 +1 @@
|
|
|
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-capabilities.ts","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../components/editors/fields/axis-options-fields.tsx","../../components/editors/fields/chart-type-options.tsx","../../components/editors/fields/data-labels-fields.tsx","../../components/editors/fields/primitives.tsx","../../components/editors/fields/series-format-fields.tsx","../../components/editors/fields/series-name-field.tsx","../../components/editors/fields/text-format-fields.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/plot.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/doughnut.ts","../../utils/echarts-gl-loader.ts","../../utils/echarts-overlays.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/legend-layout.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/series-name.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-capabilities.ts","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../components/editors/fields/axis-options-fields.tsx","../../components/editors/fields/chart-elements-fields.tsx","../../components/editors/fields/chart-type-options.tsx","../../components/editors/fields/data-labels-fields.tsx","../../components/editors/fields/primitives.tsx","../../components/editors/fields/series-format-fields.tsx","../../components/editors/fields/series-name-field.tsx","../../components/editors/fields/text-format-fields.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/plot.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-lines.ts","../../utils/chart-orientation.ts","../../utils/chart-spec-utils.ts","../../utils/chart-styles.ts","../../utils/data-table.ts","../../utils/doughnut.ts","../../utils/echarts-gl-loader.ts","../../utils/echarts-overlays.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/excel-axis-scale.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/legend-layout.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/series-name.ts","../../utils/stock.ts","../../utils/three-d.ts","../../utils/trendline.ts","../../utils/waterfall.ts","../../utils/webgl.ts"],"version":"5.8.3"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's line-chart analysis elements (Chart Design → Add Chart Element →
|
|
3
|
+
* Lines / Up/Down Bars, demo-app-monorepo#49969 FT-08) as echarts bar series
|
|
4
|
+
* over the category axis:
|
|
5
|
+
*
|
|
6
|
+
* - High-low lines — a thin vertical line per category from the lowest to the
|
|
7
|
+
* highest value of all the line series (`<c:hiLowLines/>`).
|
|
8
|
+
* - Up/down bars — a bar per category from the first line series' value to
|
|
9
|
+
* the last one's: an up bar (white) where the last is higher, a down bar
|
|
10
|
+
* (dark) where it is lower (`<c:upDownBars>`).
|
|
11
|
+
* - Drop lines — a thin vertical line per category from the axis to the
|
|
12
|
+
* highest point (`<c:dropLines/>`).
|
|
13
|
+
*
|
|
14
|
+
* Each is a stack of an invisible base plus a visible span, so the bars can
|
|
15
|
+
* start anywhere on the value axis; `barGap: "-100%"` lays every one of them
|
|
16
|
+
* over the category's centre instead of side by side.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CHART_LINE_SERIES_PREFIX = "rnc-chart-lines-";
|
|
19
|
+
export type ChartLineOptions = {
|
|
20
|
+
hiLowLines?: boolean | null;
|
|
21
|
+
dropLines?: boolean | null;
|
|
22
|
+
upDownBars?: {
|
|
23
|
+
gapWidth?: number | null;
|
|
24
|
+
upColor?: string | null;
|
|
25
|
+
downColor?: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The extra series for `options`, given the data of the chart's line series
|
|
30
|
+
* on one value axis, in spec order.
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildChartLineSeries: (options: ChartLineOptions, lines: ReadonlyArray<ReadonlyArray<unknown>>, { isDarkMode, yAxisIndex }?: {
|
|
33
|
+
isDarkMode?: boolean;
|
|
34
|
+
yAxisIndex?: number;
|
|
35
|
+
}) => Record<string, unknown>[];
|
|
36
|
+
//# sourceMappingURL=chart-lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-lines.d.ts","sourceRoot":"","sources":["../../../utils/chart-lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE;QACX,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,GAAG,IAAI,CAAC;CACV,CAAC;AAqDF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,gBAAgB,EACzB,OAAO,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EAC5C,6BAA4B;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,KAC7E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAuEzB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's line-chart analysis elements (Chart Design → Add Chart Element →
|
|
3
|
+
* Lines / Up/Down Bars, demo-app-monorepo#49969 FT-08) as echarts bar series
|
|
4
|
+
* over the category axis:
|
|
5
|
+
*
|
|
6
|
+
* - High-low lines — a thin vertical line per category from the lowest to the
|
|
7
|
+
* highest value of all the line series (`<c:hiLowLines/>`).
|
|
8
|
+
* - Up/down bars — a bar per category from the first line series' value to
|
|
9
|
+
* the last one's: an up bar (white) where the last is higher, a down bar
|
|
10
|
+
* (dark) where it is lower (`<c:upDownBars>`).
|
|
11
|
+
* - Drop lines — a thin vertical line per category from the axis to the
|
|
12
|
+
* highest point (`<c:dropLines/>`).
|
|
13
|
+
*
|
|
14
|
+
* Each is a stack of an invisible base plus a visible span, so the bars can
|
|
15
|
+
* start anywhere on the value axis; `barGap: "-100%"` lays every one of them
|
|
16
|
+
* over the category's centre instead of side by side.
|
|
17
|
+
*/
|
|
18
|
+
export const CHART_LINE_SERIES_PREFIX = "rnc-chart-lines-";
|
|
19
|
+
const finite = (item) => {
|
|
20
|
+
const raw = item !== null && typeof item === "object" && "value" in item
|
|
21
|
+
? item.value
|
|
22
|
+
: item;
|
|
23
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : undefined;
|
|
24
|
+
};
|
|
25
|
+
/** Excel's line colour for these elements: Text 1 at 75% (#404040). */
|
|
26
|
+
const LINE_COLOR = "#404040";
|
|
27
|
+
const spanSeries = ({ id, base, span, barWidth, itemStyle, yAxisIndex, }) => {
|
|
28
|
+
const common = {
|
|
29
|
+
type: "bar",
|
|
30
|
+
stack: `${CHART_LINE_SERIES_PREFIX}${id}`,
|
|
31
|
+
stackStrategy: "all",
|
|
32
|
+
barWidth,
|
|
33
|
+
barGap: "-100%",
|
|
34
|
+
silent: true,
|
|
35
|
+
legendHoverLink: false,
|
|
36
|
+
tooltip: { show: false },
|
|
37
|
+
emphasis: { disabled: true },
|
|
38
|
+
label: { show: false },
|
|
39
|
+
z: 1,
|
|
40
|
+
...(yAxisIndex ? { yAxisIndex } : {}),
|
|
41
|
+
};
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
...common,
|
|
45
|
+
id: `${CHART_LINE_SERIES_PREFIX}${id}-base`,
|
|
46
|
+
data: base,
|
|
47
|
+
itemStyle: { color: "transparent" },
|
|
48
|
+
},
|
|
49
|
+
{ ...common, id: `${CHART_LINE_SERIES_PREFIX}${id}`, data: span, itemStyle },
|
|
50
|
+
];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The extra series for `options`, given the data of the chart's line series
|
|
54
|
+
* on one value axis, in spec order.
|
|
55
|
+
*/
|
|
56
|
+
export const buildChartLineSeries = (options, lines, { isDarkMode, yAxisIndex } = {}) => {
|
|
57
|
+
const color = isDarkMode ? "rgba(255,255,255,0.65)" : LINE_COLOR;
|
|
58
|
+
const length = lines.reduce((n, data) => Math.max(n, data.length), 0);
|
|
59
|
+
const out = [];
|
|
60
|
+
const extent = (i) => {
|
|
61
|
+
const values = lines.map((data) => finite(data[i])).filter((v) => v !== undefined);
|
|
62
|
+
return values.length
|
|
63
|
+
? { low: Math.min(...values), high: Math.max(...values), count: values.length }
|
|
64
|
+
: undefined;
|
|
65
|
+
};
|
|
66
|
+
if (options.dropLines && lines.length) {
|
|
67
|
+
const base = [];
|
|
68
|
+
const span = [];
|
|
69
|
+
for (let i = 0; i < length; i++) {
|
|
70
|
+
const e = extent(i);
|
|
71
|
+
base.push(e ? 0 : null);
|
|
72
|
+
span.push(e ? e.high : null);
|
|
73
|
+
}
|
|
74
|
+
out.push(...spanSeries({ id: "drop", base, span, barWidth: 1, itemStyle: { color }, yAxisIndex }));
|
|
75
|
+
}
|
|
76
|
+
if (options.hiLowLines && lines.length > 1) {
|
|
77
|
+
const base = [];
|
|
78
|
+
const span = [];
|
|
79
|
+
for (let i = 0; i < length; i++) {
|
|
80
|
+
const e = extent(i);
|
|
81
|
+
const drawn = e && e.count > 1;
|
|
82
|
+
base.push(drawn ? e.low : null);
|
|
83
|
+
span.push(drawn ? e.high - e.low : null);
|
|
84
|
+
}
|
|
85
|
+
out.push(...spanSeries({ id: "hilow", base, span, barWidth: 1, itemStyle: { color }, yAxisIndex }));
|
|
86
|
+
}
|
|
87
|
+
if (options.upDownBars && lines.length > 1) {
|
|
88
|
+
const first = lines[0];
|
|
89
|
+
const last = lines[lines.length - 1];
|
|
90
|
+
const up = options.upDownBars.upColor ?? "#FFFFFF";
|
|
91
|
+
const down = options.upDownBars.downColor ?? (isDarkMode ? "#A6A6A6" : "#595959");
|
|
92
|
+
const base = [];
|
|
93
|
+
const span = [];
|
|
94
|
+
for (let i = 0; i < length; i++) {
|
|
95
|
+
const open = finite(first[i]);
|
|
96
|
+
const close = finite(last[i]);
|
|
97
|
+
if (open === undefined || close === undefined) {
|
|
98
|
+
base.push(null);
|
|
99
|
+
span.push(null);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
base.push(Math.min(open, close));
|
|
103
|
+
span.push({
|
|
104
|
+
value: Math.abs(close - open),
|
|
105
|
+
itemStyle: { color: close >= open ? up : down },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// `<c:gapWidth>` is the gap as a % of the bar: the bar is 1 / (1 + gap) of the category.
|
|
109
|
+
const gap = options.upDownBars.gapWidth ?? 150;
|
|
110
|
+
const barWidth = `${Math.round(100 / (1 + Math.max(0, gap) / 100))}%`;
|
|
111
|
+
out.push(...spanSeries({
|
|
112
|
+
id: "updown",
|
|
113
|
+
base,
|
|
114
|
+
span,
|
|
115
|
+
barWidth,
|
|
116
|
+
itemStyle: { borderColor: color, borderWidth: 1 },
|
|
117
|
+
yAxisIndex,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's chart data table (Add Chart Element → Data Table,
|
|
3
|
+
* demo-app-monorepo#49969 FT-08): one row per series under the category
|
|
4
|
+
* axis, each cell under its category, the series name (with its legend key)
|
|
5
|
+
* at the row's start. Drawn as extra category axes stacked below the plot:
|
|
6
|
+
* their labels are the formatted values, their axis line the horizontal
|
|
7
|
+
* border and their ticks — between categories — the vertical borders.
|
|
8
|
+
*/
|
|
9
|
+
export type DataTableOptions = {
|
|
10
|
+
showHorizontalBorder?: boolean | null;
|
|
11
|
+
showVerticalBorder?: boolean | null;
|
|
12
|
+
showOutline?: boolean | null;
|
|
13
|
+
showLegendKeys?: boolean | null;
|
|
14
|
+
};
|
|
15
|
+
export type DataTableRow = {
|
|
16
|
+
name: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
values: string[];
|
|
19
|
+
};
|
|
20
|
+
/** Row height in pixels: 9 pt text plus padding. */
|
|
21
|
+
export declare const DATA_TABLE_ROW_HEIGHT = 20;
|
|
22
|
+
export declare const dataTableAxes: (rows: ReadonlyArray<DataTableRow>, options: DataTableOptions, { textColor, fontSize, borderColor, firstOffset, }: {
|
|
23
|
+
textColor: string;
|
|
24
|
+
fontSize: number;
|
|
25
|
+
borderColor?: string;
|
|
26
|
+
/** Below the category labels (the table's header row). */
|
|
27
|
+
firstOffset?: number;
|
|
28
|
+
}) => Record<string, unknown>[];
|
|
29
|
+
/** Room the row names need left of the plot (approximate glyph width). */
|
|
30
|
+
export declare const dataTableNameWidth: (rows: ReadonlyArray<DataTableRow>, fontSize: number, legendKeys: boolean) => number;
|
|
31
|
+
//# sourceMappingURL=data-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../../utils/data-table.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oBAAoB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,aAAa,GACxB,MAAM,aAAa,CAAC,YAAY,CAAC,EACjC,SAAS,gBAAgB,EACzB,oDAKG;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KACA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAqCtB,CAAC;AAEL,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,GAC7B,MAAM,aAAa,CAAC,YAAY,CAAC,EACjC,UAAU,MAAM,EAChB,YAAY,OAAO,WAQb,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's chart data table (Add Chart Element → Data Table,
|
|
3
|
+
* demo-app-monorepo#49969 FT-08): one row per series under the category
|
|
4
|
+
* axis, each cell under its category, the series name (with its legend key)
|
|
5
|
+
* at the row's start. Drawn as extra category axes stacked below the plot:
|
|
6
|
+
* their labels are the formatted values, their axis line the horizontal
|
|
7
|
+
* border and their ticks — between categories — the vertical borders.
|
|
8
|
+
*/
|
|
9
|
+
/** Row height in pixels: 9 pt text plus padding. */
|
|
10
|
+
export const DATA_TABLE_ROW_HEIGHT = 20;
|
|
11
|
+
export const dataTableAxes = (rows, options, { textColor, fontSize, borderColor = "#D9D9D9", firstOffset = 22, }) => rows.map((row, index) => {
|
|
12
|
+
const keys = options.showLegendKeys !== false;
|
|
13
|
+
return {
|
|
14
|
+
type: "category",
|
|
15
|
+
position: "bottom",
|
|
16
|
+
gridIndex: 0,
|
|
17
|
+
offset: firstOffset + index * DATA_TABLE_ROW_HEIGHT,
|
|
18
|
+
data: row.values,
|
|
19
|
+
silent: true,
|
|
20
|
+
axisLine: {
|
|
21
|
+
show: options.showHorizontalBorder !== false ||
|
|
22
|
+
(options.showOutline !== false && index === rows.length - 1),
|
|
23
|
+
onZero: false,
|
|
24
|
+
lineStyle: { color: borderColor },
|
|
25
|
+
},
|
|
26
|
+
axisTick: {
|
|
27
|
+
show: options.showVerticalBorder !== false,
|
|
28
|
+
interval: 0,
|
|
29
|
+
length: DATA_TABLE_ROW_HEIGHT,
|
|
30
|
+
lineStyle: { color: borderColor },
|
|
31
|
+
},
|
|
32
|
+
axisLabel: { interval: 0, color: textColor, fontSize, margin: 6 },
|
|
33
|
+
splitLine: { show: false },
|
|
34
|
+
name: keys ? `{key|■} ${row.name}` : row.name,
|
|
35
|
+
nameLocation: "start",
|
|
36
|
+
nameGap: 8,
|
|
37
|
+
nameTextStyle: {
|
|
38
|
+
color: textColor,
|
|
39
|
+
fontSize,
|
|
40
|
+
align: "right",
|
|
41
|
+
verticalAlign: "top",
|
|
42
|
+
padding: [6, 0, 0, 0],
|
|
43
|
+
rich: { key: { color: row.color ?? textColor, fontSize } },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
/** Room the row names need left of the plot (approximate glyph width). */
|
|
48
|
+
export const dataTableNameWidth = (rows, fontSize, legendKeys) => Math.ceil(rows.reduce((width, row) => Math.max(width, (row.name.length + (legendKeys ? 2 : 0)) * fontSize * 0.6), 0)) + 12;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's automatic value-axis scale (Format Axis → Bounds / Units left on
|
|
3
|
+
* "Auto"). Excel does not publish the rule; this is the behaviour Jon Peltier
|
|
4
|
+
* measured ("How Excel Calculates Automatic Chart Axis Limits",
|
|
5
|
+
* peltiertech.com) and that LV-05 of demo-app-monorepo#49969 compared:
|
|
6
|
+
*
|
|
7
|
+
* - The minimum is 0 when every value is ≥ 0 and the data spans more than a
|
|
8
|
+
* sixth of the maximum (the mirror rule pins the maximum to 0 for an
|
|
9
|
+
* all-negative series); a narrower positive range starts half its span
|
|
10
|
+
* below the smallest value.
|
|
11
|
+
* - The maximum is the largest value plus 5% of the range, rounded up to the
|
|
12
|
+
* next major unit (so data ending at 17 gets an 18 ceiling, 100 gets 120).
|
|
13
|
+
* - The major unit is the smallest 1-2-5 step that splits the range into at
|
|
14
|
+
* most ten intervals.
|
|
15
|
+
*
|
|
16
|
+
* echarts' own nicing (1-2-3-5 steps aimed at five intervals) gives steps of
|
|
17
|
+
* 3 or 25 Excel never draws, so the renderer hands echarts these bounds.
|
|
18
|
+
*/
|
|
19
|
+
export type ExcelAxisScale = {
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
interval: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const excelAutoAxisScale: (values: Iterable<number>, fixed?: {
|
|
25
|
+
min?: number | null;
|
|
26
|
+
max?: number | null;
|
|
27
|
+
majorUnit?: number | null;
|
|
28
|
+
}) => ExcelAxisScale | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The values a cartesian value axis has to fit: every point of the bar / line
|
|
31
|
+
* series plotted against `axisIndex`, with stacked series summed per category
|
|
32
|
+
* (positives and negatives apart, as Excel stacks them).
|
|
33
|
+
*/
|
|
34
|
+
export declare const valueAxisExtentValues: (series: ReadonlyArray<any>, axisIndex: number, axisKey?: "yAxisIndex" | "xAxisIndex") => number[];
|
|
35
|
+
//# sourceMappingURL=excel-axis-scale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excel-axis-scale.d.ts","sourceRoot":"","sources":["../../../utils/excel-axis-scale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAiB5E,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,QAAQ,CAAC,MAAM,CAAC,EACxB,QAAO;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,KAClF,cAAc,GAAG,SA6CnB,CAAC;AAYF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,aAAa,CAAC,GAAG,CAAC,EAC1B,WAAW,MAAM,EACjB,UAAS,YAAY,GAAG,YAA2B,KAClD,MAAM,EA6BR,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const MAX_INTERVALS = 10;
|
|
2
|
+
const niceSteps = (span) => {
|
|
3
|
+
const exponent = Math.floor(Math.log10(span / MAX_INTERVALS));
|
|
4
|
+
const steps = [];
|
|
5
|
+
for (let e = exponent - 1; e <= exponent + 2; e++) {
|
|
6
|
+
const base = 10 ** e;
|
|
7
|
+
steps.push(base, 2 * base, 5 * base);
|
|
8
|
+
}
|
|
9
|
+
return steps;
|
|
10
|
+
};
|
|
11
|
+
/** Floating-point safe multiple of `step` (`0.1 * 3` would print 0.30000000000000004). */
|
|
12
|
+
const multiple = (k, step) => Number((k * step).toPrecision(12));
|
|
13
|
+
export const excelAutoAxisScale = (values, fixed = {}) => {
|
|
14
|
+
let dataMin = Infinity;
|
|
15
|
+
let dataMax = -Infinity;
|
|
16
|
+
for (const v of values) {
|
|
17
|
+
if (!Number.isFinite(v))
|
|
18
|
+
continue;
|
|
19
|
+
if (v < dataMin)
|
|
20
|
+
dataMin = v;
|
|
21
|
+
if (v > dataMax)
|
|
22
|
+
dataMax = v;
|
|
23
|
+
}
|
|
24
|
+
if (!Number.isFinite(dataMin))
|
|
25
|
+
return undefined;
|
|
26
|
+
if (dataMin === dataMax) {
|
|
27
|
+
// One distinct value: Excel spans 0..value (or value..0).
|
|
28
|
+
if (dataMin > 0)
|
|
29
|
+
dataMin = 0;
|
|
30
|
+
else if (dataMax < 0)
|
|
31
|
+
dataMax = 0;
|
|
32
|
+
else
|
|
33
|
+
dataMax = 1;
|
|
34
|
+
}
|
|
35
|
+
const fixedMin = typeof fixed.min === "number" ? fixed.min : undefined;
|
|
36
|
+
const fixedMax = typeof fixed.max === "number" ? fixed.max : undefined;
|
|
37
|
+
let lo;
|
|
38
|
+
if (fixedMin !== undefined)
|
|
39
|
+
lo = fixedMin;
|
|
40
|
+
else if (dataMin >= 0)
|
|
41
|
+
lo = (dataMax - dataMin) / dataMax > 1 / 6 ? 0 : dataMin - (dataMax - dataMin) / 2;
|
|
42
|
+
else if (dataMax <= 0)
|
|
43
|
+
lo = dataMin - 0.05 * (0 - dataMin);
|
|
44
|
+
else
|
|
45
|
+
lo = dataMin - 0.05 * (dataMax - dataMin);
|
|
46
|
+
let hi;
|
|
47
|
+
if (fixedMax !== undefined)
|
|
48
|
+
hi = fixedMax;
|
|
49
|
+
else if (dataMax <= 0)
|
|
50
|
+
hi = (dataMax - dataMin) / -dataMin > 1 / 6 ? 0 : dataMax + (dataMax - dataMin) / 2;
|
|
51
|
+
else
|
|
52
|
+
hi = dataMax + 0.05 * (dataMax - lo);
|
|
53
|
+
if (!(hi > lo))
|
|
54
|
+
return undefined;
|
|
55
|
+
const pick = (step) => {
|
|
56
|
+
const min = fixedMin !== undefined ? fixedMin : multiple(Math.floor(lo / step), step);
|
|
57
|
+
const max = fixedMax !== undefined ? fixedMax : multiple(Math.ceil(hi / step), step);
|
|
58
|
+
return { min, max, interval: step };
|
|
59
|
+
};
|
|
60
|
+
if (typeof fixed.majorUnit === "number" && fixed.majorUnit > 0) {
|
|
61
|
+
return pick(fixed.majorUnit);
|
|
62
|
+
}
|
|
63
|
+
for (const step of niceSteps(hi - lo)) {
|
|
64
|
+
const scale = pick(step);
|
|
65
|
+
if ((scale.max - scale.min) / step <= MAX_INTERVALS + 1e-9)
|
|
66
|
+
return scale;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
const pointValue = (item) => {
|
|
71
|
+
const raw = item !== null && typeof item === "object" && "value" in item
|
|
72
|
+
? item.value
|
|
73
|
+
: item;
|
|
74
|
+
if (Array.isArray(raw))
|
|
75
|
+
return undefined;
|
|
76
|
+
const n = typeof raw === "number" ? raw : raw == null || raw === "" ? NaN : Number(raw);
|
|
77
|
+
return Number.isFinite(n) ? n : undefined;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The values a cartesian value axis has to fit: every point of the bar / line
|
|
81
|
+
* series plotted against `axisIndex`, with stacked series summed per category
|
|
82
|
+
* (positives and negatives apart, as Excel stacks them).
|
|
83
|
+
*/
|
|
84
|
+
export const valueAxisExtentValues = (series, axisIndex, axisKey = "yAxisIndex") => {
|
|
85
|
+
const values = [];
|
|
86
|
+
const stacks = new Map();
|
|
87
|
+
for (const s of series) {
|
|
88
|
+
if (!s || (s.type !== "bar" && s.type !== "line"))
|
|
89
|
+
continue;
|
|
90
|
+
// High-low / drop lines and up/down bars only span the plotted values.
|
|
91
|
+
if (String(s.id ?? "").startsWith("rnc-chart-lines-"))
|
|
92
|
+
continue;
|
|
93
|
+
if ((s[axisKey] ?? 0) !== axisIndex || !Array.isArray(s.data))
|
|
94
|
+
continue;
|
|
95
|
+
if (s.stack === undefined) {
|
|
96
|
+
for (const item of s.data) {
|
|
97
|
+
const v = pointValue(item);
|
|
98
|
+
if (v !== undefined)
|
|
99
|
+
values.push(v);
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const stack = stacks.get(s.stack) ?? { pos: [], neg: [] };
|
|
104
|
+
stacks.set(s.stack, stack);
|
|
105
|
+
s.data.forEach((item, i) => {
|
|
106
|
+
const v = pointValue(item);
|
|
107
|
+
if (v === undefined)
|
|
108
|
+
return;
|
|
109
|
+
const side = v >= 0 ? stack.pos : stack.neg;
|
|
110
|
+
side[i] = (side[i] ?? 0) + v;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
for (const { pos, neg } of stacks.values()) {
|
|
114
|
+
for (const v of pos)
|
|
115
|
+
if (v !== undefined)
|
|
116
|
+
values.push(v);
|
|
117
|
+
for (const v of neg)
|
|
118
|
+
if (v !== undefined)
|
|
119
|
+
values.push(v);
|
|
120
|
+
}
|
|
121
|
+
return values;
|
|
122
|
+
};
|
|
@@ -7,6 +7,20 @@ import type { LegendComponentOption } from "echarts";
|
|
|
7
7
|
* Underline / strikethrough have no canvas text decoration in echarts and
|
|
8
8
|
* are not drawn.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* `ChartTextFormat.fontSize` is in points (OOXML `sz` / 100, the editor's
|
|
12
|
+
* Size field); echarts draws pixels. 9 pt → 12 px, 14 pt → 18.67 px.
|
|
13
|
+
*/
|
|
14
|
+
export declare const pointsToPixels: (points: number) => number;
|
|
15
|
+
/** An authored point size as pixels, or `fallbackPx` when none is set. */
|
|
16
|
+
export declare const fontSizePx: (points: unknown, fallbackPx: number) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Excel's chart text defaults (Office 2013+ chart styles): the theme's body
|
|
19
|
+
* (minor) font, 9 pt in Text 1 at 65% (#595959 on the light theme), and a
|
|
20
|
+
* 14 pt regular title (RD-24).
|
|
21
|
+
*/
|
|
22
|
+
export declare const CHART_TEXT_PX: number;
|
|
23
|
+
export declare const CHART_TITLE_PX: number;
|
|
10
24
|
export declare const themedTextStyle: (fmt: any, defaults: {
|
|
11
25
|
color: string;
|
|
12
26
|
fontSize: number;
|
|
@@ -15,19 +29,26 @@ export declare const themedTextStyle: (fmt: any, defaults: {
|
|
|
15
29
|
}) => {
|
|
16
30
|
color: any;
|
|
17
31
|
fontFamily: any;
|
|
18
|
-
fontSize:
|
|
32
|
+
fontSize: number;
|
|
19
33
|
fontWeight: "bold" | "normal";
|
|
20
34
|
fontStyle: "italic" | "normal";
|
|
21
35
|
};
|
|
22
36
|
/** Build an echarts `textStyle` from a parsed `ChartTextFormat`. */
|
|
23
37
|
export declare const textFormatToEchartsTextStyle: (fmt: any) => Record<string, any> | undefined;
|
|
24
38
|
export declare const applyLegendOverrides: (legend: LegendComponentOption, opts: any) => LegendComponentOption;
|
|
39
|
+
/** Excel's Format Axis → Display units: the divisor and the label it shows. */
|
|
40
|
+
export declare const DISPLAY_UNITS: Record<string, {
|
|
41
|
+
divisor: number;
|
|
42
|
+
label: string;
|
|
43
|
+
}>;
|
|
25
44
|
/**
|
|
26
45
|
* `numberFormatPattern` is the axis' RESOLVED format (explicit pattern or
|
|
27
46
|
* the linked source-cell format — see `resolveValueAxisNumberFormat`); it
|
|
28
|
-
* becomes the tick-label formatter.
|
|
47
|
+
* becomes the tick-label formatter. `placement` says which side of the plot
|
|
48
|
+
* the axis runs along (`x` horizontal, `y` vertical) for Excel's axis
|
|
49
|
+
* crossing; it defaults to `x` for a category axis and `y` for a value axis.
|
|
29
50
|
*/
|
|
30
|
-
export declare const applyAxisOverrides: (axis: any, opts: any, numberFormatPattern?: string, locale?: string) => any;
|
|
51
|
+
export declare const applyAxisOverrides: (axis: any, opts: any, numberFormatPattern?: string, locale?: string, placement?: "x" | "y") => any;
|
|
31
52
|
export declare const dataLabelFormatter: (opts: any, locale?: string, joiner?: string) => (params: any) => string;
|
|
32
53
|
/**
|
|
33
54
|
* The data-label options one series renders with: its own
|