Skip to content

Commit a7bb365

Browse files
committed
update title and tick labels while react to data with transitions
1 parent 8415187 commit a7bb365

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/plot_api/plot_api.js

+2
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,8 @@ function react(gd, data, layout, config) {
27692769
// when at least one animatable attribute has changed,
27702770
// N.B. config changed aren't animatable
27712771
if(newFullLayout.transition && !configChanged && (restyleFlags.anim || relayoutFlags.anim)) {
2772+
if(relayoutFlags.ticks) seq.push(subroutines.doTicksRelayout);
2773+
27722774
Plots.doCalcdata(gd);
27732775
subroutines.doAutoRangeAndConstraints(gd);
27742776

test/jasmine/tests/titles_test.js

+57
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,63 @@ describe('Titles can be updated', function() {
621621
}
622622
});
623623

624+
describe('Titles and labels', function() {
625+
'use strict';
626+
627+
var gd;
628+
beforeEach(function() { gd = createGraphDiv(); });
629+
afterEach(destroyGraphDiv);
630+
631+
it('should react with transition', function(done) {
632+
Plotly.newPlot(gd, {
633+
data: [
634+
{
635+
type: 'bar',
636+
x: ['a', 'b'],
637+
y: [1, 2],
638+
}
639+
],
640+
layout: {
641+
title: {
642+
text: 'OLD'
643+
},
644+
xaxis: {
645+
title: {
646+
text: 'x-old'
647+
}
648+
}
649+
}
650+
}).then(function() {
651+
Plotly.react(gd, {
652+
data: [
653+
{
654+
type: 'bar',
655+
x: ['b', 'a'],
656+
y: [3, 2],
657+
}
658+
],
659+
layout: {
660+
title: {
661+
text: 'NEW'
662+
},
663+
xaxis: {
664+
title: {
665+
text: 'x-new'
666+
}
667+
},
668+
transition: { duration: 500 }
669+
}
670+
});
671+
}).then(function() {
672+
expectTitle('NEW');
673+
expect(xTitleSel().text()).toBe('x-new');
674+
expect(d3.select('.xtick').text()).toBe('b');
675+
})
676+
.catch(fail)
677+
.then(done);
678+
});
679+
});
680+
624681
describe('Titles support setting custom font properties', function() {
625682
'use strict';
626683

0 commit comments

Comments
 (0)