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

Re-add support for passing title as string #7230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update jasmine tests
  • Loading branch information
emilykl committed Oct 16, 2024
commit 42caf57c3b392db9e988255412435acbeaa0109b
18 changes: 18 additions & 0 deletions 18 test/jasmine/tests/funnelarea_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,24 @@ describe('Funnelarea traces', function() {
.then(done, done.fail);
});

it('should be able to restyle title despite using deprecated title-as-string', function(done) {
Plotly.newPlot(gd, [{
type: 'funnelarea',
values: [1, 2, 3],
title: 'yo',
}])
.then(function() {
_assertTitle('base', 'yo', 'rgb(0, 0, 0)');
return Plotly.restyle(gd, {
title: 'oy',
});
})
.then(function() {
_assertTitle('base', 'oy', 'rgb(0, 0, 0)');
})
.then(done, done.fail);
});

it('should be able to react with new text colors', function(done) {
Plotly.newPlot(gd, [{
type: 'funnelarea',
Expand Down
18 changes: 18 additions & 0 deletions 18 test/jasmine/tests/pie_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,24 @@ describe('Pie traces', function() {
.then(done, done.fail);
});

it('should be able to restyle title despite using deprecated title-as-string', function(done) {
Plotly.newPlot(gd, [{
type: 'funnelarea',
values: [1, 2, 3],
title: 'yo',
}])
.then(function() {
_assertTitle('base', 'yo', 'rgb(0, 0, 0)');
return Plotly.restyle(gd, {
title: 'oy',
});
})
.then(function() {
_assertTitle('base', 'oy', 'rgb(0, 0, 0)');
})
.then(done, done.fail);
});

it('should be able to react with new text colors', function(done) {
Plotly.newPlot(gd, [{
type: 'pie',
Expand Down
24 changes: 24 additions & 0 deletions 24 test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,30 @@ describe('Test plot api', function() {
.then(assertSizeAndThen(543, 432, true, 'final back to autosize'))
.then(done, done.fail);
});

it('passes update data back to plotly_relayout unmodified ' +
'even if deprecated title-as-string has been used', function(done) {
Plotly.newPlot(gd, [{y: [1, 3, 2]}])
.then(function() {
gd.on('plotly_relayout', function(eventData) {
expect(eventData).toEqual({
title: 'Plotly chart',
'xaxis.title': 'X',
'yaxis.title': 'Y',
'polar.radialaxis.title': 'Radial'
});
done();
});

return Plotly.relayout(gd, {
title: 'Plotly chart',
'xaxis.title': 'X',
'yaxis.title': 'Y',
'polar.radialaxis.title': 'Radial'
});
})
.then(done, done.fail);
});
});

describe('Plotly.relayout subroutines switchboard', function() {
Expand Down
80 changes: 80 additions & 0 deletions 80 test/jasmine/tests/titles_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ describe('Plot title', function() {
.then(done, done.fail);
});

it('can still be defined as `layout.title` to ensure backwards-compatibility', function(done) {
Plotly.newPlot(gd, data, {title: 'Plotly line chart'})
.then(function() {
expectTitle('Plotly line chart');
expectDefaultCenteredPosition(gd);
})
.then(done, done.fail);
});

it('can be updated via `relayout`', function(done) {
Plotly.newPlot(gd, data, { title: { text: 'Plotly line chart' } })
.then(expectTitleFn('Plotly line chart'))
Expand Down Expand Up @@ -619,6 +628,23 @@ describe('Titles can be updated', function() {
'xaxis.title.text': NEW_XTITLE,
'yaxis.title.text': NEW_YTITLE
}
},
{
desc: 'despite passing title only as a string (backwards-compatibility)',
update: {
title: NEW_TITLE,
xaxis: {title: NEW_XTITLE},
yaxis: {title: NEW_YTITLE}
}
},
{
desc: 'despite passing title only as a string using string attributes ' +
'(backwards-compatibility)',
update: {
title: NEW_TITLE,
'xaxis.title': NEW_XTITLE,
'yaxis.title': NEW_YTITLE
}
Comment on lines +631 to +647
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj These tests should also be included in #7262 , right?

}
].forEach(function(testCase) {
it('via `Plotly.relayout` ' + testCase.desc, function(done) {
Expand Down Expand Up @@ -869,6 +895,60 @@ describe('Title fonts can be updated', function() {
}
});

describe('Titles for multiple axes', function() {
'use strict';

var data = [
{x: [1, 2, 3], y: [1, 2, 3], xaxis: 'x', yaxis: 'y'},
{x: [1, 2, 3], y: [3, 2, 1], xaxis: 'x2', yaxis: 'y2'}
];
var multiAxesLayout = {
xaxis: { title: 'X-Axis 1' },
xaxis2: {
title: 'X-Axis 2',
side: 'top'
},
yaxis: { title: 'Y-Axis 1' },
yaxis2: {
title: 'Y-Axis 2',
side: 'right'
}
};
var gd;

beforeEach(function() {
gd = createGraphDiv();
});

afterEach(destroyGraphDiv);

it('still supports deprecated title-as-string (backwards-compatibility)', function(done) {
Plotly.newPlot(gd, data, multiAxesLayout)
.then(function() {
expect(xTitleSel(1).text()).toBe('X-Axis 1');
expect(xTitleSel(2).text()).toBe('X-Axis 2');
expect(yTitleSel(1).text()).toBe('Y-Axis 1');
expect(yTitleSel(2).text()).toBe('Y-Axis 2');
})
.then(done, done.fail);
});

it('can be updated using deprecated title-as-string (backwards-compatibility)', function(done) {
Plotly.newPlot(gd, data, multiAxesLayout)
.then(function() {
return Plotly.relayout(gd, {
'xaxis2.title': '2nd X-Axis',
'yaxis2.title': '2nd Y-Axis',
});
})
.then(function() {
expect(xTitleSel(2).text()).toBe('2nd X-Axis');
expect(yTitleSel(2).text()).toBe('2nd Y-Axis');
})
.then(done, done.fail);
});
});

// TODO: Add in tests for interactions with other automargined elements
describe('Title automargining', function() {
'use strict';
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.