@@ -2,6 +2,7 @@ var Plotly = require('@lib/index');
2
2
var Plots = require ( '@src/plots/plots' ) ;
3
3
var Lib = require ( '@src/lib' ) ;
4
4
5
+ var d3 = require ( 'd3' ) ;
5
6
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6
7
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
7
8
@@ -417,9 +418,34 @@ describe('finance charts updates:', function() {
417
418
it ( 'Plotly.restyle should work' , function ( done ) {
418
419
var trace0 = Lib . extendDeep ( { } , mock0 , { type : 'ohlc' } ) ;
419
420
420
- Plotly . plot ( gd , [ trace0 ] ) . then ( function ( ) {
421
+ var path0 ;
421
422
422
- // gotta test 'tickwidth' and 'whiskerwitdth'
423
+ Plotly . plot ( gd , [ trace0 ] ) . then ( function ( ) {
424
+ expect ( gd . calcdata [ 0 ] [ 0 ] . x ) . toEqual ( - 0.05 ) ;
425
+ expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 33.01 ) ;
426
+
427
+ return Plotly . restyle ( gd , 'tickwidth' , 0.5 ) ;
428
+ } )
429
+ . then ( function ( ) {
430
+ expect ( gd . calcdata [ 0 ] [ 0 ] . x ) . toEqual ( - 0.5 ) ;
431
+
432
+ return Plotly . restyle ( gd , 'open' , [ [ 0 , 30.75 , 32.87 , 31.62 , 30.81 , 32.75 , 32.75 , 32.87 ] ] ) ;
433
+ } )
434
+ . then ( function ( ) {
435
+ expect ( gd . calcdata [ 0 ] [ 0 ] . y ) . toEqual ( 0 ) ;
436
+
437
+ return Plotly . restyle ( gd , {
438
+ type : 'candlestick' ,
439
+ open : [ [ 33.01 , 33.31 , 33.50 , 32.06 , 34.12 , 33.05 , 33.31 , 33.50 ] ]
440
+ } ) ;
441
+ } )
442
+ . then ( function ( ) {
443
+ path0 = d3 . select ( 'path.box' ) . attr ( 'd' ) ;
444
+
445
+ return Plotly . restyle ( gd , 'whiskerwidth' , 0.2 ) ;
446
+ } )
447
+ . then ( function ( ) {
448
+ expect ( d3 . select ( 'path.box' ) . attr ( 'd' ) ) . not . toEqual ( path0 ) ;
423
449
424
450
done ( ) ;
425
451
} ) ;
0 commit comments