Skip to content

Commit d09b343

Browse files
committed
Changes for fillgradients based on first review
- removed assert - renamed new mocks and baselines - used local variable instead of direct reference to trace property - added trailing newlines to new mock .json files
1 parent 45e2cda commit d09b343

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

src/components/drawing/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ drawing.dashStyle = function(dash, lineWidth) {
179179

180180
function setFillStyle(sel, trace, gd, forLegend) {
181181
var markerPattern = trace.fillpattern;
182+
var fillgradient = trace.fillgradient;
182183
var patternShape = markerPattern && drawing.getPatternAttr(markerPattern.shape, 0, '');
183184
if(patternShape) {
184185
var patternBGColor = drawing.getPatternAttr(markerPattern.bgcolor, 0, null);
@@ -192,32 +193,32 @@ function setFillStyle(sel, trace, gd, forLegend) {
192193
undefined, markerPattern.fillmode,
193194
patternBGColor, patternFGColor, patternFGOpacity
194195
);
195-
} else if(trace.fillgradient && trace.fillgradient.orientation !== 'none') {
196-
var direction = trace.fillgradient.orientation;
196+
} else if(fillgradient && fillgradient.orientation !== 'none') {
197+
var direction = fillgradient.orientation;
197198
var gradientID = 'scatterfill-' + trace.uid;
198199
if(forLegend) {
199200
gradientID = 'legendfill-' + trace.uid;
200201
}
201202

202-
if(!forLegend && (trace.fillgradient.start !== undefined || trace.fillgradient.stop !== undefined)) {
203+
if(!forLegend && (fillgradient.start !== undefined || fillgradient.stop !== undefined)) {
203204
var start, stop;
204205
if(direction === 'horizontal') {
205206
start = {
206-
x: trace.fillgradient.start,
207+
x: fillgradient.start,
207208
y: 0,
208209
};
209210
stop = {
210-
x: trace.fillgradient.stop,
211+
x: fillgradient.stop,
211212
y: 0,
212213
};
213214
} else if(direction === 'vertical') {
214215
start = {
215216
x: 0,
216-
y: trace.fillgradient.start,
217+
y: fillgradient.start,
217218
};
218219
stop = {
219220
x: 0,
220-
y: trace.fillgradient.stop,
221+
y: fillgradient.stop,
221222
};
222223
}
223224

@@ -234,12 +235,12 @@ function setFillStyle(sel, trace, gd, forLegend) {
234235
stop.y = trace._yA.c2p(
235236
(stop.y === undefined) ? trace._extremes.y.max[0].val : stop.y, true
236237
);
237-
sel.call(gradientWithBounds, gd, gradientID, 'linear', trace.fillgradient.colorscale, 'fill', start, stop, true, false);
238+
sel.call(gradientWithBounds, gd, gradientID, 'linear', fillgradient.colorscale, 'fill', start, stop, true, false);
238239
} else {
239240
if(direction === 'horizontal') {
240241
direction = direction + 'reversed';
241242
}
242-
sel.call(drawing.gradient, gd, gradientID, direction, trace.fillgradient.colorscale, 'fill');
243+
sel.call(drawing.gradient, gd, gradientID, direction, fillgradient.colorscale, 'fill');
243244
}
244245
} else if(trace.fillcolor) {
245246
sel.call(Color.fill, trace.fillcolor);

src/traces/scatter/attributes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ module.exports = {
443443
colorscale: {
444444
valType: 'colorscale',
445445
editType: 'style',
446-
anim: true,
447446
description: [
448447
'Sets the fill gradient colors as a color scale.',
449448
'The color scale is interpreted as a gradient',
@@ -453,7 +452,7 @@ module.exports = {
453452
'distant point from it, if orientation is *radial*.'
454453
].join(' ')
455454
},
456-
editType: 'style',
455+
editType: 'calc',
457456
description: [
458457
'Sets a fill gradient.',
459458
'If not specified, the fillcolor is used instead.'

src/traces/scatter/fillcolor_defaults.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
var Color = require('../../components/color');
44
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
5-
var assert = require('assert');
65

76
function averageColors(colorscale) {
8-
assert(colorscale.length >= 2);
97
var color = Color.interpolate(colorscale[0][1], colorscale[1][1], 0.5);
108
for(var i = 2; i < colorscale.length; i++) {
119
var averageColorI = Color.interpolate(colorscale[i - 1][1], colorscale[i][1], 0.5);

test/image/mocks/scatter_fill_gradient_tonext.json renamed to test/image/mocks/zz-scatter_fill_gradient_tonext.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
"title": { "text": "Scatter traces with radial color gradient fills" },
4040
"showlegend": true
4141
}
42-
}
42+
}

test/image/mocks/scatter_fill_gradient_tonexty_toself.json renamed to test/image/mocks/zz-scatter_fill_gradient_tonexty_toself.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@
7878
"title": { "text": "Scatter traces with linear color gradient fills" },
7979
"showlegend": true
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)