@@ -23,8 +23,8 @@ const getOrCreateTooltip = chart => {
2323 const table = document . createElement ( 'table' )
2424 table . style . margin = '0px'
2525
26- tooltipEl . appendChild ( table )
27- chart . canvas . parentNode . appendChild ( tooltipEl )
26+ tooltipEl . append ( table )
27+ chart . canvas . parentNode . append ( tooltipEl )
2828 }
2929
3030 return tooltipEl
@@ -49,7 +49,7 @@ const customTooltips = context => {
4949 const tableHead = document . createElement ( 'thead' )
5050 tableHead . classList . add ( ClassName . TOOLTIP_HEADER )
5151
52- titleLines . forEach ( title => {
52+ for ( const title of titleLines ) {
5353 const tr = document . createElement ( 'tr' )
5454 tr . style . borderWidth = 0
5555 tr . classList . add ( ClassName . TOOLTIP_HEADER_ITEM )
@@ -58,15 +58,15 @@ const customTooltips = context => {
5858 th . style . borderWidth = 0
5959 const text = document . createTextNode ( title )
6060
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+ }
6565
6666 const tableBody = document . createElement ( 'tbody' )
6767 tableBody . classList . add ( ClassName . TOOLTIP_BODY )
6868
69- bodyLines . forEach ( ( body , i ) => {
69+ for ( const [ i , body ] of bodyLines . entries ( ) ) {
7070 const colors = tooltip . labelColors [ i ]
7171
7272 const span = document . createElement ( 'span' )
@@ -86,11 +86,11 @@ const customTooltips = context => {
8686
8787 const text = document . createTextNode ( body )
8888
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+ }
9494
9595 const tableRoot = tooltipEl . querySelector ( 'table' )
9696
@@ -100,18 +100,18 @@ const customTooltips = context => {
100100 }
101101
102102 // Add new children
103- tableRoot . appendChild ( tableHead )
104- tableRoot . appendChild ( tableBody )
103+ tableRoot . append ( tableHead )
104+ tableRoot . append ( tableBody )
105105 }
106106
107107 const { offsetLeft : positionX , offsetTop : positionY } = chart . canvas
108108
109109 // Display, position, and set styles for font
110110 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`
113113 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`
115115}
116116
117117export default customTooltips
0 commit comments