@@ -31,6 +31,19 @@ const addProp = function(slotArray, newProps) {
31
31
return [];
32
32
}
33
33
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
+
34
47
35
48
/**
36
49
* This component is a container for axis and plot components,
@@ -343,9 +356,10 @@ export default {
343
356
y += this .offsetY ;
344
357
}
345
358
359
+ const clipPathUid = uuidv4 ();
346
360
defs
347
361
.append (" clipPath" )
348
- .attr (" id" , ` cp-${ axisType } ` )
362
+ .attr (" id" , ` cp-${ clipPathUid } ` )
349
363
.append (" rect" )
350
364
.attr (" width" , width)
351
365
.attr (" height" , height);
@@ -363,7 +377,7 @@ export default {
363
377
.attr (" width" , width)
364
378
.attr (" height" , height)
365
379
.attr (" transform" , ` translate(${ x} ,${ y} )` )
366
- .attr (" clip-path" , ` url(#cp-${ axisType } )` );
380
+ .attr (" clip-path" , ` url(#cp-${ clipPathUid } )` );
367
381
368
382
axisG .html (axisSvg .node ().innerHTML );
369
383
}
@@ -382,9 +396,10 @@ export default {
382
396
const width = this .pWidth ;
383
397
const height = pHeight;
384
398
399
+ const clipPathUid = uuidv4 ();
385
400
defs
386
401
.append (" clipPath" )
387
- .attr (" id" , ` cp-plot ` )
402
+ .attr (" id" , ` cp-${ clipPathUid } ` )
388
403
.append (" rect" )
389
404
.attr (" width" , width)
390
405
.attr (" height" , height);
@@ -402,7 +417,7 @@ export default {
402
417
.attr (" width" , width)
403
418
.attr (" height" , height)
404
419
.attr (" transform" , ` translate(${ x} ,${ y} )` )
405
- .attr (" clip-path" , ` url(#cp-plot )` );
420
+ .attr (" clip-path" , ` url(#cp-${ clipPathUid } )` );
406
421
plotG .html (plotSvg .node ().innerHTML );
407
422
}
408
423
};
0 commit comments