Skip to content

Commit 72cc168

Browse files
committed
rm useless logic in drawing
- that made color array containing identical items not draw properly.
1 parent 8745a22 commit 72cc168

File tree

2 files changed

+12
-42
lines changed

2 files changed

+12
-42
lines changed

src/components/drawing/index.js

+10-39
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,8 @@ drawing.singlePointStyle = function(d, sel, trace) {
276276

277277
// allow array marker and marker line colors to be
278278
// scaled by given max and min to colorscales
279-
var markerIn = (trace._input || {}).marker || {},
280-
markerScale = drawing.tryColorscale(marker, markerIn, ''),
281-
lineScale = drawing.tryColorscale(marker, markerIn, 'line.');
279+
var markerScale = drawing.tryColorscale(marker, ''),
280+
lineScale = drawing.tryColorscale(marker, 'line');
282281

283282
singlePointStyle(d, sel, trace, markerScale, lineScale, marker, markerLine);
284283

@@ -290,50 +289,22 @@ drawing.pointStyle = function(s, trace) {
290289
// allow array marker and marker line colors to be
291290
// scaled by given max and min to colorscales
292291
var marker = trace.marker;
293-
var markerIn = (trace._input || {}).marker || {},
294-
markerScale = drawing.tryColorscale(marker, markerIn, ''),
295-
lineScale = drawing.tryColorscale(marker, markerIn, 'line.');
292+
var markerScale = drawing.tryColorscale(marker, ''),
293+
lineScale = drawing.tryColorscale(marker, 'line');
296294

297295
s.each(function(d) {
298296
drawing.singlePointStyle(d, d3.select(this), trace, markerScale, lineScale);
299297
});
300298
};
301299

302-
// for a given color attribute (ie m -> mc = marker.color) look to see if we
303-
// have a colorscale for it (ie mscl, mcmin, mcmax) - if we do, translate
304-
// all numeric color values according to that scale
305-
drawing.tryColorscale = function(cont, contIn, prefix) {
306-
var colorArray = Lib.nestedProperty(cont, prefix + 'color').get(),
307-
scl = Lib.nestedProperty(cont, prefix + 'colorscale').get(),
308-
auto = Lib.nestedProperty(cont, prefix + 'cauto').get(),
309-
minProp = Lib.nestedProperty(cont, prefix + 'cmin'),
310-
maxProp = Lib.nestedProperty(cont, prefix + 'cmax'),
311-
min = minProp.get(),
312-
max = maxProp.get();
313-
314-
// TODO handle this in Colorscale.calc
315-
if(scl && Array.isArray(colorArray)) {
316-
if(auto || !isNumeric(min) || !isNumeric(max)) {
317-
min = Infinity;
318-
max = -Infinity;
319-
colorArray.forEach(function(color) {
320-
if(isNumeric(color)) {
321-
if(min > color) min = +color;
322-
if(max < color) max = +color;
323-
}
324-
});
325-
if(min > max) {
326-
min = 0;
327-
max = 1;
328-
}
329-
minProp.set(min);
330-
maxProp.set(max);
331-
Lib.nestedProperty(contIn, prefix + 'cmin').set(min);
332-
Lib.nestedProperty(contIn, prefix + 'cmax').set(max);
333-
}
300+
drawing.tryColorscale = function(marker, prefix) {
301+
var cont = prefix ? Lib.nestedProperty(marker, prefix).get() : marker,
302+
scl = cont.colorscale,
303+
colorArray = cont.color;
334304

305+
if(scl && Array.isArray(colorArray)) {
335306
return Colorscale.makeColorScaleFunc(
336-
Colorscale.extractScale(scl, min, max)
307+
Colorscale.extractScale(scl, cont.cmin, cont.cmax)
337308
);
338309
}
339310
else return Lib.identity;

src/traces/bar/style.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ module.exports = function style(gd) {
4141
var trace = d[0].trace,
4242
marker = trace.marker,
4343
markerLine = marker.line,
44-
markerIn = (trace._input || {}).marker || {},
45-
markerScale = Drawing.tryColorscale(marker, markerIn, ''),
46-
lineScale = Drawing.tryColorscale(marker, markerIn, 'line.');
44+
markerScale = Drawing.tryColorscale(marker, ''),
45+
lineScale = Drawing.tryColorscale(marker, 'line');
4746

4847
d3.select(this).selectAll('path').each(function(d) {
4948
// allow all marker and marker line colors to be scaled

0 commit comments

Comments
 (0)