From 3141c477e1dba15c442e489733c34392ee10b701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 17 Dec 2018 12:23:30 -0500 Subject: [PATCH] fix #3339 - typed arrays support for ohlc / candlestick traces --- src/traces/ohlc/calc.js | 2 +- test/jasmine/tests/finance_test.js | 31 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/traces/ohlc/calc.js b/src/traces/ohlc/calc.js index f7553444bfa..fe60922d525 100644 --- a/src/traces/ohlc/calc.js +++ b/src/traces/ohlc/calc.js @@ -92,7 +92,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) { } } - trace._extremes[ya._id] = Axes.findExtremes(ya, l.concat(h), {padded: true}); + trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), {padded: true}); if(cd.length) { cd[0].t = { diff --git a/test/jasmine/tests/finance_test.js b/test/jasmine/tests/finance_test.js index 7d721f7b29d..9d294eae626 100644 --- a/test/jasmine/tests/finance_test.js +++ b/test/jasmine/tests/finance_test.js @@ -983,6 +983,37 @@ describe('finance charts updates:', function() { .then(done); }); + it('should work with typed array', function(done) { + var mockTA = { + open: new Float32Array(mock0.open), + high: new Float32Array(mock0.high), + low: new Float32Array(mock0.low), + close: new Float32Array(mock0.close) + }; + + var dataTA = [ + Lib.extendDeep({}, mockTA, {type: 'ohlc'}), + Lib.extendDeep({}, mockTA, {type: 'candlestick'}), + ]; + + var data0 = [ + Lib.extendDeep({}, mock0, {type: 'ohlc'}), + Lib.extendDeep({}, mock0, {type: 'candlestick'}), + ]; + + Plotly.plot(gd, dataTA) + .then(function() { + expect(countOHLCTraces()).toBe(1, '# of ohlc traces'); + expect(countBoxTraces()).toBe(1, '# of candlestick traces'); + }) + .then(function() { return Plotly.react(gd, data0); }) + .then(function() { + expect(countOHLCTraces()).toBe(1, '# of ohlc traces'); + expect(countBoxTraces()).toBe(1, '# of candlestick traces'); + }) + .catch(failTest) + .then(done); + }); }); describe('finance charts *special* handlers:', function() {