@@ -2781,58 +2781,52 @@ describe('Test plot api', function() {
2781
2781
. then ( done ) ;
2782
2782
} ) ;
2783
2783
2784
- // it('has the right internal state after altering candlesticks', function(done) {
2785
- // var trace = {
2786
- // type: 'candlestick',
2787
- // low: [1],
2788
- // open: [2],
2789
- // close: [3],
2790
- // high: [4]
2791
- // };
2792
- // Plotly.newPlot(gd, [trace])
2793
- // .then(function() {
2794
- // expect(gd._fullData[0].y).toEqual([1, 2, 3, 3, 3, 4]);
2795
- // return Plotly.react(gd, [trace]);
2796
- // })
2797
- // .then(function() {
2798
- // // the plot actually *looks* correct here, but this is the simplest
2799
- // // manifestation of https://github.com/plotly/plotly.js/issues/2510
2800
- // expect(gd._fullData[0].y).toEqual([1, 2, 3, 3, 3, 4]);
2801
- // })
2802
- // .catch(failTest)
2803
- // .then(done);
2804
- // });
2805
-
2806
- // it('can change data in candlesticks multiple times', function(done) {
2807
- // var trace = {
2808
- // type: 'candlestick',
2809
- // low: [1],
2810
- // open: [2],
2811
- // close: [3],
2812
- // high: [4]
2813
- // };
2814
- // Plotly.newPlot(gd, [trace])
2815
- // .then(function() {
2816
- // expect(gd._fullData[0].y).toEqual([1, 2, 3, 3, 3, 4]);
2817
-
2818
- // trace.low = [0];
2819
- // return Plotly.react(gd, [trace]);
2820
- // })
2821
- // .then(function() {
2822
- // expect(gd._fullData[0].y).toEqual([0, 2, 3, 3, 3, 4]);
2823
-
2824
- // trace.low = [-1];
2825
- // return Plotly.react(gd, [trace]);
2826
- // })
2827
- // .then(function() {
2828
- // expect(gd._fullData[0].y).toEqual([-1, 2, 3, 3, 3, 4]);
2829
-
2830
- // trace.low = [0];
2831
- // return Plotly.react(gd, [trace]);
2832
- // })
2833
- // .catch(failTest)
2834
- // .then(done);
2835
- // });
2784
+ it ( 'can change data in candlesticks multiple times' , function ( done ) {
2785
+ // test that we've fixed the original issue in
2786
+ // https://github.com/plotly/plotly.js/issues/2510
2787
+
2788
+ function assertCalc ( open , high , low , close ) {
2789
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( {
2790
+ min : low ,
2791
+ max : high ,
2792
+ med : close ,
2793
+ q1 : Math . min ( open , close ) ,
2794
+ q3 : Math . max ( open , close ) ,
2795
+ dir : close >= open ? 'increasing' : 'decreasing'
2796
+ } ) ) ;
2797
+ }
2798
+ var trace = {
2799
+ type : 'candlestick' ,
2800
+ low : [ 1 ] ,
2801
+ open : [ 2 ] ,
2802
+ close : [ 3 ] ,
2803
+ high : [ 4 ]
2804
+ } ;
2805
+ Plotly . newPlot ( gd , [ trace ] )
2806
+ . then ( function ( ) {
2807
+ assertCalc ( 2 , 4 , 1 , 3 ) ;
2808
+
2809
+ trace . low = [ 0 ] ;
2810
+ return Plotly . react ( gd , [ trace ] ) ;
2811
+ } )
2812
+ . then ( function ( ) {
2813
+ assertCalc ( 2 , 4 , 0 , 3 ) ;
2814
+
2815
+ trace . low = [ - 1 ] ;
2816
+ return Plotly . react ( gd , [ trace ] ) ;
2817
+ } )
2818
+ . then ( function ( ) {
2819
+ assertCalc ( 2 , 4 , - 1 , 3 ) ;
2820
+
2821
+ trace . close = [ 1 ] ;
2822
+ return Plotly . react ( gd , [ trace ] ) ;
2823
+ } )
2824
+ . then ( function ( ) {
2825
+ assertCalc ( 2 , 4 , - 1 , 1 ) ;
2826
+ } )
2827
+ . catch ( failTest )
2828
+ . then ( done ) ;
2829
+ } ) ;
2836
2830
2837
2831
it ( 'can change frames without redrawing' , function ( done ) {
2838
2832
var data = [ { y : [ 1 , 2 , 3 ] } ] ;
0 commit comments