@@ -30,7 +30,7 @@ globalThis.THEME_COLORS = [
3030
3131globalThis . htmlLegendPlugin = {
3232 id : "htmlLegend" ,
33- afterUpdate ( chart , args , options ) {
33+ afterUpdate ( chart , arguments_ , options ) {
3434 // Use the built-in legendItems generator
3535 const items = chart . options . plugins . legend . labels . generateLabels ( chart ) ;
3636
@@ -39,9 +39,9 @@ globalThis.htmlLegendPlugin = {
3939 options . lastLegendItems &&
4040 items . length === options . lastLegendItems . length &&
4141 items . every (
42- ( item , i ) =>
43- item . text === options . lastLegendItems [ i ] . text &&
44- item . hidden === options . lastLegendItems [ i ] . hidden
42+ ( item , index ) =>
43+ item . text === options . lastLegendItems [ index ] . text &&
44+ item . hidden === options . lastLegendItems [ index ] . hidden
4545 ) ;
4646
4747 if ( isLegendUnchanged ) {
@@ -144,40 +144,40 @@ globalThis.htmlLegendPlugin = {
144144globalThis . customTooltips = context => {
145145 const tooltip = context . tooltip ;
146146 const canvasId = context . chart . canvas . id ;
147- const tooltipEl = getOrCreateTooltipElement ( canvasId , tooltip . options , context ) ;
147+ const tooltipElement = getOrCreateTooltipElement ( canvasId , tooltip . options , context ) ;
148148
149149 // Hide if no tooltip
150150 if ( tooltip . opacity === 0 ) {
151- tooltipEl . style . opacity = 0 ;
151+ tooltipElement . style . opacity = 0 ;
152152 return ;
153153 }
154154
155155 // Set caret position
156- setTooltipCaretPosition ( tooltipEl , tooltip ) ;
156+ setTooltipCaretPosition ( tooltipElement , tooltip ) ;
157157
158158 // Set tooltip content
159159 if ( tooltip . body ) {
160- setTooltipContent ( tooltipEl , tooltip ) ;
160+ setTooltipContent ( tooltipElement , tooltip ) ;
161161 }
162162
163163 // Position tooltip
164- positionTooltip ( tooltipEl , tooltip , context ) ;
164+ positionTooltip ( tooltipElement , tooltip , context ) ;
165165
166166 // Make tooltip visible
167- tooltipEl . style . opacity = 1 ;
167+ tooltipElement . style . opacity = 1 ;
168168} ;
169169
170170function getOrCreateTooltipElement ( canvasId , options , context ) {
171- let tooltipEl = document . getElementById ( `${ canvasId } -customTooltip` ) ;
172- if ( tooltipEl ) {
173- return tooltipEl ;
171+ let tooltipElement = document . getElementById ( `${ canvasId } -customTooltip` ) ;
172+ if ( tooltipElement ) {
173+ return tooltipElement ;
174174 }
175175
176176 // Create Tooltip Element once per chart
177- tooltipEl = document . createElement ( "div" ) ;
178- tooltipEl . id = `${ canvasId } -customTooltip` ;
179- tooltipEl . className = "chartjs-tooltip" ;
180- tooltipEl . innerHTML = '<div class="arrow"></div> <table></table>' ;
177+ tooltipElement = document . createElement ( "div" ) ;
178+ tooltipElement . id = `${ canvasId } -customTooltip` ;
179+ tooltipElement . className = "chartjs-tooltip" ;
180+ tooltipElement . innerHTML = '<div class="arrow"></div> <table></table>' ;
181181
182182 // Avoid browser's font-zoom since we know that <body>'s
183183 // font-size was set to 14px by Bootstrap's CSS
@@ -187,7 +187,7 @@ function getOrCreateTooltipElement(canvasId, options, context) {
187187 const fontZoom = Number . parseFloat ( getComputedStyle ( document . body ) . fontSize ) / 14 ;
188188
189189 // Set styles and font
190- tooltipEl . style . cssText = `
190+ tooltipElement . style . cssText = `
191191 padding: ${ options . padding } px ${ options . padding } px;
192192 border-radius: ${ options . cornerRadius } px;
193193 font: ${ options . bodyFont . string } ;
@@ -197,18 +197,18 @@ function getOrCreateTooltipElement(canvasId, options, context) {
197197 ` ;
198198
199199 // Append Tooltip next to canvas-containing box
200- tooltipEl . ancestor = context . chart . canvas . closest ( ".box[id]" ) . parentNode ;
201- tooltipEl . ancestor . append ( tooltipEl ) ;
200+ tooltipElement . ancestor = context . chart . canvas . closest ( ".box[id]" ) . parentNode ;
201+ tooltipElement . ancestor . append ( tooltipElement ) ;
202202
203- return tooltipEl ;
203+ return tooltipElement ;
204204}
205205
206- function setTooltipCaretPosition ( tooltipEl , tooltip ) {
207- tooltipEl . classList . remove ( "left" , "right" , "center" , "top" , "bottom" ) ;
208- tooltipEl . classList . add ( tooltip . xAlign , tooltip . yAlign ) ;
206+ function setTooltipCaretPosition ( tooltipElement , tooltip ) {
207+ tooltipElement . classList . remove ( "left" , "right" , "center" , "top" , "bottom" ) ;
208+ tooltipElement . classList . add ( tooltip . xAlign , tooltip . yAlign ) ;
209209}
210210
211- function setTooltipContent ( tooltipEl , tooltip ) {
211+ function setTooltipContent ( tooltipElement , tooltip ) {
212212 const bodyLines = tooltip . body . map ( bodyItem => bodyItem . lines ) ;
213213 if ( bodyLines . length === 0 ) {
214214 return ;
@@ -226,18 +226,18 @@ function setTooltipContent(tooltipEl, tooltip) {
226226 const devicePixel = ( 1 / window . devicePixelRatio ) . toFixed ( 1 ) ;
227227 let printed = 0 ;
228228
229- for ( const [ i , body ] of bodyLines . entries ( ) ) {
230- const labelColors = tooltip . labelColors [ i ] ;
229+ for ( const [ index , body ] of bodyLines . entries ( ) ) {
230+ const labelColors = tooltip . labelColors [ index ] ;
231231 const style =
232232 `background-color: ${ labelColors . backgroundColor } ; ` +
233233 `outline: 1px solid ${ labelColors . backgroundColor } ; ` +
234234 `border: ${ devicePixel } px solid #fff` ;
235235 const span = `<span class="chartjs-tooltip-key" style="${ style } "></span>` ;
236236
237- const num = body [ 0 ] . split ( ": " ) ;
237+ const number_ = body [ 0 ] . split ( ": " ) ;
238238 // Do not display entries with value of 0 in bar chart,
239239 // but pass through entries with "0.0%" (in pie charts)
240- if ( num [ 1 ] !== "0" ) {
240+ if ( number_ [ 1 ] !== "0" ) {
241241 tooltipHtml += `<tr><td>${ span } ${ body } </td></tr>` ;
242242 printed ++ ;
243243 }
@@ -249,21 +249,21 @@ function setTooltipContent(tooltipEl, tooltip) {
249249
250250 tooltipHtml += "</tbody>" ;
251251
252- const tableRoot = tooltipEl . querySelector ( "table" ) ;
252+ const tableRoot = tooltipElement . querySelector ( "table" ) ;
253253 tableRoot . innerHTML = tooltipHtml ;
254254}
255255
256- function positionTooltip ( tooltipEl , tooltip , context ) {
257- if ( tooltip . opacity === 0 || tooltipEl . style . opacity === 0 ) {
256+ function positionTooltip ( tooltipElement , tooltip , context ) {
257+ if ( tooltip . opacity === 0 || tooltipElement . style . opacity === 0 ) {
258258 return ;
259259 }
260260
261261 const canvasPos = context . chart . canvas . getBoundingClientRect ( ) ;
262- const boxPos = tooltipEl . ancestor . getBoundingClientRect ( ) ;
262+ const boxPos = tooltipElement . ancestor . getBoundingClientRect ( ) ;
263263 const offsetX = canvasPos . left - boxPos . left ;
264264 const offsetY = canvasPos . top - boxPos . top ;
265- const tooltipWidth = tooltipEl . offsetWidth ;
266- const tooltipHeight = tooltipEl . offsetHeight ;
265+ const tooltipWidth = tooltipElement . offsetWidth ;
266+ const tooltipHeight = tooltipElement . offsetHeight ;
267267 const { caretX, caretY } = tooltip ;
268268 const { caretPadding } = tooltip . options ;
269269 const arrowMinIndent = 2 * tooltip . options . cornerRadius ;
@@ -323,7 +323,7 @@ function positionTooltip(tooltipEl, tooltip, context) {
323323
324324 // Adjust X position if tooltip is centered inside ancestor
325325 if ( document . documentElement . clientWidth <= 2 * tooltip . width && tooltip . xAlign === "center" ) {
326- tooltipX = ( tooltipEl . ancestor . offsetWidth - tooltipWidth ) / 2 ;
326+ tooltipX = ( tooltipElement . ancestor . offsetWidth - tooltipWidth ) / 2 ;
327327 tooltipX = Math . max ( tooltipX , offsetX + caretX - arrowMinIndent ) ; // Prevent left overflow
328328 tooltipX = Math . min ( tooltipX , offsetX + caretX - tooltipWidth + arrowMinIndent ) ; // Prevent right overflow
329329 arrowX = offsetX + caretX - tooltipX ;
@@ -367,11 +367,11 @@ function positionTooltip(tooltipEl, tooltip, context) {
367367 }
368368
369369 // Position tooltip and display
370- tooltipEl . style . top = `${ tooltipY . toFixed ( 1 ) } px` ;
371- tooltipEl . style . left = `${ tooltipX . toFixed ( 1 ) } px` ;
370+ tooltipElement . style . top = `${ tooltipY . toFixed ( 1 ) } px` ;
371+ tooltipElement . style . left = `${ tooltipX . toFixed ( 1 ) } px` ;
372372
373373 // Set arrow position
374- const arrowEl = tooltipEl . querySelector ( ".arrow" ) ;
374+ const arrowElement = tooltipElement . querySelector ( ".arrow" ) ;
375375 let arrowLeftPosition = "" ;
376376
377377 if ( arrowX !== undefined ) {
@@ -381,7 +381,7 @@ function positionTooltip(tooltipEl, tooltip, context) {
381381 arrowLeftPosition = `${ arrowXpercent } %` ;
382382 }
383383
384- arrowEl . style . left = arrowLeftPosition ;
384+ arrowElement . style . left = arrowLeftPosition ;
385385}
386386
387387globalThis . doughnutTooltip = tooltipLabel => {
0 commit comments