From 3fbb4600410180bc83c590a8f400f32cc72d9a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 6 Feb 2017 22:37:59 -0500 Subject: [PATCH 1/3] ensure empty candlestick trace don't lead to autotyped 'category' x-axis - box traces have a special algo to handle the case where trace 'name' can appear on axis ticks. --- src/plots/cartesian/axis_defaults.js | 1 + test/jasmine/tests/finance_test.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/plots/cartesian/axis_defaults.js b/src/plots/cartesian/axis_defaults.js index 21fbe0585cd..9fbfafe9171 100644 --- a/src/plots/cartesian/axis_defaults.js +++ b/src/plots/cartesian/axis_defaults.js @@ -207,6 +207,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { return ( Registry.traceIs(trace, 'box') && + trace._fullInput.type === 'box' && axLetter === posLetter && trace[posLetter] === undefined && trace[posLetter + '0'] === undefined diff --git a/test/jasmine/tests/finance_test.js b/test/jasmine/tests/finance_test.js index 608a33aea4b..ef217bb9c0e 100644 --- a/test/jasmine/tests/finance_test.js +++ b/test/jasmine/tests/finance_test.js @@ -367,6 +367,13 @@ describe('finance charts defaults:', function() { expect(fullTrace.xcalendar).toBe(i < 2 ? 'hebrew' : 'julian'); }); }); + + it('should make empty candlestick traces autotype to *linear* (as opposed to real box traces)', function() { + var trace0 = { type: 'candlestick' }; + var out = _supply([trace0], { xaxis: {} }); + + expect(out._fullLayout.xaxis.type).toEqual('linear'); + }); }); describe('finance charts calc transforms:', function() { From 3a30ef22a1ebece11cb710241d0e7477623be497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 8 Feb 2017 14:12:38 -0500 Subject: [PATCH 2/3] robustify is-candlestick check in setAutoType --- src/plots/cartesian/axis_defaults.js | 8 +++++--- src/traces/candlestick/index.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plots/cartesian/axis_defaults.js b/src/plots/cartesian/axis_defaults.js index 9fbfafe9171..9bee70613d2 100644 --- a/src/plots/cartesian/axis_defaults.js +++ b/src/plots/cartesian/axis_defaults.js @@ -203,11 +203,13 @@ function getBoxPosLetter(trace) { } function isBoxWithoutPositionCoords(trace, axLetter) { - var posLetter = getBoxPosLetter(trace); + var posLetter = getBoxPosLetter(trace), + isBox = Registry.traceIs(trace, 'box'), + isCandlestick = isBox && Registry.traceIs(trace._fullInput || {}, 'candlestick'); return ( - Registry.traceIs(trace, 'box') && - trace._fullInput.type === 'box' && + isBox && + !isCandlestick && axLetter === posLetter && trace[posLetter] === undefined && trace[posLetter + '0'] === undefined diff --git a/src/traces/candlestick/index.js b/src/traces/candlestick/index.js index e0203edb797..13764ecbabe 100644 --- a/src/traces/candlestick/index.js +++ b/src/traces/candlestick/index.js @@ -15,7 +15,7 @@ module.exports = { moduleType: 'trace', name: 'candlestick', basePlotModule: require('../../plots/cartesian'), - categories: ['cartesian', 'showLegend'], + categories: ['cartesian', 'showLegend', 'candlestick'], meta: { description: [ 'The candlestick is a style of financial chart describing', From f2c47992a04b74ad68398a345d03f7d248beb91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 8 Feb 2017 14:15:58 -0500 Subject: [PATCH 3/3] rm useless logic --- src/plots/cartesian/axis_defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plots/cartesian/axis_defaults.js b/src/plots/cartesian/axis_defaults.js index 9bee70613d2..e4e99bf8294 100644 --- a/src/plots/cartesian/axis_defaults.js +++ b/src/plots/cartesian/axis_defaults.js @@ -205,7 +205,7 @@ function getBoxPosLetter(trace) { function isBoxWithoutPositionCoords(trace, axLetter) { var posLetter = getBoxPosLetter(trace), isBox = Registry.traceIs(trace, 'box'), - isCandlestick = isBox && Registry.traceIs(trace._fullInput || {}, 'candlestick'); + isCandlestick = Registry.traceIs(trace._fullInput || {}, 'candlestick'); return ( isBox &&