@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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Excel's line-chart analysis elements (Chart Design → Add Chart Element →
|
|
4
|
+
* Lines / Up/Down Bars, demo-app-monorepo#49969 FT-08) as echarts bar series
|
|
5
|
+
* over the category axis:
|
|
6
|
+
*
|
|
7
|
+
* - High-low lines — a thin vertical line per category from the lowest to the
|
|
8
|
+
* highest value of all the line series (`<c:hiLowLines/>`).
|
|
9
|
+
* - Up/down bars — a bar per category from the first line series' value to
|
|
10
|
+
* the last one's: an up bar (white) where the last is higher, a down bar
|
|
11
|
+
* (dark) where it is lower (`<c:upDownBars>`).
|
|
12
|
+
* - Drop lines — a thin vertical line per category from the axis to the
|
|
13
|
+
* highest point (`<c:dropLines/>`).
|
|
14
|
+
*
|
|
15
|
+
* Each is a stack of an invisible base plus a visible span, so the bars can
|
|
16
|
+
* start anywhere on the value axis; `barGap: "-100%"` lays every one of them
|
|
17
|
+
* over the category's centre instead of side by side.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.buildChartLineSeries = exports.CHART_LINE_SERIES_PREFIX = void 0;
|
|
21
|
+
var tslib_1 = require("tslib");
|
|
22
|
+
exports.CHART_LINE_SERIES_PREFIX = "rnc-chart-lines-";
|
|
23
|
+
var finite = function (item) {
|
|
24
|
+
var raw = item !== null && typeof item === "object" && "value" in item
|
|
25
|
+
? item.value
|
|
26
|
+
: item;
|
|
27
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : undefined;
|
|
28
|
+
};
|
|
29
|
+
/** Excel's line colour for these elements: Text 1 at 75% (#404040). */
|
|
30
|
+
var LINE_COLOR = "#404040";
|
|
31
|
+
var spanSeries = function (_a) {
|
|
32
|
+
var id = _a.id, base = _a.base, span = _a.span, barWidth = _a.barWidth, itemStyle = _a.itemStyle, yAxisIndex = _a.yAxisIndex;
|
|
33
|
+
var common = tslib_1.__assign({ type: "bar", stack: "".concat(exports.CHART_LINE_SERIES_PREFIX).concat(id), stackStrategy: "all", barWidth: barWidth, barGap: "-100%", silent: true, legendHoverLink: false, tooltip: { show: false }, emphasis: { disabled: true }, label: { show: false }, z: 1 }, (yAxisIndex ? { yAxisIndex: yAxisIndex } : {}));
|
|
34
|
+
return [
|
|
35
|
+
tslib_1.__assign(tslib_1.__assign({}, common), { id: "".concat(exports.CHART_LINE_SERIES_PREFIX).concat(id, "-base"), data: base, itemStyle: { color: "transparent" } }),
|
|
36
|
+
tslib_1.__assign(tslib_1.__assign({}, common), { id: "".concat(exports.CHART_LINE_SERIES_PREFIX).concat(id), data: span, itemStyle: itemStyle }),
|
|
37
|
+
];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The extra series for `options`, given the data of the chart's line series
|
|
41
|
+
* on one value axis, in spec order.
|
|
42
|
+
*/
|
|
43
|
+
var buildChartLineSeries = function (options, lines, _a) {
|
|
44
|
+
var _b, _c, _d;
|
|
45
|
+
var _e = _a === void 0 ? {} : _a, isDarkMode = _e.isDarkMode, yAxisIndex = _e.yAxisIndex;
|
|
46
|
+
var color = isDarkMode ? "rgba(255,255,255,0.65)" : LINE_COLOR;
|
|
47
|
+
var length = lines.reduce(function (n, data) { return Math.max(n, data.length); }, 0);
|
|
48
|
+
var out = [];
|
|
49
|
+
var extent = function (i) {
|
|
50
|
+
var values = lines.map(function (data) { return finite(data[i]); }).filter(function (v) { return v !== undefined; });
|
|
51
|
+
return values.length
|
|
52
|
+
? { low: Math.min.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(values), false)), high: Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(values), false)), count: values.length }
|
|
53
|
+
: undefined;
|
|
54
|
+
};
|
|
55
|
+
if (options.dropLines && lines.length) {
|
|
56
|
+
var base = [];
|
|
57
|
+
var span = [];
|
|
58
|
+
for (var i = 0; i < length; i++) {
|
|
59
|
+
var e = extent(i);
|
|
60
|
+
base.push(e ? 0 : null);
|
|
61
|
+
span.push(e ? e.high : null);
|
|
62
|
+
}
|
|
63
|
+
out.push.apply(out, tslib_1.__spreadArray([], tslib_1.__read(spanSeries({ id: "drop", base: base, span: span, barWidth: 1, itemStyle: { color: color }, yAxisIndex: yAxisIndex })), false));
|
|
64
|
+
}
|
|
65
|
+
if (options.hiLowLines && lines.length > 1) {
|
|
66
|
+
var base = [];
|
|
67
|
+
var span = [];
|
|
68
|
+
for (var i = 0; i < length; i++) {
|
|
69
|
+
var e = extent(i);
|
|
70
|
+
var drawn = e && e.count > 1;
|
|
71
|
+
base.push(drawn ? e.low : null);
|
|
72
|
+
span.push(drawn ? e.high - e.low : null);
|
|
73
|
+
}
|
|
74
|
+
out.push.apply(out, tslib_1.__spreadArray([], tslib_1.__read(spanSeries({ id: "hilow", base: base, span: span, barWidth: 1, itemStyle: { color: color }, yAxisIndex: yAxisIndex })), false));
|
|
75
|
+
}
|
|
76
|
+
if (options.upDownBars && lines.length > 1) {
|
|
77
|
+
var first = lines[0];
|
|
78
|
+
var last = lines[lines.length - 1];
|
|
79
|
+
var up = (_b = options.upDownBars.upColor) !== null && _b !== void 0 ? _b : "#FFFFFF";
|
|
80
|
+
var down = (_c = options.upDownBars.downColor) !== null && _c !== void 0 ? _c : (isDarkMode ? "#A6A6A6" : "#595959");
|
|
81
|
+
var base = [];
|
|
82
|
+
var span = [];
|
|
83
|
+
for (var i = 0; i < length; i++) {
|
|
84
|
+
var open_1 = finite(first[i]);
|
|
85
|
+
var close_1 = finite(last[i]);
|
|
86
|
+
if (open_1 === undefined || close_1 === undefined) {
|
|
87
|
+
base.push(null);
|
|
88
|
+
span.push(null);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
base.push(Math.min(open_1, close_1));
|
|
92
|
+
span.push({
|
|
93
|
+
value: Math.abs(close_1 - open_1),
|
|
94
|
+
itemStyle: { color: close_1 >= open_1 ? up : down },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// `<c:gapWidth>` is the gap as a % of the bar: the bar is 1 / (1 + gap) of the category.
|
|
98
|
+
var gap = (_d = options.upDownBars.gapWidth) !== null && _d !== void 0 ? _d : 150;
|
|
99
|
+
var barWidth = "".concat(Math.round(100 / (1 + Math.max(0, gap) / 100)), "%");
|
|
100
|
+
out.push.apply(out, tslib_1.__spreadArray([], tslib_1.__read(spanSeries({
|
|
101
|
+
id: "updown",
|
|
102
|
+
base: base,
|
|
103
|
+
span: span,
|
|
104
|
+
barWidth: barWidth,
|
|
105
|
+
itemStyle: { borderColor: color, borderWidth: 1 },
|
|
106
|
+
yAxisIndex: yAxisIndex,
|
|
107
|
+
})), false));
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
};
|
|
111
|
+
exports.buildChartLineSeries = buildChartLineSeries;
|
|
@@ -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,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Excel's chart data table (Add Chart Element → Data Table,
|
|
4
|
+
* demo-app-monorepo#49969 FT-08): one row per series under the category
|
|
5
|
+
* axis, each cell under its category, the series name (with its legend key)
|
|
6
|
+
* at the row's start. Drawn as extra category axes stacked below the plot:
|
|
7
|
+
* their labels are the formatted values, their axis line the horizontal
|
|
8
|
+
* border and their ticks — between categories — the vertical borders.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.dataTableNameWidth = exports.dataTableAxes = exports.DATA_TABLE_ROW_HEIGHT = void 0;
|
|
12
|
+
/** Row height in pixels: 9 pt text plus padding. */
|
|
13
|
+
exports.DATA_TABLE_ROW_HEIGHT = 20;
|
|
14
|
+
var dataTableAxes = function (rows, options, _a) {
|
|
15
|
+
var textColor = _a.textColor, fontSize = _a.fontSize, _b = _a.borderColor, borderColor = _b === void 0 ? "#D9D9D9" : _b, _c = _a.firstOffset, firstOffset = _c === void 0 ? 22 : _c;
|
|
16
|
+
return rows.map(function (row, index) {
|
|
17
|
+
var _a;
|
|
18
|
+
var keys = options.showLegendKeys !== false;
|
|
19
|
+
return {
|
|
20
|
+
type: "category",
|
|
21
|
+
position: "bottom",
|
|
22
|
+
gridIndex: 0,
|
|
23
|
+
offset: firstOffset + index * exports.DATA_TABLE_ROW_HEIGHT,
|
|
24
|
+
data: row.values,
|
|
25
|
+
silent: true,
|
|
26
|
+
axisLine: {
|
|
27
|
+
show: options.showHorizontalBorder !== false ||
|
|
28
|
+
(options.showOutline !== false && index === rows.length - 1),
|
|
29
|
+
onZero: false,
|
|
30
|
+
lineStyle: { color: borderColor },
|
|
31
|
+
},
|
|
32
|
+
axisTick: {
|
|
33
|
+
show: options.showVerticalBorder !== false,
|
|
34
|
+
interval: 0,
|
|
35
|
+
length: exports.DATA_TABLE_ROW_HEIGHT,
|
|
36
|
+
lineStyle: { color: borderColor },
|
|
37
|
+
},
|
|
38
|
+
axisLabel: { interval: 0, color: textColor, fontSize: fontSize, margin: 6 },
|
|
39
|
+
splitLine: { show: false },
|
|
40
|
+
name: keys ? "{key|\u25A0} ".concat(row.name) : row.name,
|
|
41
|
+
nameLocation: "start",
|
|
42
|
+
nameGap: 8,
|
|
43
|
+
nameTextStyle: {
|
|
44
|
+
color: textColor,
|
|
45
|
+
fontSize: fontSize,
|
|
46
|
+
align: "right",
|
|
47
|
+
verticalAlign: "top",
|
|
48
|
+
padding: [6, 0, 0, 0],
|
|
49
|
+
rich: { key: { color: (_a = row.color) !== null && _a !== void 0 ? _a : textColor, fontSize: fontSize } },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.dataTableAxes = dataTableAxes;
|
|
55
|
+
/** Room the row names need left of the plot (approximate glyph width). */
|
|
56
|
+
var dataTableNameWidth = function (rows, fontSize, legendKeys) {
|
|
57
|
+
return Math.ceil(rows.reduce(function (width, row) {
|
|
58
|
+
return Math.max(width, (row.name.length + (legendKeys ? 2 : 0)) * fontSize * 0.6);
|
|
59
|
+
}, 0)) + 12;
|
|
60
|
+
};
|
|
61
|
+
exports.dataTableNameWidth = dataTableNameWidth;
|
|
@@ -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,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.valueAxisExtentValues = exports.excelAutoAxisScale = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var MAX_INTERVALS = 10;
|
|
6
|
+
var niceSteps = function (span) {
|
|
7
|
+
var exponent = Math.floor(Math.log10(span / MAX_INTERVALS));
|
|
8
|
+
var steps = [];
|
|
9
|
+
for (var e = exponent - 1; e <= exponent + 2; e++) {
|
|
10
|
+
var base = Math.pow(10, e);
|
|
11
|
+
steps.push(base, 2 * base, 5 * base);
|
|
12
|
+
}
|
|
13
|
+
return steps;
|
|
14
|
+
};
|
|
15
|
+
/** Floating-point safe multiple of `step` (`0.1 * 3` would print 0.30000000000000004). */
|
|
16
|
+
var multiple = function (k, step) { return Number((k * step).toPrecision(12)); };
|
|
17
|
+
var excelAutoAxisScale = function (values, fixed) {
|
|
18
|
+
var e_1, _a, e_2, _b;
|
|
19
|
+
if (fixed === void 0) { fixed = {}; }
|
|
20
|
+
var dataMin = Infinity;
|
|
21
|
+
var dataMax = -Infinity;
|
|
22
|
+
try {
|
|
23
|
+
for (var values_1 = tslib_1.__values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
|
|
24
|
+
var v = values_1_1.value;
|
|
25
|
+
if (!Number.isFinite(v))
|
|
26
|
+
continue;
|
|
27
|
+
if (v < dataMin)
|
|
28
|
+
dataMin = v;
|
|
29
|
+
if (v > dataMax)
|
|
30
|
+
dataMax = v;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
34
|
+
finally {
|
|
35
|
+
try {
|
|
36
|
+
if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
|
|
37
|
+
}
|
|
38
|
+
finally { if (e_1) throw e_1.error; }
|
|
39
|
+
}
|
|
40
|
+
if (!Number.isFinite(dataMin))
|
|
41
|
+
return undefined;
|
|
42
|
+
if (dataMin === dataMax) {
|
|
43
|
+
// One distinct value: Excel spans 0..value (or value..0).
|
|
44
|
+
if (dataMin > 0)
|
|
45
|
+
dataMin = 0;
|
|
46
|
+
else if (dataMax < 0)
|
|
47
|
+
dataMax = 0;
|
|
48
|
+
else
|
|
49
|
+
dataMax = 1;
|
|
50
|
+
}
|
|
51
|
+
var fixedMin = typeof fixed.min === "number" ? fixed.min : undefined;
|
|
52
|
+
var fixedMax = typeof fixed.max === "number" ? fixed.max : undefined;
|
|
53
|
+
var lo;
|
|
54
|
+
if (fixedMin !== undefined)
|
|
55
|
+
lo = fixedMin;
|
|
56
|
+
else if (dataMin >= 0)
|
|
57
|
+
lo = (dataMax - dataMin) / dataMax > 1 / 6 ? 0 : dataMin - (dataMax - dataMin) / 2;
|
|
58
|
+
else if (dataMax <= 0)
|
|
59
|
+
lo = dataMin - 0.05 * (0 - dataMin);
|
|
60
|
+
else
|
|
61
|
+
lo = dataMin - 0.05 * (dataMax - dataMin);
|
|
62
|
+
var hi;
|
|
63
|
+
if (fixedMax !== undefined)
|
|
64
|
+
hi = fixedMax;
|
|
65
|
+
else if (dataMax <= 0)
|
|
66
|
+
hi = (dataMax - dataMin) / -dataMin > 1 / 6 ? 0 : dataMax + (dataMax - dataMin) / 2;
|
|
67
|
+
else
|
|
68
|
+
hi = dataMax + 0.05 * (dataMax - lo);
|
|
69
|
+
if (!(hi > lo))
|
|
70
|
+
return undefined;
|
|
71
|
+
var pick = function (step) {
|
|
72
|
+
var min = fixedMin !== undefined ? fixedMin : multiple(Math.floor(lo / step), step);
|
|
73
|
+
var max = fixedMax !== undefined ? fixedMax : multiple(Math.ceil(hi / step), step);
|
|
74
|
+
return { min: min, max: max, interval: step };
|
|
75
|
+
};
|
|
76
|
+
if (typeof fixed.majorUnit === "number" && fixed.majorUnit > 0) {
|
|
77
|
+
return pick(fixed.majorUnit);
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
for (var _c = tslib_1.__values(niceSteps(hi - lo)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
81
|
+
var step = _d.value;
|
|
82
|
+
var scale = pick(step);
|
|
83
|
+
if ((scale.max - scale.min) / step <= MAX_INTERVALS + 1e-9)
|
|
84
|
+
return scale;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
88
|
+
finally {
|
|
89
|
+
try {
|
|
90
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
91
|
+
}
|
|
92
|
+
finally { if (e_2) throw e_2.error; }
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
};
|
|
96
|
+
exports.excelAutoAxisScale = excelAutoAxisScale;
|
|
97
|
+
var pointValue = function (item) {
|
|
98
|
+
var raw = item !== null && typeof item === "object" && "value" in item
|
|
99
|
+
? item.value
|
|
100
|
+
: item;
|
|
101
|
+
if (Array.isArray(raw))
|
|
102
|
+
return undefined;
|
|
103
|
+
var n = typeof raw === "number" ? raw : raw == null || raw === "" ? NaN : Number(raw);
|
|
104
|
+
return Number.isFinite(n) ? n : undefined;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The values a cartesian value axis has to fit: every point of the bar / line
|
|
108
|
+
* series plotted against `axisIndex`, with stacked series summed per category
|
|
109
|
+
* (positives and negatives apart, as Excel stacks them).
|
|
110
|
+
*/
|
|
111
|
+
var valueAxisExtentValues = function (series, axisIndex, axisKey) {
|
|
112
|
+
var e_3, _a, e_4, _b, e_5, _c, e_6, _d;
|
|
113
|
+
var _e, _f, _g;
|
|
114
|
+
if (axisKey === void 0) { axisKey = "yAxisIndex"; }
|
|
115
|
+
var values = [];
|
|
116
|
+
var stacks = new Map();
|
|
117
|
+
var _loop_1 = function (s) {
|
|
118
|
+
var e_7, _l;
|
|
119
|
+
if (!s || (s.type !== "bar" && s.type !== "line"))
|
|
120
|
+
return "continue";
|
|
121
|
+
// High-low / drop lines and up/down bars only span the plotted values.
|
|
122
|
+
if (String((_e = s.id) !== null && _e !== void 0 ? _e : "").startsWith("rnc-chart-lines-"))
|
|
123
|
+
return "continue";
|
|
124
|
+
if (((_f = s[axisKey]) !== null && _f !== void 0 ? _f : 0) !== axisIndex || !Array.isArray(s.data))
|
|
125
|
+
return "continue";
|
|
126
|
+
if (s.stack === undefined) {
|
|
127
|
+
try {
|
|
128
|
+
for (var _m = (e_7 = void 0, tslib_1.__values(s.data)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
129
|
+
var item = _o.value;
|
|
130
|
+
var v = pointValue(item);
|
|
131
|
+
if (v !== undefined)
|
|
132
|
+
values.push(v);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
136
|
+
finally {
|
|
137
|
+
try {
|
|
138
|
+
if (_o && !_o.done && (_l = _m.return)) _l.call(_m);
|
|
139
|
+
}
|
|
140
|
+
finally { if (e_7) throw e_7.error; }
|
|
141
|
+
}
|
|
142
|
+
return "continue";
|
|
143
|
+
}
|
|
144
|
+
var stack = (_g = stacks.get(s.stack)) !== null && _g !== void 0 ? _g : { pos: [], neg: [] };
|
|
145
|
+
stacks.set(s.stack, stack);
|
|
146
|
+
s.data.forEach(function (item, i) {
|
|
147
|
+
var _a;
|
|
148
|
+
var v = pointValue(item);
|
|
149
|
+
if (v === undefined)
|
|
150
|
+
return;
|
|
151
|
+
var side = v >= 0 ? stack.pos : stack.neg;
|
|
152
|
+
side[i] = ((_a = side[i]) !== null && _a !== void 0 ? _a : 0) + v;
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
try {
|
|
156
|
+
for (var series_1 = tslib_1.__values(series), series_1_1 = series_1.next(); !series_1_1.done; series_1_1 = series_1.next()) {
|
|
157
|
+
var s = series_1_1.value;
|
|
158
|
+
_loop_1(s);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
162
|
+
finally {
|
|
163
|
+
try {
|
|
164
|
+
if (series_1_1 && !series_1_1.done && (_a = series_1.return)) _a.call(series_1);
|
|
165
|
+
}
|
|
166
|
+
finally { if (e_3) throw e_3.error; }
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
for (var _h = tslib_1.__values(stacks.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
170
|
+
var _k = _j.value, pos = _k.pos, neg = _k.neg;
|
|
171
|
+
try {
|
|
172
|
+
for (var pos_1 = (e_5 = void 0, tslib_1.__values(pos)), pos_1_1 = pos_1.next(); !pos_1_1.done; pos_1_1 = pos_1.next()) {
|
|
173
|
+
var v = pos_1_1.value;
|
|
174
|
+
if (v !== undefined)
|
|
175
|
+
values.push(v);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
179
|
+
finally {
|
|
180
|
+
try {
|
|
181
|
+
if (pos_1_1 && !pos_1_1.done && (_c = pos_1.return)) _c.call(pos_1);
|
|
182
|
+
}
|
|
183
|
+
finally { if (e_5) throw e_5.error; }
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
for (var neg_1 = (e_6 = void 0, tslib_1.__values(neg)), neg_1_1 = neg_1.next(); !neg_1_1.done; neg_1_1 = neg_1.next()) {
|
|
187
|
+
var v = neg_1_1.value;
|
|
188
|
+
if (v !== undefined)
|
|
189
|
+
values.push(v);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
193
|
+
finally {
|
|
194
|
+
try {
|
|
195
|
+
if (neg_1_1 && !neg_1_1.done && (_d = neg_1.return)) _d.call(neg_1);
|
|
196
|
+
}
|
|
197
|
+
finally { if (e_6) throw e_6.error; }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
202
|
+
finally {
|
|
203
|
+
try {
|
|
204
|
+
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
|
|
205
|
+
}
|
|
206
|
+
finally { if (e_4) throw e_4.error; }
|
|
207
|
+
}
|
|
208
|
+
return values;
|
|
209
|
+
};
|
|
210
|
+
exports.valueAxisExtentValues = valueAxisExtentValues;
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,GAAG,EACR,UAAU;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC;;;;
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD;;;;;;;GAOG;AACH;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,WACD,CAAC;AAE7C,0EAA0E;AAC1E,eAAO,MAAM,UAAU,GAAI,QAAQ,OAAO,EAAE,YAAY,MAAM,WACkB,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAoB,CAAC;AAC/C,eAAO,MAAM,cAAc,QAAqB,CAAC;AAEjD,eAAO,MAAM,eAAe,GAC1B,KAAK,GAAG,EACR,UAAU;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChC;;;;gBAMG,MAAM,GACN,QAAQ;eACsC,QAAQ,GAAG,QAAQ;CACrE,CAAC;AAEH,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCAWpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAU5E,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,EACf,YAAY,GAAG,GAAG,GAAG,QAmGtB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,SAAS,MAAM,EAEf,eAAa,MACT,QAAQ,GAAG,WA0DhB,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCAxGH,GAAG;aA0HhB,CAAC"}
|