victory-core 36.6.10 → 36.6.12
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/victory-core.js +8 -6
- package/dist/victory-core.min.js +1 -1
- package/es/victory-util/textsize.js +8 -6
- package/lib/victory-util/textsize.js +8 -6
- package/package.json +2 -2
- package/src/victory-util/textsize.ts +16 -5
|
@@ -280,6 +280,10 @@ var _approximateDimensionsInternal = function (text, style) {
|
|
|
280
280
|
var _getMeasurementContainer = _memoize(function () {
|
|
281
281
|
var element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
282
282
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
283
|
+
element.setAttribute("width", "300");
|
|
284
|
+
element.setAttribute("height", "300");
|
|
285
|
+
element.setAttribute("viewBox", "0 0 300 300");
|
|
286
|
+
element.setAttribute("aria-hidden", "true");
|
|
283
287
|
var containerElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
284
288
|
element.appendChild(containerElement);
|
|
285
289
|
element.style.position = "fixed";
|
|
@@ -314,7 +318,6 @@ var _measureDimensionsInternal = _memoize(function (text, style) {
|
|
|
314
318
|
var params = _prepareParams(style, i);
|
|
315
319
|
|
|
316
320
|
textElement.style.fontFamily = params.fontFamily;
|
|
317
|
-
textElement.style.transform = "rotate(".concat(params.angle, ")");
|
|
318
321
|
textElement.style.fontSize = "".concat(params.fontSize, "px");
|
|
319
322
|
textElement.style.lineHeight = params.lineHeight;
|
|
320
323
|
textElement.style.fontFamily = params.fontFamily;
|
|
@@ -322,18 +325,17 @@ var _measureDimensionsInternal = _memoize(function (text, style) {
|
|
|
322
325
|
textElement.textContent = line;
|
|
323
326
|
textElement.setAttribute("x", "0");
|
|
324
327
|
textElement.setAttribute("y", "".concat(heightAcc));
|
|
325
|
-
heightAcc += params.lineHeight * params.fontSize;
|
|
326
328
|
containerElement.appendChild(textElement);
|
|
329
|
+
heightAcc += params.lineHeight * textElement.getBoundingClientRect().height;
|
|
327
330
|
}
|
|
328
331
|
|
|
329
332
|
var _containerElement$get = containerElement.getBoundingClientRect(),
|
|
330
|
-
width = _containerElement$get.width
|
|
331
|
-
height = _containerElement$get.height;
|
|
333
|
+
width = _containerElement$get.width;
|
|
332
334
|
|
|
333
335
|
containerElement.innerHTML = "";
|
|
334
336
|
return {
|
|
335
|
-
width: width,
|
|
336
|
-
height:
|
|
337
|
+
width: style !== null && style !== void 0 && style.angle ? _getSizeWithRotate(width, heightAcc, style === null || style === void 0 ? void 0 : style.angle) : width,
|
|
338
|
+
height: style !== null && style !== void 0 && style.angle ? _getSizeWithRotate(heightAcc, width, style === null || style === void 0 ? void 0 : style.angle) : heightAcc
|
|
337
339
|
};
|
|
338
340
|
}, function (text, style) {
|
|
339
341
|
var totalText = Array.isArray(text) ? text.join() : text;
|
|
@@ -291,6 +291,10 @@ var _approximateDimensionsInternal = function (text, style) {
|
|
|
291
291
|
var _getMeasurementContainer = (0, _memoize2.default)(function () {
|
|
292
292
|
var element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
293
293
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
294
|
+
element.setAttribute("width", "300");
|
|
295
|
+
element.setAttribute("height", "300");
|
|
296
|
+
element.setAttribute("viewBox", "0 0 300 300");
|
|
297
|
+
element.setAttribute("aria-hidden", "true");
|
|
294
298
|
var containerElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
295
299
|
element.appendChild(containerElement);
|
|
296
300
|
element.style.position = "fixed";
|
|
@@ -325,7 +329,6 @@ var _measureDimensionsInternal = (0, _memoize2.default)(function (text, style) {
|
|
|
325
329
|
var params = _prepareParams(style, i);
|
|
326
330
|
|
|
327
331
|
textElement.style.fontFamily = params.fontFamily;
|
|
328
|
-
textElement.style.transform = "rotate(".concat(params.angle, ")");
|
|
329
332
|
textElement.style.fontSize = "".concat(params.fontSize, "px");
|
|
330
333
|
textElement.style.lineHeight = params.lineHeight;
|
|
331
334
|
textElement.style.fontFamily = params.fontFamily;
|
|
@@ -333,18 +336,17 @@ var _measureDimensionsInternal = (0, _memoize2.default)(function (text, style) {
|
|
|
333
336
|
textElement.textContent = line;
|
|
334
337
|
textElement.setAttribute("x", "0");
|
|
335
338
|
textElement.setAttribute("y", "".concat(heightAcc));
|
|
336
|
-
heightAcc += params.lineHeight * params.fontSize;
|
|
337
339
|
containerElement.appendChild(textElement);
|
|
340
|
+
heightAcc += params.lineHeight * textElement.getBoundingClientRect().height;
|
|
338
341
|
}
|
|
339
342
|
|
|
340
343
|
var _containerElement$get = containerElement.getBoundingClientRect(),
|
|
341
|
-
width = _containerElement$get.width
|
|
342
|
-
height = _containerElement$get.height;
|
|
344
|
+
width = _containerElement$get.width;
|
|
343
345
|
|
|
344
346
|
containerElement.innerHTML = "";
|
|
345
347
|
return {
|
|
346
|
-
width: width,
|
|
347
|
-
height:
|
|
348
|
+
width: style !== null && style !== void 0 && style.angle ? _getSizeWithRotate(width, heightAcc, style === null || style === void 0 ? void 0 : style.angle) : width,
|
|
349
|
+
height: style !== null && style !== void 0 && style.angle ? _getSizeWithRotate(heightAcc, width, style === null || style === void 0 ? void 0 : style.angle) : heightAcc
|
|
348
350
|
};
|
|
349
351
|
}, function (text, style) {
|
|
350
352
|
var totalText = Array.isArray(text) ? text.join() : text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.6.
|
|
3
|
+
"version": "36.6.12",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"prop-types": "^15.8.1",
|
|
25
25
|
"react-fast-compare": "^3.2.0",
|
|
26
|
-
"victory-vendor": "^36.6.
|
|
26
|
+
"victory-vendor": "^36.6.12"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.6.0"
|
|
@@ -267,6 +267,10 @@ const _approximateDimensionsInternal = (
|
|
|
267
267
|
const _getMeasurementContainer = memoize(() => {
|
|
268
268
|
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
269
269
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
270
|
+
element.setAttribute("width", "300");
|
|
271
|
+
element.setAttribute("height", "300");
|
|
272
|
+
element.setAttribute("viewBox", "0 0 300 300");
|
|
273
|
+
element.setAttribute("aria-hidden", "true");
|
|
270
274
|
|
|
271
275
|
const containerElement = document.createElementNS(
|
|
272
276
|
"http://www.w3.org/2000/svg",
|
|
@@ -304,7 +308,6 @@ const _measureDimensionsInternal = memoize(
|
|
|
304
308
|
);
|
|
305
309
|
const params = _prepareParams(style, i);
|
|
306
310
|
textElement.style.fontFamily = params.fontFamily;
|
|
307
|
-
textElement.style.transform = `rotate(${params.angle})`;
|
|
308
311
|
textElement.style.fontSize = `${params.fontSize}px`;
|
|
309
312
|
textElement.style.lineHeight = params.lineHeight;
|
|
310
313
|
textElement.style.fontFamily = params.fontFamily;
|
|
@@ -312,16 +315,24 @@ const _measureDimensionsInternal = memoize(
|
|
|
312
315
|
textElement.textContent = line;
|
|
313
316
|
textElement.setAttribute("x", "0");
|
|
314
317
|
textElement.setAttribute("y", `${heightAcc}`);
|
|
315
|
-
heightAcc += params.lineHeight * params.fontSize;
|
|
316
|
-
|
|
317
318
|
containerElement.appendChild(textElement);
|
|
319
|
+
|
|
320
|
+
heightAcc +=
|
|
321
|
+
params.lineHeight * textElement.getBoundingClientRect().height;
|
|
318
322
|
}
|
|
319
323
|
|
|
320
|
-
const { width
|
|
324
|
+
const { width } = containerElement.getBoundingClientRect();
|
|
321
325
|
|
|
322
326
|
containerElement.innerHTML = "";
|
|
323
327
|
|
|
324
|
-
return {
|
|
328
|
+
return {
|
|
329
|
+
width: style?.angle
|
|
330
|
+
? _getSizeWithRotate(width, heightAcc, style?.angle)
|
|
331
|
+
: width,
|
|
332
|
+
height: style?.angle
|
|
333
|
+
? _getSizeWithRotate(heightAcc, width, style?.angle)
|
|
334
|
+
: heightAcc,
|
|
335
|
+
};
|
|
325
336
|
},
|
|
326
337
|
(text, style) => {
|
|
327
338
|
const totalText = Array.isArray(text) ? text.join() : text;
|