Skip to content

Commit

Permalink
fix 3419 not replace colorscale with scl when both provided
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jan 8, 2019
1 parent cabe0c6 commit f2c4791
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ exports.cleanData = function(data) {

// scl->scale, reversescl->reversescale
if('scl' in trace) {
trace.colorscale = trace.scl;
if(!('colorscale' in trace)) { trace.colorscale = trace.scl; }
delete trace.scl;
}
if('reversescl' in trace) {
trace.reversescale = trace.reversescl;
if(!('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 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).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 rename \'scl\' to \'colorscale\' 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).toBe(undefined);
});

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

0 comments on commit f2c4791

Please sign in to comment.