Skip to content

Commit 3141c47

Browse files
committed
fix #3339 - typed arrays support for ohlc / candlestick traces
1 parent 9bbe295 commit 3141c47

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/traces/ohlc/calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) {
9292
}
9393
}
9494

95-
trace._extremes[ya._id] = Axes.findExtremes(ya, l.concat(h), {padded: true});
95+
trace._extremes[ya._id] = Axes.findExtremes(ya, Lib.concat(l, h), {padded: true});
9696

9797
if(cd.length) {
9898
cd[0].t = {

test/jasmine/tests/finance_test.js

+31
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,37 @@ describe('finance charts updates:', function() {
983983
.then(done);
984984
});
985985

986+
it('should work with typed array', function(done) {
987+
var mockTA = {
988+
open: new Float32Array(mock0.open),
989+
high: new Float32Array(mock0.high),
990+
low: new Float32Array(mock0.low),
991+
close: new Float32Array(mock0.close)
992+
};
993+
994+
var dataTA = [
995+
Lib.extendDeep({}, mockTA, {type: 'ohlc'}),
996+
Lib.extendDeep({}, mockTA, {type: 'candlestick'}),
997+
];
998+
999+
var data0 = [
1000+
Lib.extendDeep({}, mock0, {type: 'ohlc'}),
1001+
Lib.extendDeep({}, mock0, {type: 'candlestick'}),
1002+
];
1003+
1004+
Plotly.plot(gd, dataTA)
1005+
.then(function() {
1006+
expect(countOHLCTraces()).toBe(1, '# of ohlc traces');
1007+
expect(countBoxTraces()).toBe(1, '# of candlestick traces');
1008+
})
1009+
.then(function() { return Plotly.react(gd, data0); })
1010+
.then(function() {
1011+
expect(countOHLCTraces()).toBe(1, '# of ohlc traces');
1012+
expect(countBoxTraces()).toBe(1, '# of candlestick traces');
1013+
})
1014+
.catch(failTest)
1015+
.then(done);
1016+
});
9861017
});
9871018

9881019
describe('finance charts *special* handlers:', function() {

0 commit comments

Comments
 (0)