@opendata-ai/openchart-engine 6.25.0 → 6.25.1
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/index.js +305 -264
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +38 -9
- package/src/layout/axes/ticks.ts +4 -3
- package/src/layout/dimensions.ts +54 -17
package/dist/index.js
CHANGED
|
@@ -1,16 +1,261 @@
|
|
|
1
1
|
// src/compile.ts
|
|
2
2
|
import {
|
|
3
|
+
AXIS_TITLE_TRAILING_PAD as AXIS_TITLE_TRAILING_PAD2,
|
|
3
4
|
adaptTheme as adaptTheme3,
|
|
5
|
+
BREAKPOINT_COMPACT_MAX as BREAKPOINT_COMPACT_MAX2,
|
|
4
6
|
computeLabelBounds,
|
|
5
7
|
estimateTextWidth as estimateTextWidth13,
|
|
6
8
|
generateAltText,
|
|
7
9
|
generateDataTable,
|
|
10
|
+
getAxisTitleOffset as getAxisTitleOffset2,
|
|
8
11
|
getBreakpoint,
|
|
9
12
|
getHeightClass,
|
|
10
13
|
getLayoutStrategy,
|
|
11
|
-
resolveTheme as resolveTheme3
|
|
14
|
+
resolveTheme as resolveTheme3,
|
|
15
|
+
TICK_LABEL_OFFSET
|
|
12
16
|
} from "@opendata-ai/openchart-core";
|
|
13
17
|
|
|
18
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatDecimal.js
|
|
19
|
+
function formatDecimal_default(x2) {
|
|
20
|
+
return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
|
|
21
|
+
}
|
|
22
|
+
function formatDecimalParts(x2, p) {
|
|
23
|
+
if (!isFinite(x2) || x2 === 0) return null;
|
|
24
|
+
var i = (x2 = p ? x2.toExponential(p - 1) : x2.toExponential()).indexOf("e"), coefficient = x2.slice(0, i);
|
|
25
|
+
return [
|
|
26
|
+
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
27
|
+
+x2.slice(i + 1)
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/exponent.js
|
|
32
|
+
function exponent_default(x2) {
|
|
33
|
+
return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatGroup.js
|
|
37
|
+
function formatGroup_default(grouping, thousands) {
|
|
38
|
+
return function(value2, width) {
|
|
39
|
+
var i = value2.length, t = [], j = 0, g = grouping[0], length = 0;
|
|
40
|
+
while (i > 0 && g > 0) {
|
|
41
|
+
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
42
|
+
t.push(value2.substring(i -= g, i + g));
|
|
43
|
+
if ((length += g + 1) > width) break;
|
|
44
|
+
g = grouping[j = (j + 1) % grouping.length];
|
|
45
|
+
}
|
|
46
|
+
return t.reverse().join(thousands);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatNumerals.js
|
|
51
|
+
function formatNumerals_default(numerals) {
|
|
52
|
+
return function(value2) {
|
|
53
|
+
return value2.replace(/[0-9]/g, function(i) {
|
|
54
|
+
return numerals[+i];
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatSpecifier.js
|
|
60
|
+
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
61
|
+
function formatSpecifier(specifier) {
|
|
62
|
+
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
63
|
+
var match;
|
|
64
|
+
return new FormatSpecifier({
|
|
65
|
+
fill: match[1],
|
|
66
|
+
align: match[2],
|
|
67
|
+
sign: match[3],
|
|
68
|
+
symbol: match[4],
|
|
69
|
+
zero: match[5],
|
|
70
|
+
width: match[6],
|
|
71
|
+
comma: match[7],
|
|
72
|
+
precision: match[8] && match[8].slice(1),
|
|
73
|
+
trim: match[9],
|
|
74
|
+
type: match[10]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
formatSpecifier.prototype = FormatSpecifier.prototype;
|
|
78
|
+
function FormatSpecifier(specifier) {
|
|
79
|
+
this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
|
|
80
|
+
this.align = specifier.align === void 0 ? ">" : specifier.align + "";
|
|
81
|
+
this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
|
|
82
|
+
this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
|
|
83
|
+
this.zero = !!specifier.zero;
|
|
84
|
+
this.width = specifier.width === void 0 ? void 0 : +specifier.width;
|
|
85
|
+
this.comma = !!specifier.comma;
|
|
86
|
+
this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
|
|
87
|
+
this.trim = !!specifier.trim;
|
|
88
|
+
this.type = specifier.type === void 0 ? "" : specifier.type + "";
|
|
89
|
+
}
|
|
90
|
+
FormatSpecifier.prototype.toString = function() {
|
|
91
|
+
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTrim.js
|
|
95
|
+
function formatTrim_default(s) {
|
|
96
|
+
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
97
|
+
switch (s[i]) {
|
|
98
|
+
case ".":
|
|
99
|
+
i0 = i1 = i;
|
|
100
|
+
break;
|
|
101
|
+
case "0":
|
|
102
|
+
if (i0 === 0) i0 = i;
|
|
103
|
+
i1 = i;
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
if (!+s[i]) break out;
|
|
107
|
+
if (i0 > 0) i0 = 0;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatPrefixAuto.js
|
|
115
|
+
var prefixExponent;
|
|
116
|
+
function formatPrefixAuto_default(x2, p) {
|
|
117
|
+
var d = formatDecimalParts(x2, p);
|
|
118
|
+
if (!d) return prefixExponent = void 0, x2.toPrecision(p);
|
|
119
|
+
var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length;
|
|
120
|
+
return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x2, Math.max(0, p + i - 1))[0];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatRounded.js
|
|
124
|
+
function formatRounded_default(x2, p) {
|
|
125
|
+
var d = formatDecimalParts(x2, p);
|
|
126
|
+
if (!d) return x2 + "";
|
|
127
|
+
var coefficient = d[0], exponent = d[1];
|
|
128
|
+
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTypes.js
|
|
132
|
+
var formatTypes_default = {
|
|
133
|
+
"%": (x2, p) => (x2 * 100).toFixed(p),
|
|
134
|
+
"b": (x2) => Math.round(x2).toString(2),
|
|
135
|
+
"c": (x2) => x2 + "",
|
|
136
|
+
"d": formatDecimal_default,
|
|
137
|
+
"e": (x2, p) => x2.toExponential(p),
|
|
138
|
+
"f": (x2, p) => x2.toFixed(p),
|
|
139
|
+
"g": (x2, p) => x2.toPrecision(p),
|
|
140
|
+
"o": (x2) => Math.round(x2).toString(8),
|
|
141
|
+
"p": (x2, p) => formatRounded_default(x2 * 100, p),
|
|
142
|
+
"r": formatRounded_default,
|
|
143
|
+
"s": formatPrefixAuto_default,
|
|
144
|
+
"X": (x2) => Math.round(x2).toString(16).toUpperCase(),
|
|
145
|
+
"x": (x2) => Math.round(x2).toString(16)
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/identity.js
|
|
149
|
+
function identity_default(x2) {
|
|
150
|
+
return x2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/locale.js
|
|
154
|
+
var map = Array.prototype.map;
|
|
155
|
+
var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
156
|
+
function locale_default(locale3) {
|
|
157
|
+
var group = locale3.grouping === void 0 || locale3.thousands === void 0 ? identity_default : formatGroup_default(map.call(locale3.grouping, Number), locale3.thousands + ""), currencyPrefix = locale3.currency === void 0 ? "" : locale3.currency[0] + "", currencySuffix = locale3.currency === void 0 ? "" : locale3.currency[1] + "", decimal = locale3.decimal === void 0 ? "." : locale3.decimal + "", numerals = locale3.numerals === void 0 ? identity_default : formatNumerals_default(map.call(locale3.numerals, String)), percent = locale3.percent === void 0 ? "%" : locale3.percent + "", minus = locale3.minus === void 0 ? "\u2212" : locale3.minus + "", nan = locale3.nan === void 0 ? "NaN" : locale3.nan + "";
|
|
158
|
+
function newFormat(specifier, options) {
|
|
159
|
+
specifier = formatSpecifier(specifier);
|
|
160
|
+
var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
|
|
161
|
+
if (type === "n") comma = true, type = "g";
|
|
162
|
+
else if (!formatTypes_default[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
|
|
163
|
+
if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
|
|
164
|
+
var prefix = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
|
|
165
|
+
var formatType = formatTypes_default[type], maybeSuffix = /[defgprs%]/.test(type);
|
|
166
|
+
precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
|
|
167
|
+
function format2(value2) {
|
|
168
|
+
var valuePrefix = prefix, valueSuffix = suffix, i, n, c;
|
|
169
|
+
if (type === "c") {
|
|
170
|
+
valueSuffix = formatType(value2) + valueSuffix;
|
|
171
|
+
value2 = "";
|
|
172
|
+
} else {
|
|
173
|
+
value2 = +value2;
|
|
174
|
+
var valueNegative = value2 < 0 || 1 / value2 < 0;
|
|
175
|
+
value2 = isNaN(value2) ? nan : formatType(Math.abs(value2), precision);
|
|
176
|
+
if (trim) value2 = formatTrim_default(value2);
|
|
177
|
+
if (valueNegative && +value2 === 0 && sign2 !== "+") valueNegative = false;
|
|
178
|
+
valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
|
|
179
|
+
valueSuffix = (type === "s" && !isNaN(value2) && prefixExponent !== void 0 ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
|
|
180
|
+
if (maybeSuffix) {
|
|
181
|
+
i = -1, n = value2.length;
|
|
182
|
+
while (++i < n) {
|
|
183
|
+
if (c = value2.charCodeAt(i), 48 > c || c > 57) {
|
|
184
|
+
valueSuffix = (c === 46 ? decimal + value2.slice(i + 1) : value2.slice(i)) + valueSuffix;
|
|
185
|
+
value2 = value2.slice(0, i);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (comma && !zero3) value2 = group(value2, Infinity);
|
|
192
|
+
var length = valuePrefix.length + value2.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
193
|
+
if (comma && zero3) value2 = group(padding + value2, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
194
|
+
switch (align) {
|
|
195
|
+
case "<":
|
|
196
|
+
value2 = valuePrefix + value2 + valueSuffix + padding;
|
|
197
|
+
break;
|
|
198
|
+
case "=":
|
|
199
|
+
value2 = valuePrefix + padding + value2 + valueSuffix;
|
|
200
|
+
break;
|
|
201
|
+
case "^":
|
|
202
|
+
value2 = padding.slice(0, length = padding.length >> 1) + valuePrefix + value2 + valueSuffix + padding.slice(length);
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
value2 = padding + valuePrefix + value2 + valueSuffix;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
return numerals(value2);
|
|
209
|
+
}
|
|
210
|
+
format2.toString = function() {
|
|
211
|
+
return specifier + "";
|
|
212
|
+
};
|
|
213
|
+
return format2;
|
|
214
|
+
}
|
|
215
|
+
function formatPrefix2(specifier, value2) {
|
|
216
|
+
var e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value2) / 3))) * 3, k = Math.pow(10, -e), f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier), { suffix: prefixes[8 + e / 3] });
|
|
217
|
+
return function(value3) {
|
|
218
|
+
return f(k * value3);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
format: newFormat,
|
|
223
|
+
formatPrefix: formatPrefix2
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/defaultLocale.js
|
|
228
|
+
var locale;
|
|
229
|
+
var format;
|
|
230
|
+
var formatPrefix;
|
|
231
|
+
defaultLocale({
|
|
232
|
+
thousands: ",",
|
|
233
|
+
grouping: [3],
|
|
234
|
+
currency: ["$", ""]
|
|
235
|
+
});
|
|
236
|
+
function defaultLocale(definition) {
|
|
237
|
+
locale = locale_default(definition);
|
|
238
|
+
format = locale.format;
|
|
239
|
+
formatPrefix = locale.formatPrefix;
|
|
240
|
+
return locale;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionFixed.js
|
|
244
|
+
function precisionFixed_default(step) {
|
|
245
|
+
return Math.max(0, -exponent_default(Math.abs(step)));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionPrefix.js
|
|
249
|
+
function precisionPrefix_default(step, value2) {
|
|
250
|
+
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value2) / 3))) * 3 - exponent_default(Math.abs(step)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionRound.js
|
|
254
|
+
function precisionRound_default(step, max4) {
|
|
255
|
+
step = Math.abs(step), max4 = Math.abs(max4) - step;
|
|
256
|
+
return Math.max(0, exponent_default(max4) - exponent_default(step)) + 1;
|
|
257
|
+
}
|
|
258
|
+
|
|
14
259
|
// ../../node_modules/.bun/d3-array@3.2.4/node_modules/d3-array/src/ascending.js
|
|
15
260
|
function ascending(a, b) {
|
|
16
261
|
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
@@ -1034,247 +1279,6 @@ function continuous() {
|
|
|
1034
1279
|
return transformer()(identity, identity);
|
|
1035
1280
|
}
|
|
1036
1281
|
|
|
1037
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatDecimal.js
|
|
1038
|
-
function formatDecimal_default(x2) {
|
|
1039
|
-
return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
|
|
1040
|
-
}
|
|
1041
|
-
function formatDecimalParts(x2, p) {
|
|
1042
|
-
if (!isFinite(x2) || x2 === 0) return null;
|
|
1043
|
-
var i = (x2 = p ? x2.toExponential(p - 1) : x2.toExponential()).indexOf("e"), coefficient = x2.slice(0, i);
|
|
1044
|
-
return [
|
|
1045
|
-
coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
|
|
1046
|
-
+x2.slice(i + 1)
|
|
1047
|
-
];
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/exponent.js
|
|
1051
|
-
function exponent_default(x2) {
|
|
1052
|
-
return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatGroup.js
|
|
1056
|
-
function formatGroup_default(grouping, thousands) {
|
|
1057
|
-
return function(value2, width) {
|
|
1058
|
-
var i = value2.length, t = [], j = 0, g = grouping[0], length = 0;
|
|
1059
|
-
while (i > 0 && g > 0) {
|
|
1060
|
-
if (length + g + 1 > width) g = Math.max(1, width - length);
|
|
1061
|
-
t.push(value2.substring(i -= g, i + g));
|
|
1062
|
-
if ((length += g + 1) > width) break;
|
|
1063
|
-
g = grouping[j = (j + 1) % grouping.length];
|
|
1064
|
-
}
|
|
1065
|
-
return t.reverse().join(thousands);
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatNumerals.js
|
|
1070
|
-
function formatNumerals_default(numerals) {
|
|
1071
|
-
return function(value2) {
|
|
1072
|
-
return value2.replace(/[0-9]/g, function(i) {
|
|
1073
|
-
return numerals[+i];
|
|
1074
|
-
});
|
|
1075
|
-
};
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatSpecifier.js
|
|
1079
|
-
var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
|
|
1080
|
-
function formatSpecifier(specifier) {
|
|
1081
|
-
if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
|
|
1082
|
-
var match;
|
|
1083
|
-
return new FormatSpecifier({
|
|
1084
|
-
fill: match[1],
|
|
1085
|
-
align: match[2],
|
|
1086
|
-
sign: match[3],
|
|
1087
|
-
symbol: match[4],
|
|
1088
|
-
zero: match[5],
|
|
1089
|
-
width: match[6],
|
|
1090
|
-
comma: match[7],
|
|
1091
|
-
precision: match[8] && match[8].slice(1),
|
|
1092
|
-
trim: match[9],
|
|
1093
|
-
type: match[10]
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
formatSpecifier.prototype = FormatSpecifier.prototype;
|
|
1097
|
-
function FormatSpecifier(specifier) {
|
|
1098
|
-
this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
|
|
1099
|
-
this.align = specifier.align === void 0 ? ">" : specifier.align + "";
|
|
1100
|
-
this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
|
|
1101
|
-
this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
|
|
1102
|
-
this.zero = !!specifier.zero;
|
|
1103
|
-
this.width = specifier.width === void 0 ? void 0 : +specifier.width;
|
|
1104
|
-
this.comma = !!specifier.comma;
|
|
1105
|
-
this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
|
|
1106
|
-
this.trim = !!specifier.trim;
|
|
1107
|
-
this.type = specifier.type === void 0 ? "" : specifier.type + "";
|
|
1108
|
-
}
|
|
1109
|
-
FormatSpecifier.prototype.toString = function() {
|
|
1110
|
-
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTrim.js
|
|
1114
|
-
function formatTrim_default(s) {
|
|
1115
|
-
out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
|
|
1116
|
-
switch (s[i]) {
|
|
1117
|
-
case ".":
|
|
1118
|
-
i0 = i1 = i;
|
|
1119
|
-
break;
|
|
1120
|
-
case "0":
|
|
1121
|
-
if (i0 === 0) i0 = i;
|
|
1122
|
-
i1 = i;
|
|
1123
|
-
break;
|
|
1124
|
-
default:
|
|
1125
|
-
if (!+s[i]) break out;
|
|
1126
|
-
if (i0 > 0) i0 = 0;
|
|
1127
|
-
break;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatPrefixAuto.js
|
|
1134
|
-
var prefixExponent;
|
|
1135
|
-
function formatPrefixAuto_default(x2, p) {
|
|
1136
|
-
var d = formatDecimalParts(x2, p);
|
|
1137
|
-
if (!d) return prefixExponent = void 0, x2.toPrecision(p);
|
|
1138
|
-
var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length;
|
|
1139
|
-
return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x2, Math.max(0, p + i - 1))[0];
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatRounded.js
|
|
1143
|
-
function formatRounded_default(x2, p) {
|
|
1144
|
-
var d = formatDecimalParts(x2, p);
|
|
1145
|
-
if (!d) return x2 + "";
|
|
1146
|
-
var coefficient = d[0], exponent = d[1];
|
|
1147
|
-
return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/formatTypes.js
|
|
1151
|
-
var formatTypes_default = {
|
|
1152
|
-
"%": (x2, p) => (x2 * 100).toFixed(p),
|
|
1153
|
-
"b": (x2) => Math.round(x2).toString(2),
|
|
1154
|
-
"c": (x2) => x2 + "",
|
|
1155
|
-
"d": formatDecimal_default,
|
|
1156
|
-
"e": (x2, p) => x2.toExponential(p),
|
|
1157
|
-
"f": (x2, p) => x2.toFixed(p),
|
|
1158
|
-
"g": (x2, p) => x2.toPrecision(p),
|
|
1159
|
-
"o": (x2) => Math.round(x2).toString(8),
|
|
1160
|
-
"p": (x2, p) => formatRounded_default(x2 * 100, p),
|
|
1161
|
-
"r": formatRounded_default,
|
|
1162
|
-
"s": formatPrefixAuto_default,
|
|
1163
|
-
"X": (x2) => Math.round(x2).toString(16).toUpperCase(),
|
|
1164
|
-
"x": (x2) => Math.round(x2).toString(16)
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/identity.js
|
|
1168
|
-
function identity_default(x2) {
|
|
1169
|
-
return x2;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/locale.js
|
|
1173
|
-
var map = Array.prototype.map;
|
|
1174
|
-
var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
1175
|
-
function locale_default(locale3) {
|
|
1176
|
-
var group = locale3.grouping === void 0 || locale3.thousands === void 0 ? identity_default : formatGroup_default(map.call(locale3.grouping, Number), locale3.thousands + ""), currencyPrefix = locale3.currency === void 0 ? "" : locale3.currency[0] + "", currencySuffix = locale3.currency === void 0 ? "" : locale3.currency[1] + "", decimal = locale3.decimal === void 0 ? "." : locale3.decimal + "", numerals = locale3.numerals === void 0 ? identity_default : formatNumerals_default(map.call(locale3.numerals, String)), percent = locale3.percent === void 0 ? "%" : locale3.percent + "", minus = locale3.minus === void 0 ? "\u2212" : locale3.minus + "", nan = locale3.nan === void 0 ? "NaN" : locale3.nan + "";
|
|
1177
|
-
function newFormat(specifier, options) {
|
|
1178
|
-
specifier = formatSpecifier(specifier);
|
|
1179
|
-
var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
|
|
1180
|
-
if (type === "n") comma = true, type = "g";
|
|
1181
|
-
else if (!formatTypes_default[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
|
|
1182
|
-
if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
|
|
1183
|
-
var prefix = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
|
|
1184
|
-
var formatType = formatTypes_default[type], maybeSuffix = /[defgprs%]/.test(type);
|
|
1185
|
-
precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
|
|
1186
|
-
function format2(value2) {
|
|
1187
|
-
var valuePrefix = prefix, valueSuffix = suffix, i, n, c;
|
|
1188
|
-
if (type === "c") {
|
|
1189
|
-
valueSuffix = formatType(value2) + valueSuffix;
|
|
1190
|
-
value2 = "";
|
|
1191
|
-
} else {
|
|
1192
|
-
value2 = +value2;
|
|
1193
|
-
var valueNegative = value2 < 0 || 1 / value2 < 0;
|
|
1194
|
-
value2 = isNaN(value2) ? nan : formatType(Math.abs(value2), precision);
|
|
1195
|
-
if (trim) value2 = formatTrim_default(value2);
|
|
1196
|
-
if (valueNegative && +value2 === 0 && sign2 !== "+") valueNegative = false;
|
|
1197
|
-
valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
|
|
1198
|
-
valueSuffix = (type === "s" && !isNaN(value2) && prefixExponent !== void 0 ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
|
|
1199
|
-
if (maybeSuffix) {
|
|
1200
|
-
i = -1, n = value2.length;
|
|
1201
|
-
while (++i < n) {
|
|
1202
|
-
if (c = value2.charCodeAt(i), 48 > c || c > 57) {
|
|
1203
|
-
valueSuffix = (c === 46 ? decimal + value2.slice(i + 1) : value2.slice(i)) + valueSuffix;
|
|
1204
|
-
value2 = value2.slice(0, i);
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
if (comma && !zero3) value2 = group(value2, Infinity);
|
|
1211
|
-
var length = valuePrefix.length + value2.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
|
|
1212
|
-
if (comma && zero3) value2 = group(padding + value2, padding.length ? width - valueSuffix.length : Infinity), padding = "";
|
|
1213
|
-
switch (align) {
|
|
1214
|
-
case "<":
|
|
1215
|
-
value2 = valuePrefix + value2 + valueSuffix + padding;
|
|
1216
|
-
break;
|
|
1217
|
-
case "=":
|
|
1218
|
-
value2 = valuePrefix + padding + value2 + valueSuffix;
|
|
1219
|
-
break;
|
|
1220
|
-
case "^":
|
|
1221
|
-
value2 = padding.slice(0, length = padding.length >> 1) + valuePrefix + value2 + valueSuffix + padding.slice(length);
|
|
1222
|
-
break;
|
|
1223
|
-
default:
|
|
1224
|
-
value2 = padding + valuePrefix + value2 + valueSuffix;
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
return numerals(value2);
|
|
1228
|
-
}
|
|
1229
|
-
format2.toString = function() {
|
|
1230
|
-
return specifier + "";
|
|
1231
|
-
};
|
|
1232
|
-
return format2;
|
|
1233
|
-
}
|
|
1234
|
-
function formatPrefix2(specifier, value2) {
|
|
1235
|
-
var e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value2) / 3))) * 3, k = Math.pow(10, -e), f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier), { suffix: prefixes[8 + e / 3] });
|
|
1236
|
-
return function(value3) {
|
|
1237
|
-
return f(k * value3);
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
return {
|
|
1241
|
-
format: newFormat,
|
|
1242
|
-
formatPrefix: formatPrefix2
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/defaultLocale.js
|
|
1247
|
-
var locale;
|
|
1248
|
-
var format;
|
|
1249
|
-
var formatPrefix;
|
|
1250
|
-
defaultLocale({
|
|
1251
|
-
thousands: ",",
|
|
1252
|
-
grouping: [3],
|
|
1253
|
-
currency: ["$", ""]
|
|
1254
|
-
});
|
|
1255
|
-
function defaultLocale(definition) {
|
|
1256
|
-
locale = locale_default(definition);
|
|
1257
|
-
format = locale.format;
|
|
1258
|
-
formatPrefix = locale.formatPrefix;
|
|
1259
|
-
return locale;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionFixed.js
|
|
1263
|
-
function precisionFixed_default(step) {
|
|
1264
|
-
return Math.max(0, -exponent_default(Math.abs(step)));
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionPrefix.js
|
|
1268
|
-
function precisionPrefix_default(step, value2) {
|
|
1269
|
-
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value2) / 3))) * 3 - exponent_default(Math.abs(step)));
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
// ../../node_modules/.bun/d3-format@3.1.2/node_modules/d3-format/src/precisionRound.js
|
|
1273
|
-
function precisionRound_default(step, max4) {
|
|
1274
|
-
step = Math.abs(step), max4 = Math.abs(max4) - step;
|
|
1275
|
-
return Math.max(0, exponent_default(max4) - exponent_default(step)) + 1;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
1282
|
// ../../node_modules/.bun/d3-scale@4.0.2/node_modules/d3-scale/src/tickFormat.js
|
|
1279
1283
|
function tickFormat(start, stop, count, specifier) {
|
|
1280
1284
|
var step = tickStep(start, stop, count), precision;
|
|
@@ -8017,7 +8021,8 @@ function categoricalTicks(resolvedScale, density) {
|
|
|
8017
8021
|
const explicitTickCount = resolvedScale.channel.axis?.tickCount;
|
|
8018
8022
|
const maxTicks = explicitTickCount ?? TICK_COUNTS[density];
|
|
8019
8023
|
let selectedValues = domain;
|
|
8020
|
-
|
|
8024
|
+
const shouldThinBand = resolvedScale.type === "band" && (explicitTickCount || density !== "full");
|
|
8025
|
+
if ((resolvedScale.type !== "band" || shouldThinBand) && domain.length > maxTicks) {
|
|
8021
8026
|
const step = Math.ceil(domain.length / maxTicks);
|
|
8022
8027
|
selectedValues = domain.filter((_, i) => i % step === 0);
|
|
8023
8028
|
}
|
|
@@ -8261,7 +8266,23 @@ function computeAxes(scales, chartArea, strategy, theme, measureText) {
|
|
|
8261
8266
|
}
|
|
8262
8267
|
|
|
8263
8268
|
// src/layout/dimensions.ts
|
|
8264
|
-
import {
|
|
8269
|
+
import {
|
|
8270
|
+
AXIS_TITLE_TRAILING_PAD,
|
|
8271
|
+
BREAKPOINT_COMPACT_MAX,
|
|
8272
|
+
computeChrome as computeChrome2,
|
|
8273
|
+
estimateTextWidth as estimateTextWidth9,
|
|
8274
|
+
getAxisTitleOffset,
|
|
8275
|
+
HPAD_COMPACT_FRACTION,
|
|
8276
|
+
HPAD_COMPACT_MIN,
|
|
8277
|
+
LABEL_GAP_COMPACT,
|
|
8278
|
+
LABEL_GAP_DEFAULT,
|
|
8279
|
+
MAX_LEFT_LABEL_FRACTION_COMPACT,
|
|
8280
|
+
MAX_LEFT_LABEL_FRACTION_DEFAULT,
|
|
8281
|
+
MAX_LEFT_LABEL_FRACTION_MEDIUM,
|
|
8282
|
+
MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
|
|
8283
|
+
NARROW_VIEWPORT_MAX,
|
|
8284
|
+
TOP_PAD_EXTRA_NARROW
|
|
8285
|
+
} from "@opendata-ai/openchart-core";
|
|
8265
8286
|
|
|
8266
8287
|
// src/legend/wrap.ts
|
|
8267
8288
|
import { COMPACT_WIDTH, estimateTextWidth as estimateTextWidth8 } from "@opendata-ai/openchart-core";
|
|
@@ -8327,6 +8348,7 @@ var MIN_CHART_HEIGHT = 40;
|
|
|
8327
8348
|
function computeDimensions(spec, options, legendLayout, theme, strategy, watermark = true) {
|
|
8328
8349
|
const { width, height } = options;
|
|
8329
8350
|
const padding = scalePadding(theme.spacing.padding, width, height);
|
|
8351
|
+
const hPad = width < BREAKPOINT_COMPACT_MAX ? Math.max(Math.round(padding * HPAD_COMPACT_FRACTION), HPAD_COMPACT_MIN) : padding;
|
|
8330
8352
|
const axisMargin = theme.spacing.axisMargin;
|
|
8331
8353
|
const chromeMode = strategy?.chromeMode ?? "full";
|
|
8332
8354
|
const chrome = computeChrome2(
|
|
@@ -8365,11 +8387,12 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8365
8387
|
xAxisHeight = hasXAxisLabel ? 48 : 26;
|
|
8366
8388
|
}
|
|
8367
8389
|
const topAxisGap = isRadial && chrome.topHeight === 0 ? 0 : axisMargin;
|
|
8390
|
+
const topPad = width < NARROW_VIEWPORT_MAX ? padding + TOP_PAD_EXTRA_NARROW : padding;
|
|
8368
8391
|
const margins = {
|
|
8369
|
-
top:
|
|
8370
|
-
right:
|
|
8392
|
+
top: topPad + chrome.topHeight + topAxisGap,
|
|
8393
|
+
right: hPad + (isRadial ? hPad : axisMargin),
|
|
8371
8394
|
bottom: padding + chrome.bottomHeight + xAxisHeight,
|
|
8372
|
-
left:
|
|
8395
|
+
left: hPad + (isRadial ? hPad : axisMargin)
|
|
8373
8396
|
};
|
|
8374
8397
|
const labelDensity = spec.labels.density;
|
|
8375
8398
|
const labelsHiddenByStrategy = strategy?.labelMode === "none";
|
|
@@ -8388,7 +8411,7 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8388
8411
|
}
|
|
8389
8412
|
}
|
|
8390
8413
|
if (maxLabelWidth > 0) {
|
|
8391
|
-
margins.right = Math.max(margins.right,
|
|
8414
|
+
margins.right = Math.max(margins.right, hPad + maxLabelWidth + 8);
|
|
8392
8415
|
}
|
|
8393
8416
|
}
|
|
8394
8417
|
}
|
|
@@ -8415,7 +8438,7 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8415
8438
|
);
|
|
8416
8439
|
const rightOverflow = Math.max(0, baseRightExtent + dx);
|
|
8417
8440
|
if (rightOverflow > 0) {
|
|
8418
|
-
margins.right = Math.max(margins.right,
|
|
8441
|
+
margins.right = Math.max(margins.right, hPad + rightOverflow + 12);
|
|
8419
8442
|
}
|
|
8420
8443
|
}
|
|
8421
8444
|
}
|
|
@@ -8431,10 +8454,10 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8431
8454
|
if (w > maxLabelWidth) maxLabelWidth = w;
|
|
8432
8455
|
}
|
|
8433
8456
|
if (maxLabelWidth > 0) {
|
|
8434
|
-
const labelGap = width <
|
|
8435
|
-
const maxLeftFraction = width <
|
|
8457
|
+
const labelGap = width < NARROW_VIEWPORT_MAX ? LABEL_GAP_COMPACT : LABEL_GAP_DEFAULT;
|
|
8458
|
+
const maxLeftFraction = width < BREAKPOINT_COMPACT_MAX ? MAX_LEFT_LABEL_FRACTION_COMPACT : width < MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX ? MAX_LEFT_LABEL_FRACTION_MEDIUM : MAX_LEFT_LABEL_FRACTION_DEFAULT;
|
|
8436
8459
|
const maxLeftReserved = Math.floor(width * maxLeftFraction);
|
|
8437
|
-
const reserved = Math.min(
|
|
8460
|
+
const reserved = Math.min(hPad + maxLabelWidth + labelGap, maxLeftReserved);
|
|
8438
8461
|
margins.left = Math.max(margins.left, reserved);
|
|
8439
8462
|
}
|
|
8440
8463
|
} else if (encoding.y.type === "quantitative" || encoding.y.type === "temporal") {
|
|
@@ -8468,16 +8491,18 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8468
8491
|
theme.fonts.sizes.axisTick,
|
|
8469
8492
|
theme.fonts.weights.normal
|
|
8470
8493
|
);
|
|
8471
|
-
margins.left = Math.max(margins.left,
|
|
8494
|
+
margins.left = Math.max(margins.left, hPad + labelWidth + 10);
|
|
8472
8495
|
}
|
|
8473
8496
|
}
|
|
8474
8497
|
const yAxis = encoding.y?.axis;
|
|
8475
8498
|
if (yAxis && (yAxis.title || yAxis.label) && !isRadial) {
|
|
8476
|
-
const
|
|
8477
|
-
|
|
8499
|
+
const axisTitleOffset = getAxisTitleOffset(width);
|
|
8500
|
+
const halfGlyph = Math.ceil(theme.fonts.sizes.body / 2);
|
|
8501
|
+
const rotatedLabelMargin = axisTitleOffset + halfGlyph + (width < BREAKPOINT_COMPACT_MAX ? 0 : AXIS_TITLE_TRAILING_PAD);
|
|
8502
|
+
margins.left = Math.max(margins.left, hPad + rotatedLabelMargin);
|
|
8478
8503
|
}
|
|
8479
8504
|
if (options.rightAxisReserve && options.rightAxisReserve > 0) {
|
|
8480
|
-
margins.right
|
|
8505
|
+
margins.right = Math.max(margins.right, hPad + options.rightAxisReserve);
|
|
8481
8506
|
}
|
|
8482
8507
|
if (legendLayout.entries.length > 0) {
|
|
8483
8508
|
const gap = legendGap(width);
|
|
@@ -8507,7 +8532,7 @@ function computeDimensions(spec, options, legendLayout, theme, strategy, waterma
|
|
|
8507
8532
|
watermark
|
|
8508
8533
|
);
|
|
8509
8534
|
const fallbackTopAxisGap = isRadial && fallbackChrome.topHeight === 0 ? 0 : axisMargin;
|
|
8510
|
-
const newTop =
|
|
8535
|
+
const newTop = topPad + fallbackChrome.topHeight + fallbackTopAxisGap;
|
|
8511
8536
|
const topDelta = margins.top - newTop;
|
|
8512
8537
|
const newBottom = padding + fallbackChrome.bottomHeight + xAxisHeight;
|
|
8513
8538
|
const bottomDelta = margins.bottom - newBottom;
|
|
@@ -11553,18 +11578,28 @@ function estimateYAxisLabelWidth(data, encoding, baseFontSize) {
|
|
|
11553
11578
|
}
|
|
11554
11579
|
return maxWidth > 0 ? maxWidth + 10 : 40;
|
|
11555
11580
|
}
|
|
11581
|
+
const yAxisFormat = encoding.y.axis?.format;
|
|
11556
11582
|
let maxAbsVal = 0;
|
|
11557
11583
|
for (const row of data) {
|
|
11558
11584
|
const v = Number(row[yField]);
|
|
11559
11585
|
if (Number.isFinite(v) && Math.abs(v) > maxAbsVal) maxAbsVal = Math.abs(v);
|
|
11560
11586
|
}
|
|
11561
11587
|
let sampleLabel;
|
|
11562
|
-
if (
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11588
|
+
if (yAxisFormat) {
|
|
11589
|
+
try {
|
|
11590
|
+
const fmt = format(yAxisFormat);
|
|
11591
|
+
sampleLabel = fmt(maxAbsVal);
|
|
11592
|
+
} catch {
|
|
11593
|
+
sampleLabel = String(maxAbsVal);
|
|
11594
|
+
}
|
|
11595
|
+
} else {
|
|
11596
|
+
if (maxAbsVal >= 1e9) sampleLabel = "1.5B";
|
|
11597
|
+
else if (maxAbsVal >= 1e6) sampleLabel = "1.5M";
|
|
11598
|
+
else if (maxAbsVal >= 1e3) sampleLabel = "1.5K";
|
|
11599
|
+
else if (maxAbsVal >= 100) sampleLabel = "100";
|
|
11600
|
+
else if (maxAbsVal >= 10) sampleLabel = "10";
|
|
11601
|
+
else sampleLabel = "0.0";
|
|
11602
|
+
}
|
|
11568
11603
|
const hasNeg = data.some((r) => Number(r[yField]) < 0);
|
|
11569
11604
|
const labelEst = (hasNeg ? "-" : "") + sampleLabel;
|
|
11570
11605
|
return estimateTextWidth13(labelEst, baseFontSize, 400) + 10;
|
|
@@ -11588,7 +11623,12 @@ function compileLayerIndependent(leaves, layerSpec, options) {
|
|
|
11588
11623
|
const axisFontSize = theme.fonts?.sizes?.axisTick ?? 11;
|
|
11589
11624
|
const rightAxisWidth = estimateYAxisLabelWidth(leaf1.data, leaf1.encoding, axisFontSize);
|
|
11590
11625
|
const hasRightAxisTitle = !!leaf1.encoding?.y?.axis?.title;
|
|
11591
|
-
const
|
|
11626
|
+
const tickExtent = TICK_LABEL_OFFSET + rightAxisWidth;
|
|
11627
|
+
const bodyFontSize = theme.fonts?.sizes?.body ?? 13;
|
|
11628
|
+
const axisTitleOffset = getAxisTitleOffset2(options.width);
|
|
11629
|
+
const halfGlyph = Math.ceil(bodyFontSize / 2);
|
|
11630
|
+
const titleExtent = hasRightAxisTitle ? axisTitleOffset + halfGlyph + (options.width < BREAKPOINT_COMPACT_MAX2 ? 0 : AXIS_TITLE_TRAILING_PAD2) : 0;
|
|
11631
|
+
const rightReserve = Math.max(tickExtent, titleExtent);
|
|
11592
11632
|
const optionsWithReserve = {
|
|
11593
11633
|
...options,
|
|
11594
11634
|
rightAxisReserve: rightReserve
|
|
@@ -11819,6 +11859,7 @@ function buildPrimarySpec(leaves, layerSpec) {
|
|
|
11819
11859
|
data: allData,
|
|
11820
11860
|
// Layer-level chrome overrides leaf chrome
|
|
11821
11861
|
chrome: layerSpec.chrome ?? leaves[0].chrome,
|
|
11862
|
+
annotations: layerSpec.annotations ?? leaves[0].annotations,
|
|
11822
11863
|
labels: layerSpec.labels ?? leaves[0].labels,
|
|
11823
11864
|
legend: layerSpec.legend ?? leaves[0].legend,
|
|
11824
11865
|
responsive: layerSpec.responsive ?? leaves[0].responsive,
|