11const d3 = require ( 'd3' )
2- const { getElementWidth, getElementHeight, decodeHTML} = require ( '../../util/htmlUtil' )
3- const { toRadian} = require ( '../../util/mathUtils' )
4- const { getRingIdString} = require ( '../../util/stringUtil' )
2+ const { getElementWidth, getElementHeight, decodeHTML } = require ( '../../util/htmlUtil' )
3+ const { toRadian } = require ( '../../util/mathUtils' )
4+ const { getRingIdString } = require ( '../../util/stringUtil' )
55const {
66 graphConfig,
77 getGraphSize,
@@ -13,13 +13,12 @@ const {
1313
1414const ANIMATION_DURATION = 1000
1515
16- const { quadrantHeight, quadrantWidth, quadrantsGap, effectiveQuadrantWidth} = graphConfig
16+ const { quadrantHeight, quadrantWidth, quadrantsGap, effectiveQuadrantWidth } = graphConfig
1717
1818let prevLeft , prevTop
1919let quadrantScrollHandlerReference
2020let scrollFlag = false
2121
22-
2322const createElement = ( tagName , text , attributes ) => {
2423 const tag = document . createElement ( tagName )
2524 Object . keys ( attributes ) . forEach ( ( keyName ) => {
@@ -30,15 +29,10 @@ const createElement = (tagName, text, attributes) => {
3029}
3130
3231const replaceChild = ( element , child ) => {
33- let elementChild = element . lastElementChild ;
34- while ( elementChild ) {
35- element . removeChild ( elementChild ) ;
36- elementChild = e . lastElementChild ;
37- }
32+ element . textContent = ''
3833 element . appendChild ( child )
3934}
4035
41-
4236function selectRadarQuadrant ( order , startAngle , name ) {
4337 const noOfBlips = d3 . selectAll ( '.quadrant-group-' + order + ' .blip-link' ) . size ( )
4438 d3 . select ( '#radar' ) . classed ( 'no-blips' , noOfBlips === 0 )
@@ -120,10 +114,10 @@ function selectRadarQuadrant(order, startAngle, name) {
120114 svg . classed ( 'quadrant-view' , true )
121115
122116 const quadrantGroupTranslate = {
123- first : { x : 0 , y : 0 } ,
124- second : { x : 0 , y : - quadrantHeight } ,
125- third : { x : - ( quadrantWidth + quadrantsGap ) , y : 0 } ,
126- fourth : { x : - ( quadrantWidth + quadrantsGap ) , y : - quadrantHeight } ,
117+ first : { x : 0 , y : 0 } ,
118+ second : { x : 0 , y : - quadrantHeight } ,
119+ third : { x : - ( quadrantWidth + quadrantsGap ) , y : 0 } ,
120+ fourth : { x : - ( quadrantWidth + quadrantsGap ) , y : - quadrantHeight } ,
127121 }
128122
129123 d3 . select ( '.quadrant-group-' + order )
@@ -219,19 +213,19 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
219213 const words = text . split ( ' ' )
220214 let line = ''
221215
222- replaceChild ( element , createElement ( 'tspan' , text , { id : 'text-width-check' } ) )
216+ replaceChild ( element , createElement ( 'tspan' , text , { id : 'text-width-check' } ) )
223217 const testElem = document . getElementById ( 'text-width-check' )
224218
225219 function maxCharactersToFit ( testLine , suffix ) {
226220 let j = 1
227221 let firstLineWidth = 0
228222 const testElem1 = document . getElementById ( 'text-width-check' )
229- testElem1 . innerHTML = testLine
223+ testElem1 . textContent = testLine
230224 if ( testElem1 . getBoundingClientRect ( ) . width < maxWidth ) {
231225 return testLine . length
232226 }
233227 while ( firstLineWidth < maxWidth && testLine . length > j ) {
234- testElem1 . innerHTML = testLine . substring ( 0 , j ) + suffix
228+ testElem1 . textContent = testLine . substring ( 0 , j ) + suffix
235229 firstLineWidth = testElem1 . getBoundingClientRect ( ) . width
236230
237231 j ++
@@ -252,33 +246,33 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
252246 if ( testElem . getBoundingClientRect ( ) . width > maxWidth ) {
253247 for ( let i = 0 ; i < words . length ; i ++ ) {
254248 let testLine = line + words [ i ] + ' '
255- testElem . innerHTML = testLine
249+ testElem . textContent = testLine
256250 const textWidth = testElem . getBoundingClientRect ( ) . width
257251
258252 if ( textWidth > maxWidth ) {
259253 if ( i === 0 ) {
260254 let lineBreakIndex = maxCharactersToFit ( testLine , '-' )
261255 const elementText = `${ words [ i ] . substring ( 0 , lineBreakIndex ) } -`
262- element . appendChild ( createElement ( 'tspan' , elementText , { x : '0' , dy} ) )
256+ element . appendChild ( createElement ( 'tspan' , elementText , { x : '0' , dy } ) )
263257 const secondLine = words [ i ] . substring ( lineBreakIndex , words [ i ] . length ) + ' ' + words . slice ( i + 1 ) . join ( ' ' )
264258 lineBreakIndex = maxCharactersToFit ( secondLine , '...' )
265259 const text = `${ secondLine . substring ( 0 , lineBreakIndex ) } ${ ellipsis ( lineBreakIndex , secondLine ) } `
266- element . appendChild ( createElement ( 'tspan' , text , { x : '0' , dy : '20' } ) )
260+ element . appendChild ( createElement ( 'tspan' , text , { x : '0' , dy : '20' } ) )
267261 break
268262 } else {
269- element . appendChild ( createElement ( 'tspan' , line , { x : '0' , dy} ) )
263+ element . appendChild ( createElement ( 'tspan' , line , { x : '0' , dy } ) )
270264 const secondLine = words . slice ( i ) . join ( ' ' )
271265 const lineBreakIndex = maxCharactersToFit ( secondLine , '...' )
272266 const text = `${ secondLine . substring ( 0 , lineBreakIndex ) } ${ ellipsis ( lineBreakIndex , secondLine ) } `
273- element . appendChild ( createElement ( 'tspan' , text , { x : '0' , dy : '20' } ) )
267+ element . appendChild ( createElement ( 'tspan' , text , { x : '0' , dy : '20' } ) )
274268 }
275269 line = words [ i ] + ' '
276270 } else {
277271 line = testLine
278272 }
279273 }
280274 } else {
281- element . appendChild ( createElement ( 'tspan' , text , { x : '0' } ) )
275+ element . appendChild ( createElement ( 'tspan' , text , { x : '0' } ) )
282276 }
283277
284278 document . getElementById ( 'text-width-check' ) . remove ( )
@@ -338,7 +332,7 @@ function renderRadarQuadrants(size, svg, quadrant, rings, ringCalculator, tip) {
338332 } )
339333
340334 const rectCoordMap = {
341- first : { x : 0 , y : 0 , strokeDashArray : `0, ${ quadrantWidth } , ${ quadrantHeight + quadrantWidth } , ${ quadrantHeight } ` } ,
335+ first : { x : 0 , y : 0 , strokeDashArray : `0, ${ quadrantWidth } , ${ quadrantHeight + quadrantWidth } , ${ quadrantHeight } ` } ,
342336 second : {
343337 x : 0 ,
344338 y : quadrantHeight + quadrantsGap ,
0 commit comments