Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2b4c10

Browse filesBrowse files
committed
Pass back update data unmodified to plotly_relayout event handlers [882]
- ... even if deprecated layout attributes have been cleaned up internally. - Reason: to stay backwards-compatible with existing event handlers that count on the old titles structure for example.
1 parent 1117113 commit c2b4c10
Copy full SHA for c2b4c10

File tree

Expand file treeCollapse file tree

3 files changed

+28
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-3
lines changed

‎src/plot_api/plot_api.js

Copy file name to clipboardExpand all lines: src/plot_api/plot_api.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,7 @@ function _relayout(gd, aobj) {
18591859
var layout = gd.layout,
18601860
fullLayout = gd._fullLayout,
18611861
axes = Axes.list(gd),
1862+
eventData = Lib.extendDeepAll({}, aobj),
18621863
arrayEdits = {},
18631864
keys,
18641865
arrayStr,
@@ -2194,7 +2195,7 @@ function _relayout(gd, aobj) {
21942195
rangesAltered: rangesAltered,
21952196
undoit: undoit,
21962197
redoit: redoit,
2197-
eventData: Lib.extendDeep({}, redoit)
2198+
eventData: eventData
21982199
};
21992200
}
22002201

‎test/jasmine/tests/legend_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/legend_test.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ describe('legend interaction', function() {
14311431
});
14321432
gd.on('plotly_relayout', function(d) {
14331433
expect(typeof d).toBe('object');
1434-
expect(d.title.text).toBe('just clicked on trace #2');
1434+
expect(d.title).toBe('just clicked on trace #2');
14351435
done();
14361436
});
14371437
gd.on('plotly_restyle', function() {
@@ -1451,7 +1451,7 @@ describe('legend interaction', function() {
14511451
});
14521452
gd.on('plotly_relayout', function(d) {
14531453
expect(typeof d).toBe('object');
1454-
expect(d.title.text).toBe('just double clicked on trace #0');
1454+
expect(d.title).toBe('just double clicked on trace #0');
14551455
done();
14561456
});
14571457
gd.on('plotly_restyle', function() {

‎test/jasmine/tests/plot_api_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/plot_api_test.js
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,30 @@ describe('Test plot api', function() {
547547
.catch(failTest)
548548
.then(done);
549549
});
550+
551+
it('passes update data back to plotly_relayout unmodified ' +
552+
'even if deprecated attributes have been used', function(done) {
553+
Plotly.newPlot(gd, [{y: [1, 3, 2]}]);
554+
555+
gd.on('plotly_relayout', function(eventData) {
556+
expect(eventData).toEqual({
557+
'title': 'Plotly chart',
558+
'xaxis.title': 'X',
559+
'xaxis.titlefont': {color: 'green'},
560+
'yaxis.title': 'Y',
561+
'polar.radialaxis.title': 'Radial'
562+
});
563+
done();
564+
});
565+
566+
Plotly.relayout(gd, {
567+
'title': 'Plotly chart',
568+
'xaxis.title': 'X',
569+
'xaxis.titlefont': {color: 'green'},
570+
'yaxis.title': 'Y',
571+
'polar.radialaxis.title': 'Radial'
572+
});
573+
});
550574
});
551575

552576
describe('Plotly.relayout subroutines switchboard', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.