source: node_modules/recharts/lib/util/YAxisUtils.js@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getCalculatedYAxisWidth = void 0;
7/**
8 * Calculates the width of the Y-axis based on the tick labels and the axis label.
9 * @param params - The parameters object.
10 * @param [params.ticks] - An array-like object of tick elements, each with a `getBoundingClientRect` method.
11 * @param [params.label] - The axis label element, with a `getBoundingClientRect` method.
12 * @param [params.labelGapWithTick=5] - The gap between the label and the tick.
13 * @param [params.tickSize=0] - The length of the tick line.
14 * @param [params.tickMargin=0] - The margin between the tick line and the tick text.
15 * @returns The calculated width of the Y-axis.
16 */
17var getCalculatedYAxisWidth = _ref => {
18 var {
19 ticks,
20 label,
21 labelGapWithTick = 5,
22 // Default gap between label and tick
23 tickSize = 0,
24 tickMargin = 0
25 } = _ref;
26 // find the max width of the tick labels
27 var maxTickWidth = 0;
28 if (ticks) {
29 Array.from(ticks).forEach(tickNode => {
30 if (tickNode) {
31 var bbox = tickNode.getBoundingClientRect();
32 if (bbox.width > maxTickWidth) {
33 maxTickWidth = bbox.width;
34 }
35 }
36 });
37
38 // calculate width of the axis label
39 var labelWidth = label ? label.getBoundingClientRect().width : 0;
40 var tickWidth = tickSize + tickMargin;
41
42 // calculate the updated width of the y-axis
43 var updatedYAxisWidth = maxTickWidth + tickWidth + labelWidth + (label ? labelGapWithTick : 0);
44 return Math.round(updatedYAxisWidth);
45 }
46 return 0;
47};
48exports.getCalculatedYAxisWidth = getCalculatedYAxisWidth;
Note: See TracBrowser for help on using the repository browser.