@@ -1248,6 +1248,45 @@ describe('Test plotly events on a scattermap plot when css transform is present:
12481248 } ) ;
12491249} ) ;
12501250
1251+ describe ( 'scattermap legend' , function ( ) {
1252+ var gd ;
1253+
1254+ beforeEach ( function ( ) {
1255+ Plotly . setPlotConfig ( { } ) ;
1256+ gd = createGraphDiv ( ) ;
1257+ } ) ;
1258+
1259+ afterEach ( function ( ) {
1260+ Plotly . purge ( gd ) ;
1261+ destroyGraphDiv ( ) ;
1262+ } ) ;
1263+
1264+ it ( '@gl should always draw a circle swatch regardless of marker.symbol' , function ( done ) {
1265+ // marker.symbol on map traces is a Maki/sprite icon name that the SVG
1266+ // legend can't reproduce, so the swatch should consistently be a circle.
1267+ // The circle symbol path is the only one using an arc ('A') command;
1268+ // square/triangle/etc. use only straight (H/V/L) segments.
1269+ Plotly . newPlot ( gd , {
1270+ data : [
1271+ { type : 'scattermap' , lat : [ 0 ] , lon : [ 0 ] , mode : 'markers' , name : 'square' , marker : { symbol : 'square' } } ,
1272+ { type : 'scattermap' , lat : [ 1 ] , lon : [ 1 ] , mode : 'markers' , name : 'tri' , marker : { symbol : 'triangle-stroked' } }
1273+ ] ,
1274+ layout : {
1275+ map : { style : 'open-street-map' , zoom : 6 , center : { lat : 0.5 , lon : 0.5 } } ,
1276+ showlegend : true
1277+ }
1278+ } ) . then ( function ( ) {
1279+ var swatches = gd . querySelectorAll ( '.legend .legendpoints path.scatterpts' ) ;
1280+ expect ( swatches . length ) . toBe ( 2 , 'one swatch per trace' ) ;
1281+ swatches . forEach ( function ( node ) {
1282+ var d = node . getAttribute ( 'd' ) ;
1283+ expect ( d . indexOf ( 'A' ) ) . toBeGreaterThan ( - 1 , 'swatch is a circle (has arc): ' + d ) ;
1284+ expect ( d . indexOf ( 'NaN' ) ) . toBe ( - 1 , 'swatch path has no NaN: ' + d ) ;
1285+ } ) ;
1286+ } ) . then ( done , done . fail ) ;
1287+ } ) ;
1288+ } ) ;
1289+
12511290describe ( 'scattermap restyle' , function ( ) {
12521291 var gd ;
12531292
0 commit comments