Skip to content

Commit

Permalink
do not rely on patternID to detect legend
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jun 17, 2021
1 parent fd89e23 commit 5f5561f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
*
* @param {object} sel: d3 selection to apply this pattern to
* You can use `selection.call(Drawing.pattern, ...)`
* @param {string} calledBy: option to know the caller component
* @param {DOM element} gd: the graph div `sel` is part of
* @param {string} patternID: a unique (within this plot) identifier
* for this pattern, so that we don't create unnecessary definitions
Expand All @@ -370,7 +371,9 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
* @param {string} fgcolor: foreground color for this pattern
* @param {number} fgopacity: foreground opacity for this pattern
*/
drawing.pattern = function(sel, gd, patternID, shape, size, solidity, mcc, fillmode, bgcolor, fgcolor, fgopacity) {
drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity, mcc, fillmode, bgcolor, fgcolor, fgopacity) {
var isLegend = calledBy === 'legend';

if(mcc) {
if(fillmode === 'overlay') {
bgcolor = mcc;
Expand Down Expand Up @@ -504,8 +507,6 @@ drawing.pattern = function(sel, gd, patternID, shape, size, solidity, mcc, fillm
break;
}

var isLegend = patternID.substr(0, 6) === 'legend';

var str = [
shape || 'noSh',
bgcolor || 'noBg',
Expand Down Expand Up @@ -737,7 +738,7 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) {
if(perPointPattern) patternID += '-' + d.i;

drawing.pattern(
sel, gd, patternID,
sel, 'point', gd, patternID,
patternShape, patternSize, patternSolidity,
d.mcc, markerPattern.fillmode,
patternBGColor, patternFGColor, patternFGOpacity
Expand Down
2 changes: 1 addition & 1 deletion src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ module.exports = function style(s, gd, legend) {
var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3);
var patternID = 'legend-' + trace.uid;
p.call(
Drawing.pattern, gd, patternID,
Drawing.pattern, 'legend', gd, patternID,
patternShape, patternSize, patternSolidity,
mcc, markerPattern.fillmode,
patternBGColor, patternFGColor, patternFGOpacity
Expand Down

0 comments on commit 5f5561f

Please sign in to comment.