UNPKG

1.48 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getAnglePoint = exports.getFactTitleConfig = void 0;
4var constant_1 = require("../constant");
5/**
6 * @ignore
7 * 获取 facet title 的最佳默认配置,防止
8 */
9function getFactTitleConfig(direction) {
10 if ([constant_1.DIRECTION.TOP, constant_1.DIRECTION.BOTTOM].includes(direction)) {
11 return {
12 offsetX: 0,
13 offsetY: direction === constant_1.DIRECTION.TOP ? -8 : 8,
14 style: {
15 textAlign: 'center',
16 textBaseline: direction === constant_1.DIRECTION.TOP ? 'bottom' : 'top',
17 },
18 };
19 }
20 if ([constant_1.DIRECTION.LEFT, constant_1.DIRECTION.RIGHT].includes(direction)) {
21 return {
22 offsetX: direction === constant_1.DIRECTION.LEFT ? -8 : 8,
23 offsetY: 0,
24 style: {
25 textAlign: direction === constant_1.DIRECTION.LEFT ? 'right' : 'left',
26 textBaseline: 'middle',
27 rotate: Math.PI / 2,
28 },
29 };
30 }
31 return {};
32}
33exports.getFactTitleConfig = getFactTitleConfig;
34/**
35 * @ignore
36 * 根据角度,获取 ○ 上的点
37 * @param center
38 * @param r
39 * @param angle
40 */
41function getAnglePoint(center, r, angle) {
42 return {
43 x: center.x + r * Math.cos(angle),
44 y: center.y + r * Math.sin(angle),
45 };
46}
47exports.getAnglePoint = getAnglePoint;
48//# sourceMappingURL=facet.js.map
\No newline at end of file