@@ -23,8 +23,8 @@ const getOrCreateTooltip = chart => {
23
23
const table = document . createElement ( 'table' )
24
24
table . style . margin = '0px'
25
25
26
- tooltipEl . appendChild ( table )
27
- chart . canvas . parentNode . appendChild ( tooltipEl )
26
+ tooltipEl . append ( table )
27
+ chart . canvas . parentNode . append ( tooltipEl )
28
28
}
29
29
30
30
return tooltipEl
@@ -49,7 +49,7 @@ const customTooltips = context => {
49
49
const tableHead = document . createElement ( 'thead' )
50
50
tableHead . classList . add ( ClassName . TOOLTIP_HEADER )
51
51
52
- titleLines . forEach ( title => {
52
+ for ( const title of titleLines ) {
53
53
const tr = document . createElement ( 'tr' )
54
54
tr . style . borderWidth = 0
55
55
tr . classList . add ( ClassName . TOOLTIP_HEADER_ITEM )
@@ -58,15 +58,15 @@ const customTooltips = context => {
58
58
th . style . borderWidth = 0
59
59
const text = document . createTextNode ( title )
60
60
61
- th . appendChild ( text )
62
- tr . appendChild ( th )
63
- tableHead . appendChild ( tr )
64
- } )
61
+ th . append ( text )
62
+ tr . append ( th )
63
+ tableHead . append ( tr )
64
+ }
65
65
66
66
const tableBody = document . createElement ( 'tbody' )
67
67
tableBody . classList . add ( ClassName . TOOLTIP_BODY )
68
68
69
- bodyLines . forEach ( ( body , i ) => {
69
+ for ( const [ i , body ] of bodyLines . entries ( ) ) {
70
70
const colors = tooltip . labelColors [ i ]
71
71
72
72
const span = document . createElement ( 'span' )
@@ -86,11 +86,11 @@ const customTooltips = context => {
86
86
87
87
const text = document . createTextNode ( body )
88
88
89
- td . appendChild ( span )
90
- td . appendChild ( text )
91
- tr . appendChild ( td )
92
- tableBody . appendChild ( tr )
93
- } )
89
+ td . append ( span )
90
+ td . append ( text )
91
+ tr . append ( td )
92
+ tableBody . append ( tr )
93
+ }
94
94
95
95
const tableRoot = tooltipEl . querySelector ( 'table' )
96
96
@@ -100,18 +100,18 @@ const customTooltips = context => {
100
100
}
101
101
102
102
// Add new children
103
- tableRoot . appendChild ( tableHead )
104
- tableRoot . appendChild ( tableBody )
103
+ tableRoot . append ( tableHead )
104
+ tableRoot . append ( tableBody )
105
105
}
106
106
107
107
const { offsetLeft : positionX , offsetTop : positionY } = chart . canvas
108
108
109
109
// Display, position, and set styles for font
110
110
tooltipEl . style . opacity = 1
111
- tooltipEl . style . left = positionX + tooltip . caretX + 'px'
112
- tooltipEl . style . top = positionY + tooltip . caretY + 'px'
111
+ tooltipEl . style . left = ` ${ positionX + tooltip . caretX } px`
112
+ tooltipEl . style . top = ` ${ positionY + tooltip . caretY } px`
113
113
tooltipEl . style . font = tooltip . options . bodyFont . string
114
- tooltipEl . style . padding = tooltip . padding + ' px ' + tooltip . padding + 'px'
114
+ tooltipEl . style . padding = ` ${ tooltip . padding } px ${ tooltip . padding } px`
115
115
}
116
116
117
117
export default customTooltips
0 commit comments