@@ -25,11 +25,11 @@ var formatColor = require('../../lib/gl_format_color');
2525var subTypes = require ( '../scatter/subtypes' ) ;
2626var makeBubbleSizeFn = require ( '../scatter/make_bubble_size_func' ) ;
2727var getTraceColor = require ( '../scatter/get_trace_color' ) ;
28- var MARKER_SYMBOLS = require ( '../../constants/gl_markers ' ) ;
28+ var MARKER_SYMBOLS = require ( '../../constants/gl2d_markers ' ) ;
2929var DASHES = require ( '../../constants/gl2d_dashes' ) ;
3030
3131var AXES = [ 'xaxis' , 'yaxis' ] ;
32-
32+ var transparent = [ 0 , 0 , 0 , 0 ] ;
3333
3434function LineWithMarkers ( scene , uid ) {
3535 this . scene = scene ;
@@ -214,7 +214,7 @@ function _convertArray(convert, data, count) {
214214var convertNumber = convertArray . bind ( null , function ( x ) { return + x ; } ) ;
215215var convertColorBase = convertArray . bind ( null , str2RGBArray ) ;
216216var convertSymbol = convertArray . bind ( null , function ( x ) {
217- return MARKER_SYMBOLS [ x ] || '● ';
217+ return MARKER_SYMBOLS [ x ] ? x : 'circle ';
218218} ) ;
219219
220220function convertColor ( color , opacity , count ) {
@@ -251,8 +251,17 @@ function _convertColor(colors, opacities, count) {
251251 return result ;
252252}
253253
254- proto . update = function ( options ) {
254+ function isSymbolOpen ( symbol ) {
255+ return symbol . split ( '-open' ) [ 1 ] === '' ;
256+ }
255257
258+ function fillColor ( colorIn , colorOut , offsetIn , offsetOut ) {
259+ for ( var j = 0 ; j < 4 ; j ++ ) {
260+ colorIn [ 4 * offsetIn + j ] = colorOut [ 4 * offsetOut + j ] ;
261+ }
262+ }
263+
264+ proto . update = function ( options ) {
256265 if ( options . visible !== true ) {
257266 this . isVisible = false ;
258267 this . hasLines = false ;
@@ -441,7 +450,7 @@ proto.updateFancy = function(options) {
441450 var getX = ( xaxis . type === 'log' ) ? xaxis . d2l : function ( x ) { return x ; } ;
442451 var getY = ( yaxis . type === 'log' ) ? yaxis . d2l : function ( y ) { return y ; } ;
443452
444- var i , j , xx , yy , ex0 , ex1 , ey0 , ey1 ;
453+ var i , xx , yy , ex0 , ex1 , ey0 , ey1 ;
445454
446455 for ( i = 0 ; i < len ; ++ i ) {
447456 this . xData [ i ] = xx = getX ( x [ i ] ) ;
@@ -491,29 +500,53 @@ proto.updateFancy = function(options) {
491500 this . scatter . options . colors = new Array ( pId * 4 ) ;
492501 this . scatter . options . borderColors = new Array ( pId * 4 ) ;
493502
494- var markerSizeFunc = makeBubbleSizeFn ( options ) ,
495- markerOpts = options . marker ,
496- markerOpacity = markerOpts . opacity ,
497- traceOpacity = options . opacity ,
498- colors = convertColorScale ( markerOpts , markerOpacity , traceOpacity , len ) ,
499- glyphs = convertSymbol ( markerOpts . symbol , len ) ,
500- borderWidths = convertNumber ( markerOpts . line . width , len ) ,
501- borderColors = convertColorScale ( markerOpts . line , markerOpacity , traceOpacity , len ) ,
502- index ;
503+ var markerSizeFunc = makeBubbleSizeFn ( options ) ;
504+ var markerOpts = options . marker ;
505+ var markerOpacity = markerOpts . opacity ;
506+ var traceOpacity = options . opacity ;
507+ var symbols = convertSymbol ( markerOpts . symbol , len ) ;
508+ var colors = convertColorScale ( markerOpts , markerOpacity , traceOpacity , len ) ;
509+ var borderWidths = convertNumber ( markerOpts . line . width , len ) ;
510+ var borderColors = convertColorScale ( markerOpts . line , markerOpacity , traceOpacity , len ) ;
511+ var index , size , symbol , symbolSpec , isOpen , _colors , _borderColors , bw , minBorderWidth ;
503512
504513 sizes = convertArray ( markerSizeFunc , markerOpts . size , len ) ;
505514
506515 for ( i = 0 ; i < pId ; ++ i ) {
507516 index = idToIndex [ i ] ;
508517
509- this . scatter . options . sizes [ i ] = 4.0 * sizes [ index ] ;
510- this . scatter . options . glyphs [ i ] = glyphs [ index ] ;
511- this . scatter . options . borderWidths [ i ] = 0.5 * borderWidths [ index ] ;
518+ symbol = symbols [ index ] ;
519+ symbolSpec = MARKER_SYMBOLS [ symbol ] ;
520+ isOpen = isSymbolOpen ( symbol ) ;
521+
522+ if ( symbolSpec . noBorder && ! isOpen ) {
523+ _colors = borderColors ;
524+ } else {
525+ _colors = colors ;
526+ }
527+
528+ if ( isOpen ) {
529+ _borderColors = colors ;
530+ } else {
531+ _borderColors = borderColors ;
532+ }
533+
534+ // See https://github.com/plotly/plotly.js/pull/1781#discussion_r121820798
535+ // for more info on this logic
536+ size = sizes [ index ] ;
537+ bw = borderWidths [ index ] ;
538+ minBorderWidth = ( symbolSpec . noBorder || symbolSpec . noFill ) ? 0.1 * size : 0 ;
539+
540+ this . scatter . options . sizes [ i ] = 4.0 * size ;
541+ this . scatter . options . glyphs [ i ] = symbolSpec . unicode ;
542+ this . scatter . options . borderWidths [ i ] = 0.5 * ( ( bw > minBorderWidth ) ? bw - minBorderWidth : 0 ) ;
512543
513- for ( j = 0 ; j < 4 ; ++ j ) {
514- this . scatter . options . colors [ 4 * i + j ] = colors [ 4 * index + j ] ;
515- this . scatter . options . borderColors [ 4 * i + j ] = borderColors [ 4 * index + j ] ;
544+ if ( isOpen && ! symbolSpec . noBorder && ! symbolSpec . noFill ) {
545+ fillColor ( this . scatter . options . colors , transparent , i , 0 ) ;
546+ } else {
547+ fillColor ( this . scatter . options . colors , _colors , i , index ) ;
516548 }
549+ fillColor ( this . scatter . options . borderColors , _borderColors , i , index ) ;
517550 }
518551
519552 this . fancyScatter . update ( ) ;
0 commit comments