Skip to content

Commit 6879e51

Browse files
committed
refactor pattern arguments
1 parent bd19e27 commit 6879e51

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/components/drawing/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,15 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) {
362362
* @param {DOM element} gd: the graph div `sel` is part of
363363
* @param {string} patternID: a unique (within this plot) identifier
364364
* for this pattern, so that we don't create unnecessary definitions
365-
* @param {string} bgcolor: background color for this pattern
366-
* @param {string} fgcolor: foreground color for this pattern
367-
* @param {number} fgopacity: foreground opacity for this pattern
368365
* @param {number} size: size of unit squares for repetition of this pattern
369366
* @param {number} solidity: how solid lines of this pattern are
370367
* @param {string} mcc: color when painted with colorscale
371368
* @param {string} fillmode: fillmode for this pattern
372-
* @param {string} prop: the property to apply to, 'fill' or 'stroke'
369+
* @param {string} bgcolor: background color for this pattern
370+
* @param {string} fgcolor: foreground color for this pattern
371+
* @param {number} fgopacity: foreground opacity for this pattern
373372
*/
374-
drawing.pattern = function(sel, gd, patternID, shape, bgcolor, fgcolor, fgopacity, size, solidity, mcc, fillmode, prop) {
373+
drawing.pattern = function(sel, gd, patternID, shape, size, solidity, mcc, fillmode, bgcolor, fgcolor, fgopacity) {
375374
if(mcc) {
376375
if(fillmode === 'overlay') {
377376
bgcolor = mcc;
@@ -550,8 +549,8 @@ drawing.pattern = function(sel, gd, patternID, shape, bgcolor, fgcolor, fgopacit
550549
.attr(patternAttrs);
551550
});
552551

553-
sel.style(prop, getFullUrl(fullID, gd))
554-
.style(prop + '-opacity', null);
552+
sel.style('fill', getFullUrl(fullID, gd))
553+
.style('fill-opacity', null);
555554

556555
sel.classed('pattern_filled', true);
557556
var className2query = function(s) {
@@ -734,8 +733,12 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) {
734733
var patternID = trace.uid;
735734
if(perPointPattern) patternID += '-' + d.i;
736735

737-
drawing.pattern(sel, gd, patternID, patternShape, patternBGColor, patternFGColor, patternFGOpacity,
738-
patternSize, patternSolidity, d.mcc, markerPattern.fillmode, 'fill');
736+
drawing.pattern(
737+
sel, gd, patternID,
738+
patternShape, patternSize, patternSolidity,
739+
d.mcc, markerPattern.fillmode,
740+
patternBGColor, patternFGColor, patternFGOpacity
741+
);
739742
} else {
740743
Color.fill(sel, fillColor);
741744
}

src/components/legend/style.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,12 @@ module.exports = function style(s, gd, legend) {
364364
var patternSize = Math.min(12, Drawing.getPatternAttr(markerPattern.size, 0, 8));
365365
var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3);
366366
var patternID = 'legend-' + trace.uid;
367-
p.call(Drawing.pattern, gd, patternID, patternShape, patternBGColor, patternFGColor, patternFGOpacity,
368-
patternSize, patternSolidity, mcc, markerPattern.fillmode, 'fill');
367+
p.call(
368+
Drawing.pattern, gd, patternID,
369+
patternShape, patternSize, patternSolidity,
370+
mcc, markerPattern.fillmode,
371+
patternBGColor, patternFGColor, patternFGOpacity
372+
);
369373
} else {
370374
p.call(Color.fill, fillColor);
371375
}

0 commit comments

Comments
 (0)