@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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildSeriesLabelOption = exports.resolveSeriesDataLabels = exports.dataLabelFormatter = exports.applyAxisOverrides = exports.applyLegendOverrides = exports.textFormatToEchartsTextStyle = exports.themedTextStyle = void 0;
|
|
3
|
+
exports.buildSeriesLabelOption = exports.resolveSeriesDataLabels = exports.dataLabelFormatter = exports.applyAxisOverrides = exports.DISPLAY_UNITS = exports.applyLegendOverrides = exports.textFormatToEchartsTextStyle = exports.themedTextStyle = exports.CHART_TITLE_PX = exports.CHART_TEXT_PX = exports.fontSizePx = exports.pointsToPixels = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var axis_number_format_1 = require("./axis-number-format");
|
|
6
6
|
// Map ChartSpec.legend / dataLabels / axisOptions to ECharts option
|
|
@@ -17,14 +17,32 @@ var axis_number_format_1 = require("./axis-number-format");
|
|
|
17
17
|
* Underline / strikethrough have no canvas text decoration in echarts and
|
|
18
18
|
* are not drawn.
|
|
19
19
|
*/
|
|
20
|
+
/**
|
|
21
|
+
* `ChartTextFormat.fontSize` is in points (OOXML `sz` / 100, the editor's
|
|
22
|
+
* Size field); echarts draws pixels. 9 pt → 12 px, 14 pt → 18.67 px.
|
|
23
|
+
*/
|
|
24
|
+
var pointsToPixels = function (points) {
|
|
25
|
+
return Math.round(((points * 4) / 3) * 100) / 100;
|
|
26
|
+
};
|
|
27
|
+
exports.pointsToPixels = pointsToPixels;
|
|
28
|
+
/** An authored point size as pixels, or `fallbackPx` when none is set. */
|
|
29
|
+
var fontSizePx = function (points, fallbackPx) {
|
|
30
|
+
return typeof points === "number" && points > 0 ? (0, exports.pointsToPixels)(points) : fallbackPx;
|
|
31
|
+
};
|
|
32
|
+
exports.fontSizePx = fontSizePx;
|
|
33
|
+
/**
|
|
34
|
+
* Excel's chart text defaults (Office 2013+ chart styles): the theme's body
|
|
35
|
+
* (minor) font, 9 pt in Text 1 at 65% (#595959 on the light theme), and a
|
|
36
|
+
* 14 pt regular title (RD-24).
|
|
37
|
+
*/
|
|
38
|
+
exports.CHART_TEXT_PX = (0, exports.pointsToPixels)(9);
|
|
39
|
+
exports.CHART_TITLE_PX = (0, exports.pointsToPixels)(14);
|
|
20
40
|
var themedTextStyle = function (fmt, defaults) {
|
|
21
41
|
var _a, _b, _c, _d;
|
|
22
42
|
return ({
|
|
23
43
|
color: (_a = fmt === null || fmt === void 0 ? void 0 : fmt.color) !== null && _a !== void 0 ? _a : defaults.color,
|
|
24
44
|
fontFamily: (_c = (_b = fmt === null || fmt === void 0 ? void 0 : fmt.fontFamily) !== null && _b !== void 0 ? _b : defaults.fontFamily) !== null && _c !== void 0 ? _c : "sans-serif",
|
|
25
|
-
fontSize:
|
|
26
|
-
? fmt.fontSize
|
|
27
|
-
: defaults.fontSize,
|
|
45
|
+
fontSize: (0, exports.fontSizePx)(fmt === null || fmt === void 0 ? void 0 : fmt.fontSize, defaults.fontSize),
|
|
28
46
|
fontWeight: (fmt ? (fmt.bold ? "bold" : "normal") : (_d = defaults.fontWeight) !== null && _d !== void 0 ? _d : "normal"),
|
|
29
47
|
fontStyle: ((fmt === null || fmt === void 0 ? void 0 : fmt.italic) ? "italic" : "normal"),
|
|
30
48
|
});
|
|
@@ -39,8 +57,9 @@ var textFormatToEchartsTextStyle = function (fmt) {
|
|
|
39
57
|
result.color = fmt.color;
|
|
40
58
|
if (fmt.fontFamily)
|
|
41
59
|
result.fontFamily = fmt.fontFamily;
|
|
42
|
-
if (typeof fmt.fontSize === "number")
|
|
43
|
-
result.fontSize = fmt.fontSize;
|
|
60
|
+
if (typeof fmt.fontSize === "number" && fmt.fontSize > 0) {
|
|
61
|
+
result.fontSize = (0, exports.pointsToPixels)(fmt.fontSize);
|
|
62
|
+
}
|
|
44
63
|
if (fmt.bold)
|
|
45
64
|
result.fontWeight = "bold";
|
|
46
65
|
if (fmt.italic)
|
|
@@ -97,14 +116,40 @@ var applyLegendOverrides = function (legend, opts) {
|
|
|
97
116
|
return next;
|
|
98
117
|
};
|
|
99
118
|
exports.applyLegendOverrides = applyLegendOverrides;
|
|
119
|
+
/** Excel's Format Axis → Display units: the divisor and the label it shows. */
|
|
120
|
+
exports.DISPLAY_UNITS = {
|
|
121
|
+
hundreds: { divisor: 1e2, label: "Hundreds" },
|
|
122
|
+
thousands: { divisor: 1e3, label: "Thousands" },
|
|
123
|
+
tenThousands: { divisor: 1e4, label: "10000" },
|
|
124
|
+
hundredThousands: { divisor: 1e5, label: "100000" },
|
|
125
|
+
millions: { divisor: 1e6, label: "Millions" },
|
|
126
|
+
tenMillions: { divisor: 1e7, label: "10000000" },
|
|
127
|
+
hundredMillions: { divisor: 1e8, label: "100000000" },
|
|
128
|
+
billions: { divisor: 1e9, label: "Billions" },
|
|
129
|
+
trillions: { divisor: 1e12, label: "Trillions" },
|
|
130
|
+
};
|
|
131
|
+
var positive = function (v) {
|
|
132
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
133
|
+
};
|
|
100
134
|
/**
|
|
101
135
|
* `numberFormatPattern` is the axis' RESOLVED format (explicit pattern or
|
|
102
136
|
* the linked source-cell format — see `resolveValueAxisNumberFormat`); it
|
|
103
|
-
* becomes the tick-label formatter.
|
|
137
|
+
* becomes the tick-label formatter. `placement` says which side of the plot
|
|
138
|
+
* the axis runs along (`x` horizontal, `y` vertical) for Excel's axis
|
|
139
|
+
* crossing; it defaults to `x` for a category axis and `y` for a value axis.
|
|
104
140
|
*/
|
|
105
|
-
var applyAxisOverrides = function (axis, opts, numberFormatPattern, locale) {
|
|
106
|
-
var _a, _b, _c, _d, _e;
|
|
107
|
-
var
|
|
141
|
+
var applyAxisOverrides = function (axis, opts, numberFormatPattern, locale, placement) {
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
143
|
+
var units = (opts === null || opts === void 0 ? void 0 : opts.displayUnits) ? exports.DISPLAY_UNITS[opts.displayUnits] : undefined;
|
|
144
|
+
var baseFormatter = (0, axis_number_format_1.valueAxisLabelFormatter)(numberFormatPattern, locale);
|
|
145
|
+
// Display units divide the tick labels: 25,000 on a "Thousands" axis reads 25.
|
|
146
|
+
var formatter = units
|
|
147
|
+
? function (value) {
|
|
148
|
+
return typeof value === "number"
|
|
149
|
+
? (baseFormatter !== null && baseFormatter !== void 0 ? baseFormatter : (function (v) { return (0, axis_number_format_1.formatAxisValue)(undefined, v, locale); }))(value / units.divisor)
|
|
150
|
+
: String(value !== null && value !== void 0 ? value : "");
|
|
151
|
+
}
|
|
152
|
+
: baseFormatter;
|
|
108
153
|
if (!opts && !formatter)
|
|
109
154
|
return axis;
|
|
110
155
|
var next = tslib_1.__assign({}, axis);
|
|
@@ -113,8 +158,11 @@ var applyAxisOverrides = function (axis, opts, numberFormatPattern, locale) {
|
|
|
113
158
|
}
|
|
114
159
|
if (!opts)
|
|
115
160
|
return next;
|
|
116
|
-
|
|
161
|
+
var isValueAxis = next.type !== "category";
|
|
162
|
+
if (opts.logarithmic) {
|
|
117
163
|
next.type = "log";
|
|
164
|
+
next.logBase = positive(opts.logBase) && opts.logBase >= 2 ? opts.logBase : 10;
|
|
165
|
+
}
|
|
118
166
|
if (opts.reverse)
|
|
119
167
|
next.inverse = true;
|
|
120
168
|
if (typeof opts.min === "number")
|
|
@@ -129,12 +177,62 @@ var applyAxisOverrides = function (axis, opts, numberFormatPattern, locale) {
|
|
|
129
177
|
if (opts.showMajorGridlines === true) {
|
|
130
178
|
next.splitLine = tslib_1.__assign(tslib_1.__assign({}, ((_c = next.splitLine) !== null && _c !== void 0 ? _c : {})), { show: true });
|
|
131
179
|
}
|
|
180
|
+
// Format Axis → Units (FT-08). A value axis' major unit is the tick
|
|
181
|
+
// interval; minor ticks / gridlines split it by major ÷ minor (Excel's
|
|
182
|
+
// automatic minor unit is a fifth of the major).
|
|
183
|
+
if (isValueAxis && positive(opts.majorUnit) && !opts.logarithmic) {
|
|
184
|
+
next.interval = opts.majorUnit;
|
|
185
|
+
}
|
|
186
|
+
var minorSplit = positive(opts.majorUnit) && positive(opts.minorUnit)
|
|
187
|
+
? Math.max(1, Math.round(opts.majorUnit / opts.minorUnit))
|
|
188
|
+
: 5;
|
|
189
|
+
var minorTicks = typeof opts.minorTickMark === "string" && opts.minorTickMark !== "none";
|
|
190
|
+
if (isValueAxis && (minorTicks || opts.showMinorGridlines)) {
|
|
191
|
+
next.minorTick = { show: minorTicks, splitNumber: minorSplit };
|
|
192
|
+
}
|
|
193
|
+
if (isValueAxis && opts.showMinorGridlines) {
|
|
194
|
+
next.minorSplitLine = { show: true, lineStyle: { color: "#F2F2F2" } };
|
|
195
|
+
}
|
|
196
|
+
// Format Axis → Tick Marks: none / inside / outside / cross.
|
|
197
|
+
if (opts.majorTickMark === "none") {
|
|
198
|
+
next.axisTick = tslib_1.__assign(tslib_1.__assign({}, ((_d = next.axisTick) !== null && _d !== void 0 ? _d : {})), { show: false });
|
|
199
|
+
}
|
|
200
|
+
else if (opts.majorTickMark === "in") {
|
|
201
|
+
next.axisTick = tslib_1.__assign(tslib_1.__assign({}, ((_e = next.axisTick) !== null && _e !== void 0 ? _e : {})), { show: true, inside: true });
|
|
202
|
+
}
|
|
203
|
+
else if (opts.majorTickMark === "cross") {
|
|
204
|
+
next.axisTick = tslib_1.__assign(tslib_1.__assign({}, ((_f = next.axisTick) !== null && _f !== void 0 ? _f : {})), { show: true, inside: false, length: 8 });
|
|
205
|
+
}
|
|
206
|
+
// Category axis "Interval between labels / tick marks": every Nth category.
|
|
207
|
+
if (!isValueAxis && positive(opts.tickLabelSkip)) {
|
|
208
|
+
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((_g = next.axisLabel) !== null && _g !== void 0 ? _g : {})), { interval: Math.round(opts.tickLabelSkip) - 1 });
|
|
209
|
+
}
|
|
210
|
+
if (!isValueAxis && positive(opts.tickMarkSkip)) {
|
|
211
|
+
next.axisTick = tslib_1.__assign(tslib_1.__assign({}, ((_h = next.axisTick) !== null && _h !== void 0 ? _h : {})), { interval: Math.round(opts.tickMarkSkip) - 1 });
|
|
212
|
+
}
|
|
213
|
+
// Where this axis crosses the perpendicular one (OOXML's `<c:crosses>` /
|
|
214
|
+
// `<c:crossesAt>` on this axis). echarts places an axis at the other's zero
|
|
215
|
+
// or at either plot edge, so a `crossesAt` other than 0 draws at the edge.
|
|
216
|
+
var side = placement !== null && placement !== void 0 ? placement : (isValueAxis ? "y" : "x");
|
|
217
|
+
if (opts.crosses === "max") {
|
|
218
|
+
next.position = side === "x" ? "top" : "right";
|
|
219
|
+
next.axisLine = tslib_1.__assign(tslib_1.__assign({}, ((_j = next.axisLine) !== null && _j !== void 0 ? _j : {})), { onZero: false });
|
|
220
|
+
}
|
|
221
|
+
else if (opts.crosses === "min" ||
|
|
222
|
+
(typeof opts.crossesAt === "number" && opts.crossesAt !== 0)) {
|
|
223
|
+
next.position = side === "x" ? "bottom" : "left";
|
|
224
|
+
next.axisLine = tslib_1.__assign(tslib_1.__assign({}, ((_k = next.axisLine) !== null && _k !== void 0 ? _k : {})), { onZero: false });
|
|
225
|
+
}
|
|
226
|
+
// The display-units label ("Thousands") rides with the axis title.
|
|
227
|
+
if (units && opts.showDisplayUnitsLabel !== false) {
|
|
228
|
+
next.name = next.name ? "".concat(next.name, " (").concat(units.label, ")") : units.label;
|
|
229
|
+
}
|
|
132
230
|
// Axis label text style (tick labels) + axis title font come from
|
|
133
231
|
// <c:txPr>. Without this echarts uses its default (~black on light).
|
|
134
232
|
var axisTextStyle = (0, exports.textFormatToEchartsTextStyle)(opts.textFormat);
|
|
135
233
|
if (axisTextStyle) {
|
|
136
|
-
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
137
|
-
next.nameTextStyle = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
234
|
+
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((_l = next.axisLabel) !== null && _l !== void 0 ? _l : {})), axisTextStyle);
|
|
235
|
+
next.nameTextStyle = tslib_1.__assign(tslib_1.__assign({}, ((_m = next.nameTextStyle) !== null && _m !== void 0 ? _m : {})), axisTextStyle);
|
|
138
236
|
}
|
|
139
237
|
return next;
|
|
140
238
|
};
|
|
@@ -153,6 +251,12 @@ joiner) {
|
|
|
153
251
|
if (joiner === void 0) { joiner = ": "; }
|
|
154
252
|
return function (params) {
|
|
155
253
|
var parts = [];
|
|
254
|
+
// Value From Cells (FT-08): the point's cell leads; resolved by the caller.
|
|
255
|
+
if (Array.isArray(opts.cellLabels)) {
|
|
256
|
+
var cell = opts.cellLabels[params.dataIndex];
|
|
257
|
+
if (cell !== undefined && cell !== null && cell !== "")
|
|
258
|
+
parts.push(String(cell));
|
|
259
|
+
}
|
|
156
260
|
if (opts.showSeriesName && params.seriesName)
|
|
157
261
|
parts.push(params.seriesName);
|
|
158
262
|
if (opts.showCategoryName && params.name)
|
|
@@ -168,7 +272,8 @@ joiner) {
|
|
|
168
272
|
!opts.showCategoryName &&
|
|
169
273
|
!opts.showPercent &&
|
|
170
274
|
!opts.showSeriesName &&
|
|
171
|
-
!opts.showBubbleSize
|
|
275
|
+
!opts.showBubbleSize &&
|
|
276
|
+
!Array.isArray(opts.cellLabels)
|
|
172
277
|
? true
|
|
173
278
|
: !!opts.showValue;
|
|
174
279
|
// A scatter / bubble point's value is its [x, y, size] tuple: the label's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA2UrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAoHnD,eAAO,MAAM,UAAU,GAAI,0PAmBxB,eAAe,sBAm8HjB,CAAC"}
|