Skip to content

Commit 5f5561f

Browse files
committed
do not rely on patternID to detect legend
1 parent fd89e23 commit 5f5561f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components/drawing/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
359359
*
360360
* @param {object} sel: d3 selection to apply this pattern to
361361
* You can use `selection.call(Drawing.pattern, ...)`
362+
* @param {string} calledBy: option to know the caller component
362363
* @param {DOM element} gd: the graph div `sel` is part of
363364
* @param {string} patternID: a unique (within this plot) identifier
364365
* for this pattern, so that we don't create unnecessary definitions
@@ -370,7 +371,9 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
370371
* @param {string} fgcolor: foreground color for this pattern
371372
* @param {number} fgopacity: foreground opacity for this pattern
372373
*/
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+
374377
if(mcc) {
375378
if(fillmode === 'overlay') {
376379
bgcolor = mcc;
@@ -504,8 +507,6 @@ drawing.pattern = function(sel, gd, patternID, shape, size, solidity, mcc, fillm
504507
break;
505508
}
506509

507-
var isLegend = patternID.substr(0, 6) === 'legend';
508-
509510
var str = [
510511
shape || 'noSh',
511512
bgcolor || 'noBg',
@@ -737,7 +738,7 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) {
737738
if(perPointPattern) patternID += '-' + d.i;
738739

739740
drawing.pattern(
740-
sel, gd, patternID,
741+
sel, 'point', gd, patternID,
741742
patternShape, patternSize, patternSolidity,
742743
d.mcc, markerPattern.fillmode,
743744
patternBGColor, patternFGColor, patternFGOpacity

src/components/legend/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ module.exports = function style(s, gd, legend) {
365365
var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3);
366366
var patternID = 'legend-' + trace.uid;
367367
p.call(
368-
Drawing.pattern, gd, patternID,
368+
Drawing.pattern, 'legend', gd, patternID,
369369
patternShape, patternSize, patternSolidity,
370370
mcc, markerPattern.fillmode,
371371
patternBGColor, patternFGColor, patternFGOpacity

0 commit comments

Comments
 (0)