Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ exports.cleanData = function(data) {
}

// scl->scale, reversescl->reversescale
if('scl' in trace) {
if('scl' in trace && !('colorscale' in trace)) {
trace.colorscale = trace.scl;
delete trace.scl;
}
if('reversescl' in trace) {
if('reversescl' in trace && !('reversescale' in trace)) {
trace.reversescale = trace.reversescl;
delete trace.reversescl;
}
Expand Down
46 changes: 46 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,52 @@ describe('Test plot api', function() {

afterEach(destroyGraphDiv);

it('should rename \'scl\' to \'colorscale\' when colorscale is not defined', function() {
var data = [{
type: 'heatmap',
scl: 'Blues'
}];

Plotly.plot(gd, data);
expect(gd.data[0].colorscale).toBe('Blues');
expect(gd.data[0].scl).toBe(undefined);
});

it('should not delete rename \'scl\' to \'colorscale\' when colorscale is defined ', function() {
var data = [{
type: 'heatmap',
colorscale: 'Greens',
scl: 'Reds'
}];

Plotly.plot(gd, data);
expect(gd.data[0].colorscale).toBe('Greens');
expect(gd.data[0].scl).not.toBe(undefined);
});

it('should rename \'reversescl\' to \'reversescale\' when colorscale is not defined', function() {
var data = [{
type: 'heatmap',
reversescl: true
}];

Plotly.plot(gd, data);
expect(gd.data[0].reversescale).toBe(true);
expect(gd.data[0].reversescl).toBe(undefined);
});

it('should not delete & rename \'reversescl\' to \'reversescale\' when colorscale is defined', function() {
var data = [{
type: 'heatmap',
reversescale: true,
reversescl: false
}];

Plotly.plot(gd, data);
expect(gd.data[0].reversescale).toBe(true);
expect(gd.data[0].reversescl).not.toBe(undefined);
});

it('should rename \'YIGnBu\' colorscales YlGnBu (2dMap case)', function() {
var data = [{
type: 'heatmap',
Expand Down