@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":"overrides.d.ts","sourceRoot":"","sources":["../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AO,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"}
|
|
@@ -13,12 +13,24 @@ import { formatAxisValue, valueAxisLabelFormatter } from "./axis-number-format";
|
|
|
13
13
|
* Underline / strikethrough have no canvas text decoration in echarts and
|
|
14
14
|
* are not drawn.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* `ChartTextFormat.fontSize` is in points (OOXML `sz` / 100, the editor's
|
|
18
|
+
* Size field); echarts draws pixels. 9 pt → 12 px, 14 pt → 18.67 px.
|
|
19
|
+
*/
|
|
20
|
+
export const pointsToPixels = (points) => Math.round(((points * 4) / 3) * 100) / 100;
|
|
21
|
+
/** An authored point size as pixels, or `fallbackPx` when none is set. */
|
|
22
|
+
export const fontSizePx = (points, fallbackPx) => typeof points === "number" && points > 0 ? pointsToPixels(points) : fallbackPx;
|
|
23
|
+
/**
|
|
24
|
+
* Excel's chart text defaults (Office 2013+ chart styles): the theme's body
|
|
25
|
+
* (minor) font, 9 pt in Text 1 at 65% (#595959 on the light theme), and a
|
|
26
|
+
* 14 pt regular title (RD-24).
|
|
27
|
+
*/
|
|
28
|
+
export const CHART_TEXT_PX = pointsToPixels(9);
|
|
29
|
+
export const CHART_TITLE_PX = pointsToPixels(14);
|
|
16
30
|
export const themedTextStyle = (fmt, defaults) => ({
|
|
17
31
|
color: fmt?.color ?? defaults.color,
|
|
18
32
|
fontFamily: fmt?.fontFamily ?? defaults.fontFamily ?? "sans-serif",
|
|
19
|
-
fontSize:
|
|
20
|
-
? fmt.fontSize
|
|
21
|
-
: defaults.fontSize,
|
|
33
|
+
fontSize: fontSizePx(fmt?.fontSize, defaults.fontSize),
|
|
22
34
|
fontWeight: (fmt ? (fmt.bold ? "bold" : "normal") : defaults.fontWeight ?? "normal"),
|
|
23
35
|
fontStyle: (fmt?.italic ? "italic" : "normal"),
|
|
24
36
|
});
|
|
@@ -31,8 +43,9 @@ export const textFormatToEchartsTextStyle = (fmt) => {
|
|
|
31
43
|
result.color = fmt.color;
|
|
32
44
|
if (fmt.fontFamily)
|
|
33
45
|
result.fontFamily = fmt.fontFamily;
|
|
34
|
-
if (typeof fmt.fontSize === "number")
|
|
35
|
-
result.fontSize = fmt.fontSize;
|
|
46
|
+
if (typeof fmt.fontSize === "number" && fmt.fontSize > 0) {
|
|
47
|
+
result.fontSize = pointsToPixels(fmt.fontSize);
|
|
48
|
+
}
|
|
36
49
|
if (fmt.bold)
|
|
37
50
|
result.fontWeight = "bold";
|
|
38
51
|
if (fmt.italic)
|
|
@@ -86,13 +99,35 @@ export const applyLegendOverrides = (legend, opts) => {
|
|
|
86
99
|
}
|
|
87
100
|
return next;
|
|
88
101
|
};
|
|
102
|
+
/** Excel's Format Axis → Display units: the divisor and the label it shows. */
|
|
103
|
+
export const DISPLAY_UNITS = {
|
|
104
|
+
hundreds: { divisor: 1e2, label: "Hundreds" },
|
|
105
|
+
thousands: { divisor: 1e3, label: "Thousands" },
|
|
106
|
+
tenThousands: { divisor: 1e4, label: "10000" },
|
|
107
|
+
hundredThousands: { divisor: 1e5, label: "100000" },
|
|
108
|
+
millions: { divisor: 1e6, label: "Millions" },
|
|
109
|
+
tenMillions: { divisor: 1e7, label: "10000000" },
|
|
110
|
+
hundredMillions: { divisor: 1e8, label: "100000000" },
|
|
111
|
+
billions: { divisor: 1e9, label: "Billions" },
|
|
112
|
+
trillions: { divisor: 1e12, label: "Trillions" },
|
|
113
|
+
};
|
|
114
|
+
const positive = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
89
115
|
/**
|
|
90
116
|
* `numberFormatPattern` is the axis' RESOLVED format (explicit pattern or
|
|
91
117
|
* the linked source-cell format — see `resolveValueAxisNumberFormat`); it
|
|
92
|
-
* becomes the tick-label formatter.
|
|
118
|
+
* becomes the tick-label formatter. `placement` says which side of the plot
|
|
119
|
+
* the axis runs along (`x` horizontal, `y` vertical) for Excel's axis
|
|
120
|
+
* crossing; it defaults to `x` for a category axis and `y` for a value axis.
|
|
93
121
|
*/
|
|
94
|
-
export const applyAxisOverrides = (axis, opts, numberFormatPattern, locale) => {
|
|
95
|
-
const
|
|
122
|
+
export const applyAxisOverrides = (axis, opts, numberFormatPattern, locale, placement) => {
|
|
123
|
+
const units = opts?.displayUnits ? DISPLAY_UNITS[opts.displayUnits] : undefined;
|
|
124
|
+
const baseFormatter = valueAxisLabelFormatter(numberFormatPattern, locale);
|
|
125
|
+
// Display units divide the tick labels: 25,000 on a "Thousands" axis reads 25.
|
|
126
|
+
const formatter = units
|
|
127
|
+
? (value) => typeof value === "number"
|
|
128
|
+
? (baseFormatter ?? ((v) => formatAxisValue(undefined, v, locale)))(value / units.divisor)
|
|
129
|
+
: String(value ?? "")
|
|
130
|
+
: baseFormatter;
|
|
96
131
|
if (!opts && !formatter)
|
|
97
132
|
return axis;
|
|
98
133
|
const next = { ...axis };
|
|
@@ -101,8 +136,11 @@ export const applyAxisOverrides = (axis, opts, numberFormatPattern, locale) => {
|
|
|
101
136
|
}
|
|
102
137
|
if (!opts)
|
|
103
138
|
return next;
|
|
104
|
-
|
|
139
|
+
const isValueAxis = next.type !== "category";
|
|
140
|
+
if (opts.logarithmic) {
|
|
105
141
|
next.type = "log";
|
|
142
|
+
next.logBase = positive(opts.logBase) && opts.logBase >= 2 ? opts.logBase : 10;
|
|
143
|
+
}
|
|
106
144
|
if (opts.reverse)
|
|
107
145
|
next.inverse = true;
|
|
108
146
|
if (typeof opts.min === "number")
|
|
@@ -117,6 +155,62 @@ export const applyAxisOverrides = (axis, opts, numberFormatPattern, locale) => {
|
|
|
117
155
|
if (opts.showMajorGridlines === true) {
|
|
118
156
|
next.splitLine = { ...(next.splitLine ?? {}), show: true };
|
|
119
157
|
}
|
|
158
|
+
// Format Axis → Units (FT-08). A value axis' major unit is the tick
|
|
159
|
+
// interval; minor ticks / gridlines split it by major ÷ minor (Excel's
|
|
160
|
+
// automatic minor unit is a fifth of the major).
|
|
161
|
+
if (isValueAxis && positive(opts.majorUnit) && !opts.logarithmic) {
|
|
162
|
+
next.interval = opts.majorUnit;
|
|
163
|
+
}
|
|
164
|
+
const minorSplit = positive(opts.majorUnit) && positive(opts.minorUnit)
|
|
165
|
+
? Math.max(1, Math.round(opts.majorUnit / opts.minorUnit))
|
|
166
|
+
: 5;
|
|
167
|
+
const minorTicks = typeof opts.minorTickMark === "string" && opts.minorTickMark !== "none";
|
|
168
|
+
if (isValueAxis && (minorTicks || opts.showMinorGridlines)) {
|
|
169
|
+
next.minorTick = { show: minorTicks, splitNumber: minorSplit };
|
|
170
|
+
}
|
|
171
|
+
if (isValueAxis && opts.showMinorGridlines) {
|
|
172
|
+
next.minorSplitLine = { show: true, lineStyle: { color: "#F2F2F2" } };
|
|
173
|
+
}
|
|
174
|
+
// Format Axis → Tick Marks: none / inside / outside / cross.
|
|
175
|
+
if (opts.majorTickMark === "none") {
|
|
176
|
+
next.axisTick = { ...(next.axisTick ?? {}), show: false };
|
|
177
|
+
}
|
|
178
|
+
else if (opts.majorTickMark === "in") {
|
|
179
|
+
next.axisTick = { ...(next.axisTick ?? {}), show: true, inside: true };
|
|
180
|
+
}
|
|
181
|
+
else if (opts.majorTickMark === "cross") {
|
|
182
|
+
next.axisTick = { ...(next.axisTick ?? {}), show: true, inside: false, length: 8 };
|
|
183
|
+
}
|
|
184
|
+
// Category axis "Interval between labels / tick marks": every Nth category.
|
|
185
|
+
if (!isValueAxis && positive(opts.tickLabelSkip)) {
|
|
186
|
+
next.axisLabel = {
|
|
187
|
+
...(next.axisLabel ?? {}),
|
|
188
|
+
interval: Math.round(opts.tickLabelSkip) - 1,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (!isValueAxis && positive(opts.tickMarkSkip)) {
|
|
192
|
+
next.axisTick = {
|
|
193
|
+
...(next.axisTick ?? {}),
|
|
194
|
+
interval: Math.round(opts.tickMarkSkip) - 1,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
// Where this axis crosses the perpendicular one (OOXML's `<c:crosses>` /
|
|
198
|
+
// `<c:crossesAt>` on this axis). echarts places an axis at the other's zero
|
|
199
|
+
// or at either plot edge, so a `crossesAt` other than 0 draws at the edge.
|
|
200
|
+
const side = placement ?? (isValueAxis ? "y" : "x");
|
|
201
|
+
if (opts.crosses === "max") {
|
|
202
|
+
next.position = side === "x" ? "top" : "right";
|
|
203
|
+
next.axisLine = { ...(next.axisLine ?? {}), onZero: false };
|
|
204
|
+
}
|
|
205
|
+
else if (opts.crosses === "min" ||
|
|
206
|
+
(typeof opts.crossesAt === "number" && opts.crossesAt !== 0)) {
|
|
207
|
+
next.position = side === "x" ? "bottom" : "left";
|
|
208
|
+
next.axisLine = { ...(next.axisLine ?? {}), onZero: false };
|
|
209
|
+
}
|
|
210
|
+
// The display-units label ("Thousands") rides with the axis title.
|
|
211
|
+
if (units && opts.showDisplayUnitsLabel !== false) {
|
|
212
|
+
next.name = next.name ? `${next.name} (${units.label})` : units.label;
|
|
213
|
+
}
|
|
120
214
|
// Axis label text style (tick labels) + axis title font come from
|
|
121
215
|
// <c:txPr>. Without this echarts uses its default (~black on light).
|
|
122
216
|
const axisTextStyle = textFormatToEchartsTextStyle(opts.textFormat);
|
|
@@ -138,6 +232,12 @@ export const dataLabelFormatter = (opts, locale,
|
|
|
138
232
|
// A treemap block stacks the parts (name, value) on their own lines.
|
|
139
233
|
joiner = ": ") => (params) => {
|
|
140
234
|
const parts = [];
|
|
235
|
+
// Value From Cells (FT-08): the point's cell leads; resolved by the caller.
|
|
236
|
+
if (Array.isArray(opts.cellLabels)) {
|
|
237
|
+
const cell = opts.cellLabels[params.dataIndex];
|
|
238
|
+
if (cell !== undefined && cell !== null && cell !== "")
|
|
239
|
+
parts.push(String(cell));
|
|
240
|
+
}
|
|
141
241
|
if (opts.showSeriesName && params.seriesName)
|
|
142
242
|
parts.push(params.seriesName);
|
|
143
243
|
if (opts.showCategoryName && params.name)
|
|
@@ -153,7 +253,8 @@ joiner = ": ") => (params) => {
|
|
|
153
253
|
!opts.showCategoryName &&
|
|
154
254
|
!opts.showPercent &&
|
|
155
255
|
!opts.showSeriesName &&
|
|
156
|
-
!opts.showBubbleSize
|
|
256
|
+
!opts.showBubbleSize &&
|
|
257
|
+
!Array.isArray(opts.cellLabels)
|
|
157
258
|
? true
|
|
158
259
|
: !!opts.showValue;
|
|
159
260
|
// A scatter / bubble point's value is its [x, y, size] tuple: the label's
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/charts",
|
|
3
|
-
"version": "28.1.
|
|
3
|
+
"version": "28.1.19",
|
|
4
4
|
"author": "Vinay M",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@rowsncolumns/calculator": ">=7.3.1",
|
|
70
|
-
"@rowsncolumns/common-types": ">=5.
|
|
71
|
-
"@rowsncolumns/grid": ">=13.
|
|
70
|
+
"@rowsncolumns/common-types": ">=5.4.0",
|
|
71
|
+
"@rowsncolumns/grid": ">=13.4.0",
|
|
72
72
|
"@rowsncolumns/icons": ">=7.2.33",
|
|
73
|
-
"@rowsncolumns/spreadsheet": ">=10.
|
|
74
|
-
"@rowsncolumns/spreadsheet-state": ">=29.
|
|
73
|
+
"@rowsncolumns/spreadsheet": ">=10.8.0",
|
|
74
|
+
"@rowsncolumns/spreadsheet-state": ">=29.4.0",
|
|
75
75
|
"@rowsncolumns/toolkit": ">=24.5.14",
|
|
76
|
-
"@rowsncolumns/ui": ">=16.0
|
|
77
|
-
"@rowsncolumns/utils": ">=9.
|
|
76
|
+
"@rowsncolumns/ui": ">=16.2.0",
|
|
77
|
+
"@rowsncolumns/utils": ">=9.7.0",
|
|
78
78
|
"@types/react-plotly.js": "^2.6.3",
|
|
79
79
|
"echarts": "^5.6.0",
|
|
80
80
|
"formik": "^2.4.6",
|