Skip to content

Commit da89728

Browse files
committed
try replacing bwFactor with minBorderWidth
- add svg and gl2d mocks for comparison
1 parent fffc702 commit da89728

File tree

6 files changed

+1202
-14
lines changed

6 files changed

+1202
-14
lines changed

src/constants/gl2d_markers.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ var symbolsWithOpenSupport = {
7070
unicode: '⧓'
7171
},
7272
'diamond-x': {
73-
unicode: '❖',
74-
bwFactor: 0.25
73+
unicode: '❖'
7574
},
7675
'cross-thin': {
7776
unicode: '+',

src/traces/scattergl/convert.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,13 @@ proto.updateFancy = function(options) {
508508
var colors = convertColorScale(markerOpts, markerOpacity, traceOpacity, len);
509509
var borderWidths = convertNumber(markerOpts.line.width, len);
510510
var borderColors = convertColorScale(markerOpts.line, markerOpacity, traceOpacity, len);
511-
var index, symbol, symbolSpec, _colors, _borderColors, bwFactor, isOpen;
511+
var index, size, symbol, symbolSpec, isOpen, _colors, _borderColors, bw, minBorderWidth;
512512

513513
sizes = convertArray(markerSizeFunc, markerOpts.size, len);
514514

515515
for(i = 0; i < pId; ++i) {
516516
index = idToIndex[i];
517+
517518
symbol = symbols[index];
518519
symbolSpec = MARKER_SYMBOLS[symbol];
519520
isOpen = isSymbolOpen(symbol);
@@ -530,19 +531,24 @@ proto.updateFancy = function(options) {
530531
_borderColors = borderColors;
531532
}
532533

533-
if(symbolSpec.bwFactor) {
534-
bwFactor = symbolSpec.bwFactor;
535-
} else if(symbolSpec.noBorder) {
536-
bwFactor = 0.25;
537-
} else if(symbolSpec.noFill) {
538-
bwFactor = 0.1;
539-
} else {
540-
bwFactor = 0.5;
541-
}
534+
size = sizes[index];
535+
bw = borderWidths[index];
536+
minBorderWidth = 0.1 * size;
542537

543-
this.scatter.options.sizes[i] = 4.0 * sizes[index];
538+
this.scatter.options.sizes[i] = 4.0 * size;
544539
this.scatter.options.glyphs[i] = symbolSpec.unicode;
545-
this.scatter.options.borderWidths[i] = bwFactor * borderWidths[index];
540+
541+
// From https://github.com/plotly/plotly.js/pull/1781#discussion_r121820798
542+
// I would think we'd do better with something like a minimum border
543+
// width, as a fraction of size, that corresponds to the line width
544+
// already baked into the unicode symbol, so the symbol gets no
545+
// explicit border until you provide a width greater than this, and
546+
// at greater widths you set a border borderWidth - minBorderWidth.
547+
548+
//this.scatter.options.borderWidths[i] = (bw > minBorderWidth) ? bw - minBorderWidth : 0;
549+
550+
// but I found better results with:
551+
this.scatter.options.borderWidths[i] = (bw > minBorderWidth) ? bw - minBorderWidth : bw;
546552

547553
if(isOpen && !symbolSpec.noBorder && !symbolSpec.noFill) {
548554
fillColor(this.scatter.options.colors, transparent, i, 0);
50.4 KB
Loading
45.7 KB
Loading

0 commit comments

Comments
 (0)