Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32ccae5

Browse files
authored
Merge pull request plotly#1359 from plotly/candlestick-no-data-ax-autotype
Ensure empty candlestick traces don't lead to autotyped 'category' x-axis
2 parents f523952 + f2c4799 commit 32ccae5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/plots/cartesian/axis_defaults.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,13 @@ function getBoxPosLetter(trace) {
203203
}
204204

205205
function isBoxWithoutPositionCoords(trace, axLetter) {
206-
var posLetter = getBoxPosLetter(trace);
206+
var posLetter = getBoxPosLetter(trace),
207+
isBox = Registry.traceIs(trace, 'box'),
208+
isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick');
207209

208210
return (
209-
Registry.traceIs(trace, 'box') &&
211+
isBox &&
212+
!isCandlestick &&
210213
axLetter === posLetter &&
211214
trace[posLetter] === undefined &&
212215
trace[posLetter + '0'] === undefined

src/traces/candlestick/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
moduleType: 'trace',
1616
name: 'candlestick',
1717
basePlotModule: require('../../plots/cartesian'),
18-
categories: ['cartesian', 'showLegend'],
18+
categories: ['cartesian', 'showLegend', 'candlestick'],
1919
meta: {
2020
description: [
2121
'The candlestick is a style of financial chart describing',

test/jasmine/tests/finance_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ describe('finance charts defaults:', function() {
367367
expect(fullTrace.xcalendar).toBe(i < 2 ? 'hebrew' : 'julian');
368368
});
369369
});
370+
371+
it('should make empty candlestick traces autotype to *linear* (as opposed to real box traces)', function() {
372+
var trace0 = { type: 'candlestick' };
373+
var out = _supply([trace0], { xaxis: {} });
374+
375+
expect(out._fullLayout.xaxis.type).toEqual('linear');
376+
});
370377
});
371378

372379
describe('finance charts calc transforms:', function() {

0 commit comments

Comments
 (0)