@@ -3,6 +3,7 @@ var Scatter = require('@src/traces/scatter');
3
3
var makeBubbleSizeFn = require ( '@src/traces/scatter/make_bubble_size_func' ) ;
4
4
var linePoints = require ( '@src/traces/scatter/line_points' ) ;
5
5
var Lib = require ( '@src/lib' ) ;
6
+ var Plots = require ( '@src/plots/plots' ) ;
6
7
7
8
var Plotly = require ( '@lib/index' ) ;
8
9
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
@@ -18,6 +19,8 @@ var assertMultiNodeOrder = customAssertions.assertMultiNodeOrder;
18
19
var checkEventData = require ( '../assets/check_event_data' ) ;
19
20
var constants = require ( '@src/traces/scatter/constants' ) ;
20
21
22
+ var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
23
+
21
24
var getOpacity = function ( node ) { return Number ( node . style . opacity ) ; } ;
22
25
var getFillOpacity = function ( node ) { return Number ( node . style [ 'fill-opacity' ] ) ; } ;
23
26
var getColor = function ( node ) { return node . style . fill ; } ;
@@ -273,6 +276,55 @@ describe('Test scatter', function() {
273
276
} ) ;
274
277
} ) ;
275
278
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
+
276
328
describe ( 'isBubble' , function ( ) {
277
329
it ( 'should return true when marker.size is an Array' , function ( ) {
278
330
var trace = {
0 commit comments