Skip to content

Commit 5c94c05

Browse files
committed
finance: add re-calc attributes to restyle lists
1 parent dc8aaea commit 5c94c05

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/plot_api/plot_api.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ function _restyle(gd, aobj, _traces) {
12451245
'histfunc', 'histnorm', 'text',
12461246
'x', 'y', 'z',
12471247
'a', 'b', 'c',
1248+
'open', 'high', 'low', 'close',
12481249
'xtype', 'x0', 'dx', 'ytype', 'y0', 'dy', 'xaxis', 'yaxis',
12491250
'line.width',
12501251
'connectgaps', 'transpose', 'zsmooth',
@@ -1287,7 +1288,8 @@ function _restyle(gd, aobj, _traces) {
12871288
// TODO: could we break this out as well?
12881289
var autorangeAttrs = [
12891290
'marker', 'marker.size', 'textfont',
1290-
'boxpoints', 'jitter', 'pointpos', 'whiskerwidth', 'boxmean'
1291+
'boxpoints', 'jitter', 'pointpos', 'whiskerwidth', 'boxmean',
1292+
'tickwidth'
12911293
];
12921294

12931295
// replotAttrs attributes need a replot (because different

test/jasmine/tests/finance_test.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var Plotly = require('@lib/index');
22
var Plots = require('@src/plots/plots');
33
var Lib = require('@src/lib');
44

5+
var d3 = require('d3');
56
var createGraphDiv = require('../assets/create_graph_div');
67
var destroyGraphDiv = require('../assets/destroy_graph_div');
78

@@ -417,9 +418,34 @@ describe('finance charts updates:', function() {
417418
it('Plotly.restyle should work', function(done) {
418419
var trace0 = Lib.extendDeep({}, mock0, { type: 'ohlc' });
419420

420-
Plotly.plot(gd, [trace0]).then(function() {
421+
var path0;
421422

422-
// gotta test 'tickwidth' and 'whiskerwitdth'
423+
Plotly.plot(gd, [trace0]).then(function() {
424+
expect(gd.calcdata[0][0].x).toEqual(-0.05);
425+
expect(gd.calcdata[0][0].y).toEqual(33.01);
426+
427+
return Plotly.restyle(gd, 'tickwidth', 0.5);
428+
})
429+
.then(function() {
430+
expect(gd.calcdata[0][0].x).toEqual(-0.5);
431+
432+
return Plotly.restyle(gd, 'open', [[0, 30.75, 32.87, 31.62, 30.81, 32.75, 32.75, 32.87]]);
433+
})
434+
.then(function() {
435+
expect(gd.calcdata[0][0].y).toEqual(0);
436+
437+
return Plotly.restyle(gd, {
438+
type: 'candlestick',
439+
open: [[33.01, 33.31, 33.50, 32.06, 34.12, 33.05, 33.31, 33.50]]
440+
});
441+
})
442+
.then(function() {
443+
path0 = d3.select('path.box').attr('d');
444+
445+
return Plotly.restyle(gd, 'whiskerwidth', 0.2);
446+
})
447+
.then(function() {
448+
expect(d3.select('path.box').attr('d')).not.toEqual(path0);
423449

424450
done();
425451
});

0 commit comments

Comments
 (0)