source: node_modules/recharts/lib/util/TickUtils.js

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

Added visualizations

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getAngledTickWidth = getAngledTickWidth;
7exports.getNumberIntervalTicks = getNumberIntervalTicks;
8exports.getTickBoundaries = getTickBoundaries;
9exports.isVisible = isVisible;
10var _CartesianUtils = require("./CartesianUtils");
11var _getEveryNth = require("./getEveryNth");
12function getAngledTickWidth(contentSize, unitSize, angle) {
13 var size = {
14 width: contentSize.width + unitSize.width,
15 height: contentSize.height + unitSize.height
16 };
17 return (0, _CartesianUtils.getAngledRectangleWidth)(size, angle);
18}
19function getTickBoundaries(viewBox, sign, sizeKey) {
20 var isWidth = sizeKey === 'width';
21 var {
22 x,
23 y,
24 width,
25 height
26 } = viewBox;
27 if (sign === 1) {
28 return {
29 start: isWidth ? x : y,
30 end: isWidth ? x + width : y + height
31 };
32 }
33 return {
34 start: isWidth ? x + width : y + height,
35 end: isWidth ? x : y
36 };
37}
38function isVisible(sign, tickPosition, getSize, start, end) {
39 /* Since getSize() is expensive (it reads the ticks' size from the DOM), we do this check first to avoid calculating
40 * the tick's size. */
41 if (sign * tickPosition < sign * start || sign * tickPosition > sign * end) {
42 return false;
43 }
44 var size = getSize();
45 return sign * (tickPosition - sign * size / 2 - start) >= 0 && sign * (tickPosition + sign * size / 2 - end) <= 0;
46}
47function getNumberIntervalTicks(ticks, interval) {
48 return (0, _getEveryNth.getEveryNth)(ticks, interval + 1);
49}
Note: See TracBrowser for help on using the repository browser.