Skip to content

Commit a326778

Browse files
committed
fix and 🔒 ohlc tickwidth edits
1 parent 8f23ef5 commit a326778

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/traces/ohlc/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = {
110110
max: 0.5,
111111
dflt: 0.3,
112112
role: 'style',
113-
editType: 'calcIfAutorange',
113+
editType: 'calc',
114114
description: [
115115
'Sets the width of the open/close tick marks',
116116
'relative to the *x* minimal interval.'

test/jasmine/tests/finance_test.js

+52
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,58 @@ describe('finance charts updates:', function() {
931931
.then(done);
932932
});
933933

934+
it('should be able to update ohlc tickwidth', function(done) {
935+
var trace0 = Lib.extendDeep({}, mock0, {type: 'ohlc'});
936+
937+
function _assert(msg, exp) {
938+
var tickLen = gd.calcdata[0][0].t.tickLen;
939+
expect(tickLen)
940+
.toBe(exp.tickLen, 'tickLen val in calcdata - ' + msg);
941+
var pathd = d3.select(gd).select('.ohlc > path').attr('d');
942+
expect(pathd)
943+
.toBe(exp.pathd, 'path d attr - ' + msg);
944+
}
945+
946+
Plotly.plot(gd, [trace0], {
947+
xaxis: { rangeslider: {visible: false} }
948+
})
949+
.then(function() {
950+
_assert('auto rng / base tickwidth', {
951+
tickLen: 0.3,
952+
pathd: 'M13.5,137.63H33.75M33.75,75.04V206.53M54,80.3H33.75'
953+
});
954+
return Plotly.restyle(gd, 'tickwidth', 0);
955+
})
956+
.then(function() {
957+
_assert('auto rng / no tickwidth', {
958+
tickLen: 0,
959+
pathd: 'M33.75,137.63H33.75M33.75,75.04V206.53M33.75,80.3H33.75'
960+
});
961+
962+
return Plotly.update(gd, {
963+
tickwidth: null
964+
}, {
965+
'xaxis.range': [0, 8],
966+
'yaxis.range': [30, 36]
967+
});
968+
})
969+
.then(function() {
970+
_assert('set rng / base tickwidth', {
971+
tickLen: 0.3,
972+
pathd: 'M-20.25,134.55H0M0,81V193.5M20.25,85.5H0'
973+
});
974+
return Plotly.restyle(gd, 'tickwidth', 0);
975+
})
976+
.then(function() {
977+
_assert('set rng / no tickwidth', {
978+
tickLen: 0,
979+
pathd: 'M0,134.55H0M0,81V193.5M0,85.5H0'
980+
});
981+
})
982+
.catch(failTest)
983+
.then(done);
984+
});
985+
934986
});
935987

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

0 commit comments

Comments
 (0)