@@ -31,6 +31,19 @@ const addProp = function(slotArray, newProps) {
3131 return [];
3232}
3333
34+ /**
35+ * Returns a uuid string.
36+ * Reference: https://stackoverflow.com/a/2117523
37+ * @private
38+ * @return {string}
39+ */
40+ const uuidv4 = function () {
41+ return ' xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' .replace (/ [xy] / g , function (c ) {
42+ var r = Math .random () * 16 | 0 , v = c == ' x' ? r : (r & 0x3 | 0x8 );
43+ return v .toString (16 );
44+ });
45+ }
46+
3447
3548/**
3649 * This component is a container for axis and plot components,
@@ -343,9 +356,10 @@ export default {
343356 y += this .offsetY ;
344357 }
345358
359+ const clipPathUid = uuidv4 ();
346360 defs
347361 .append (" clipPath" )
348- .attr (" id" , ` cp-${ axisType } ` )
362+ .attr (" id" , ` cp-${ clipPathUid } ` )
349363 .append (" rect" )
350364 .attr (" width" , width)
351365 .attr (" height" , height);
@@ -363,7 +377,7 @@ export default {
363377 .attr (" width" , width)
364378 .attr (" height" , height)
365379 .attr (" transform" , ` translate(${ x} ,${ y} )` )
366- .attr (" clip-path" , ` url(#cp-${ axisType } )` );
380+ .attr (" clip-path" , ` url(#cp-${ clipPathUid } )` );
367381
368382 axisG .html (axisSvg .node ().innerHTML );
369383 }
@@ -382,9 +396,10 @@ export default {
382396 const width = this .pWidth ;
383397 const height = pHeight;
384398
399+ const clipPathUid = uuidv4 ();
385400 defs
386401 .append (" clipPath" )
387- .attr (" id" , ` cp-plot ` )
402+ .attr (" id" , ` cp-${ clipPathUid } ` )
388403 .append (" rect" )
389404 .attr (" width" , width)
390405 .attr (" height" , height);
@@ -402,7 +417,7 @@ export default {
402417 .attr (" width" , width)
403418 .attr (" height" , height)
404419 .attr (" transform" , ` translate(${ x} ,${ y} )` )
405- .attr (" clip-path" , ` url(#cp-plot )` );
420+ .attr (" clip-path" , ` url(#cp-${ clipPathUid } )` );
406421 plotG .html (plotSvg .node ().innerHTML );
407422 }
408423 };
0 commit comments