@@ -3,6 +3,7 @@ var Scatter = require('@src/traces/scatter');
33var makeBubbleSizeFn = require ( '@src/traces/scatter/make_bubble_size_func' ) ;
44var linePoints = require ( '@src/traces/scatter/line_points' ) ;
55var Lib = require ( '@src/lib' ) ;
6+ var Plots = require ( '@src/plots/plots' ) ;
67
78var Plotly = require ( '@lib/index' ) ;
89var createGraphDiv = require ( '../assets/create_graph_div' ) ;
@@ -18,6 +19,8 @@ var assertMultiNodeOrder = customAssertions.assertMultiNodeOrder;
1819var checkEventData = require ( '../assets/check_event_data' ) ;
1920var constants = require ( '@src/traces/scatter/constants' ) ;
2021
22+ var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
23+
2124var getOpacity = function ( node ) { return Number ( node . style . opacity ) ; } ;
2225var getFillOpacity = function ( node ) { return Number ( node . style [ 'fill-opacity' ] ) ; } ;
2326var getColor = function ( node ) { return node . style . fill ; } ;
@@ -273,6 +276,55 @@ describe('Test scatter', function() {
273276 } ) ;
274277 } ) ;
275278
279+ describe ( 'calc' , function ( ) {
280+ function assertPointField ( calcData , prop , expectation ) {
281+ var values = [ ] ;
282+
283+ calcData . forEach ( function ( calcTrace ) {
284+ var vals = calcTrace . map ( function ( pt ) {
285+ return Lib . nestedProperty ( pt , prop ) . get ( ) ;
286+ } ) ;
287+
288+ values . push ( vals ) ;
289+ } ) ;
290+
291+ expect ( values ) . toBeCloseTo2DArray ( expectation , undefined , '(field ' + prop + ')' ) ;
292+ }
293+
294+ it ( 'should guard against negative size values' , function ( ) {
295+ var gd = {
296+ data : [ {
297+ type : 'scatter' ,
298+ mode : 'markers+text' ,
299+ marker : {
300+ line : {
301+ width : [ 2 , 1 , 0 , - 1 , false , true , null , [ ] , - Infinity , Infinity , NaN , { } , '12+1' , '1e1' ]
302+ } ,
303+ opacity : [ 2 , 1 , 0 , - 1 , false , true , null , [ ] , - Infinity , Infinity , NaN , { } , '12+1' , '1e1' ] ,
304+ size : [ 2 , 1 , 0 , - 1 , false , true , null , [ ] , - Infinity , Infinity , NaN , { } , '12+1' , '1e1' ]
305+ } ,
306+ textfont : {
307+ size : [ 2 , 1 , 0 , - 1 , false , true , null , [ ] , - Infinity , Infinity , NaN , { } , '12+1' , '1e1' ]
308+ } ,
309+ text : [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '10' , '11' , '12' , '13' , '14' ] ,
310+ y : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 ]
311+ } ] ,
312+ layout : { } ,
313+ calcdata : [ ] ,
314+ _context : { locale : 'en' , locales : { } }
315+ } ;
316+
317+ supplyAllDefaults ( gd ) ;
318+ Plots . doCalcdata ( gd ) ;
319+
320+ var cd = gd . calcdata ;
321+ assertPointField ( cd , 'mlw' , [ [ 2 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 ] ] ) ;
322+ assertPointField ( cd , 'mo' , [ [ 2 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 ] ] ) ;
323+ assertPointField ( cd , 'ms' , [ [ 2 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 ] ] ) ;
324+ assertPointField ( cd , 'ts' , [ [ 2 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 ] ] ) ;
325+ } ) ;
326+ } ) ;
327+
276328 describe ( 'isBubble' , function ( ) {
277329 it ( 'should return true when marker.size is an Array' , function ( ) {
278330 var trace = {
0 commit comments