@@ -26,6 +26,7 @@ var assertClip = customAssertions.assertClip;
2626var assertNodeDisplay = customAssertions . assertNodeDisplay ;
2727var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
2828var checkTextTemplate = require ( '../assets/check_texttemplate' ) ;
29+ var checkTransition = require ( '../assets/check_transitions' ) ;
2930var Fx = require ( '@src/components/fx' ) ;
3031
3132var d3 = require ( 'd3' ) ;
@@ -2548,3 +2549,96 @@ function assertTraceField(calcData, prop, expectation) {
25482549
25492550 expect ( values ) . toBeCloseToArray ( expectation , undefined , '(field ' + prop + ')' ) ;
25502551}
2552+
2553+ describe ( 'bar tweening' , function ( ) {
2554+ var gd ;
2555+ var mock = {
2556+ 'data' : [ {
2557+ 'type' : 'bar' ,
2558+ 'x' : [ 'A' , 'B' , 'C' ] ,
2559+ 'text' : [ 'A' , 'B' , 'C' ] ,
2560+ 'textposition' : 'inside' ,
2561+ 'y' : [ 24 , 5 , 8 ] ,
2562+ 'error_y' : { 'array' : [ 3 , 2 , 1 ] }
2563+ } ]
2564+ } ;
2565+ var transitionOpts = false ; // use default
2566+
2567+ beforeEach ( function ( ) {
2568+ gd = createGraphDiv ( ) ;
2569+ } ) ;
2570+
2571+ afterEach ( function ( ) {
2572+ Plotly . purge ( gd ) ;
2573+ destroyGraphDiv ( ) ;
2574+ } ) ;
2575+
2576+ it ( 'for bar fill color' , function ( done ) {
2577+ var tests = [
2578+ [ 0 , '.point path' , 'style' , 'fill' , [ 'rgb(31, 119, 180)' , 'rgb(31, 119, 180)' , 'rgb(31, 119, 180)' ] ] ,
2579+ [ 100 , '.point path' , 'style' , 'fill' , [ 'rgb(76, 95, 144)' , 'rgb(25, 146, 144)' , 'rgb(25, 95, 195)' ] ] ,
2580+ [ 300 , '.point path' , 'style' , 'fill' , [ 'rgb(165, 48, 72)' , 'rgb(12, 201, 72)' , 'rgb(12, 48, 225)' ] ] ,
2581+ [ 500 , '.point path' , 'style' , 'fill' , [ 'rgb(255, 0, 0)' , 'rgb(0, 255, 0)' , 'rgb(0, 0, 255)' ] ]
2582+ ] ;
2583+ var animateOpts = { 'data' : [ { 'marker' : { 'color' : [ 'rgb(255, 0, 0)' , 'rgb(0, 255, 0)' , 'rgb(0, 0, 255)' ] } } ] } ;
2584+
2585+ checkTransition ( gd , mock , animateOpts , transitionOpts , tests )
2586+ . catch ( failTest )
2587+ . then ( done ) ;
2588+ } ) ;
2589+
2590+ it ( 'for bar height and and text position' , function ( done ) {
2591+ var tests = [
2592+ [ 0 , '.point path' , 'attr' , 'd' , [ 'M18,270V42H162V270Z' , 'M198,270V222.5H342V270Z' , 'M378,270V194H522V270Z' ] ] ,
2593+ [ 0 , 'text.bartext' , 'attr' , 'transform' , [ 'translate(90 56)' , 'translate(270 236.5)' , 'translate(450 208)' ] ] ,
2594+ [ 100 , '.point path' , 'attr' , 'd' , [ 'M18,270V78.1H162V270Z' , 'M198,270V186.4H342V270Z' , 'M378,270V186.40000000000003H522V270Z' ] ] ,
2595+ [ 300 , '.point path' , 'attr' , 'd' , [ 'M18,270V150.3H162V270Z' , 'M198,270V114.2H342V270Z' , 'M378,270V171.2H522V270Z' ] ] ,
2596+ [ 300 , 'text.bartext' , 'attr' , 'transform' , [ 'translate(90,164.3)' , 'translate(270,128.20000000000002)' , 'translate(450,185.2)' ] ] ,
2597+ [ 500 , '.point path' , 'attr' , 'd' , [ 'M18,270V222.5H162V270Z' , 'M198,270V42H342V270Z' , 'M378,270V156H522V270Z' ] ] ,
2598+ [ 600 , '.point path' , 'attr' , 'd' , [ 'M18,270V222.5H162V270Z' , 'M198,270V42H342V270Z' , 'M378,270V156H522V270Z' ] ] ,
2599+ [ 600 , 'text.bartext' , 'attr' , 'transform' , [ 'translate(90 236.5)' , 'translate(270 56)' , 'translate(450 170)' ] ] ,
2600+ ] ;
2601+ var animateOpts = { data : [ { y : [ 5 , 24 , 12 ] } ] } ;
2602+
2603+ checkTransition ( gd , mock , animateOpts , transitionOpts , tests )
2604+ . catch ( failTest )
2605+ . then ( done ) ;
2606+ } ) ;
2607+
2608+ it ( 'for bar width' , function ( done ) {
2609+ var tests = [
2610+ [ 0 , '.point path' , 'attr' , 'd' , [ 'M54,270V13.5H486V270Z' ] ] ,
2611+ [ 250 , '.point path' , 'attr' , 'd' , [ 'M94.5,270V13.5H445.5V270Z' ] ] ,
2612+ [ 500 , '.point path' , 'attr' , 'd' , [ 'M135,270V13.5H405V270Z' ] ]
2613+ ] ;
2614+ var animateOpts = { data : [ { width : 0.5 } ] } ;
2615+
2616+ checkTransition ( gd , {
2617+ data : [ {
2618+ type : 'bar' ,
2619+ y : [ 5 ]
2620+ } ] } ,
2621+ animateOpts , transitionOpts , tests )
2622+ . catch ( failTest )
2623+ . then ( done ) ;
2624+ } ) ;
2625+
2626+ it ( 'for error bars' , function ( done ) {
2627+ var tests = [
2628+ [ 0 , 'path.yerror' , 'attr' , 'd' , [ 'M266,13.5h8m-4,0V99m-4,0h8' ] ] ,
2629+ [ 250 , 'path.yerror' , 'attr' , 'd' , [ 'M266,-18.56h8m-4,0V131.065m-4,0h8' ] ] ,
2630+ [ 500 , 'path.yerror' , 'attr' , 'd' , [ 'M266,-50.62h8m-4,0V163.13m-4,0h8' ] ]
2631+ ] ;
2632+ var animateOpts = { data : [ { error_y : { value : 50 } } ] } ;
2633+
2634+ checkTransition ( gd , {
2635+ data : [ {
2636+ type : 'bar' ,
2637+ y : [ 2 ] ,
2638+ error_y : { value : 20 }
2639+ } ] } ,
2640+ animateOpts , transitionOpts , tests )
2641+ . catch ( failTest )
2642+ . then ( done ) ;
2643+ } ) ;
2644+ } ) ;
0 commit comments