@@ -359,6 +359,7 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
359
359
*
360
360
* @param {object } sel: d3 selection to apply this pattern to
361
361
* You can use `selection.call(Drawing.pattern, ...)`
362
+ * @param {string } calledBy: option to know the caller component
362
363
* @param {DOM element } gd: the graph div `sel` is part of
363
364
* @param {string } patternID: a unique (within this plot) identifier
364
365
* for this pattern, so that we don't create unnecessary definitions
@@ -370,7 +371,9 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
370
371
* @param {string } fgcolor: foreground color for this pattern
371
372
* @param {number } fgopacity: foreground opacity for this pattern
372
373
*/
373
- drawing . pattern = function ( sel , gd , patternID , shape , size , solidity , mcc , fillmode , bgcolor , fgcolor , fgopacity ) {
374
+ drawing . pattern = function ( sel , calledBy , gd , patternID , shape , size , solidity , mcc , fillmode , bgcolor , fgcolor , fgopacity ) {
375
+ var isLegend = calledBy === 'legend' ;
376
+
374
377
if ( mcc ) {
375
378
if ( fillmode === 'overlay' ) {
376
379
bgcolor = mcc ;
@@ -527,7 +530,9 @@ drawing.pattern = function(sel, gd, patternID, shape, size, solidity, mcc, fillm
527
530
'id' : fullID ,
528
531
'width' : width + 'px' ,
529
532
'height' : height + 'px' ,
530
- 'patternUnits' : 'userSpaceOnUse'
533
+ 'patternUnits' : 'userSpaceOnUse' ,
534
+ // for legends scale down patterns just a bit so that default size (i.e 8) nicely fit in small icons
535
+ 'patternTransform' : isLegend ? 'scale(0.8)' : ''
531
536
} ) ;
532
537
533
538
if ( bgcolor ) {
@@ -734,7 +739,7 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) {
734
739
if ( perPointPattern ) patternID += '-' + d . i ;
735
740
736
741
drawing . pattern (
737
- sel , gd , patternID ,
742
+ sel , 'point' , gd , patternID ,
738
743
patternShape , patternSize , patternSolidity ,
739
744
d . mcc , markerPattern . fillmode ,
740
745
patternBGColor , patternFGColor , patternFGOpacity
0 commit comments