Skip to content

Commit

Permalink
return a default not the first point for legend when having arrays of…
Browse files Browse the repository at this point in the history
… size or solidity
  • Loading branch information
archmoj committed Jun 17, 2021
1 parent 5f5561f commit a2a66e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@ drawing.getPatternAttr = function(mp, i, dflt) {
return mp;
};

drawing.getPatternLegendDim = function(mp, i, dflt) {
if(mp && Lib.isArrayOrTypedArray(mp)) {
return dflt;
}
return mp;
};

drawing.pointStyle = function(s, trace, gd) {
if(!s.size()) return;

Expand Down Expand Up @@ -725,7 +732,7 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) {
} else if(patternShape) {
var patternBGColor = drawing.getPatternAttr(markerPattern.bgcolor, d.i, null);
var patternFGColor = drawing.getPatternAttr(markerPattern.fgcolor, d.i, null);
var patternFGOpacity = drawing.getPatternAttr(markerPattern.fgopacity, d.i, 1);
var patternFGOpacity = markerPattern.fgopacity;
var patternSize = drawing.getPatternAttr(markerPattern.size, d.i, 8);
var patternSolidity = drawing.getPatternAttr(markerPattern.solidity, d.i, 0.3);
var perPointPattern = d.mcc ||
Expand Down
6 changes: 3 additions & 3 deletions src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ module.exports = function style(s, gd, legend) {
if(patternShape) {
var patternBGColor = Drawing.getPatternAttr(markerPattern.bgcolor, 0, null);
var patternFGColor = Drawing.getPatternAttr(markerPattern.fgcolor, 0, null);
var patternFGOpacity = Drawing.getPatternAttr(markerPattern.fgopacity, 0, 1);
var patternSize = Math.min(12, Drawing.getPatternAttr(markerPattern.size, 0, 8));
var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3);
var patternFGOpacity = markerPattern.fgopacity;
var patternSize = Math.min(12, Drawing.getPatternLegendDim(markerPattern.size, 0, 8));
var patternSolidity = Drawing.getPatternLegendDim(markerPattern.solidity, 0, 0.3);
var patternID = 'legend-' + trace.uid;
p.call(
Drawing.pattern, 'legend', gd, patternID,
Expand Down
Binary file modified test/image/baselines/pattern_bars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/pattern_fgcolor_overlay_fillmode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2a66e7

Please sign in to comment.