• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

naver / billboard.js / 16137267914

08 Jul 2025 07:51AM UTC coverage: 86.941% (-7.2%) from 94.118%
16137267914

push

github

web-flow
chore(deps-dev): update dependency (#4014)

update dependencies to the latest versions

5668 of 7016 branches covered (80.79%)

Branch coverage included in aggregate %.

7487 of 8115 relevant lines covered (92.26%)

11761.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.98
/src/ChartInternal/internals/transform.ts
1
/**
2
 * Copyright (c) 2017 ~ present NAVER Corp.
3
 * billboard.js project is licensed under the MIT license
4
 */
5
import {$ARC, $AXIS} from "../../config/classes";
6
import {asHalfPixel} from "../../module/util";
7

8
type TranslateParam = "main" | "context" | "legend" | "x" | "y" | "y2" | "subX" | "arc" | "radar"
9
        | "polar";
10

11
export default {
12
        getTranslate(target: TranslateParam, index = 0): string {
64,995✔
13
                const $$ = this;
64,995✔
14
                const {config, state} = $$;
64,995✔
15
                const isRotated = config.axis_rotated;
64,995✔
16
                let padding = 0;
64,995✔
17
                let x;
18
                let y;
19

20
                if (index && /^(x|y2?)$/.test(target)) {
64,995!
21
                        padding = $$.getAxisSize(target) * index;
×
22
                }
23

24
                if (target === "main") {
64,995✔
25
                        x = asHalfPixel(state.margin.left);
11,565✔
26
                        y = asHalfPixel(state.margin.top);
11,565✔
27
                } else if (target === "context") {
53,430✔
28
                        x = asHalfPixel(state.margin2.left);
783✔
29
                        y = asHalfPixel(state.margin2.top);
783✔
30
                } else if (target === "legend") {
52,647✔
31
                        x = state.margin3.left;
11,445✔
32
                        y = state.margin3.top;
11,445✔
33
                } else if (target === "x") {
41,202✔
34
                        x = isRotated ? -padding : 0;
10,908✔
35
                        y = isRotated ? 0 : state.height + padding;
10,908✔
36
                } else if (target === "y") {
30,294✔
37
                        x = isRotated ? 0 : -padding;
10,908✔
38
                        y = isRotated ? state.height + padding : 0;
10,908✔
39
                } else if (target === "y2") {
19,386✔
40
                        x = isRotated ? 0 : state.width + padding;
9,087✔
41
                        y = isRotated ? -padding - 1 : 0;
9,087✔
42
                } else if (target === "subX") {
10,299✔
43
                        x = 0;
783✔
44
                        y = isRotated ? 0 : state.height2;
783✔
45
                } else if (target === "arc") {
9,516✔
46
                        x = state.arcWidth / 2;
9,411✔
47
                        y = state.arcHeight / 2;
9,411✔
48

49
                        if (config.arc_rangeText_values?.length) {
9,411✔
50
                                y += 5 + ($$.hasType("gauge") && config.title_text ? 10 : 0);
156!
51
                        }
52
                } else if (target === "polar") {
105!
53
                        x = state.arcWidth / 2;
×
54
                        y = state.arcHeight / 2;
×
55
                } else if (target === "radar") {
105!
56
                        const [width, height] = $$.getRadarSize();
105✔
57

58
                        x = state.width / 2 - width;
105✔
59
                        y = state.height / 2 - height;
105✔
60
                }
61

62
                return `translate(${x}, ${y})`;
64,995✔
63
        },
64

65
        transformMain(withTransition: boolean, transitions): void {
66
                const $$ = this;
8,844✔
67
                const {$el: {main}, $T} = $$;
8,844✔
68

69
                const xAxis = transitions?.axisX ?
8,844✔
70
                        transitions.axisX :
71
                        $T(main.select(`.${$AXIS.axisX}`), withTransition);
72

73
                const yAxis = transitions?.axisY ?
8,844✔
74
                        transitions.axisY :
75
                        $T(main.select(`.${$AXIS.axisY}`), withTransition);
76

77
                const y2Axis = transitions?.axisY2 ?
8,844✔
78
                        transitions.axisY2 :
79
                        $T(main.select(`.${$AXIS.axisY2}`), withTransition);
80

81
                $T(main, withTransition)
8,844✔
82
                        .attr("transform", $$.getTranslate("main"));
83

84
                xAxis.attr("transform", $$.getTranslate("x"));
8,844✔
85
                yAxis.attr("transform", $$.getTranslate("y"));
8,844✔
86
                y2Axis.attr("transform", $$.getTranslate("y2"));
8,844✔
87

88
                main.select(`.${$ARC.chartArcs}`)
8,844✔
89
                        .attr("transform", $$.getTranslate("arc"));
90
        },
91

92
        transformAll(withTransition: boolean, transitions): void {
93
                const $$ = this;
9,111✔
94
                const {config, state: {hasAxis, hasFunnel, hasTreemap}, $el} = $$;
9,111✔
95

96
                !hasFunnel && !hasTreemap && $$.transformMain(withTransition, transitions);
9,111✔
97

98
                hasAxis && config.subchart_show &&
9,111✔
99
                        $$.transformContext(withTransition, transitions);
100

101
                $el.legend && $$.transformLegend(withTransition);
9,111✔
102
        }
103
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc