Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 777709e

Browse files
committed
move hasColorbar check in colorbar/
1 parent 5f573c0 commit 777709e

File tree

4 files changed

+49
-30
lines changed

4 files changed

+49
-30
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright 2012-2015, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
13+
module.exports = function hasColorbar(container) {
14+
return (
15+
typeof container.colorbar === 'object' &&
16+
container.colorbar !== null
17+
);
18+
};

src/components/colorscale/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ colorscale.hasColorscale = function(trace, containerStr) {
109109
);
110110
};
111111

112-
colorscale.hasColorbar = function(container) {
113-
return typeof container.colorbar==='object' && container.colorbar!==null;
114-
};
115-
116112
colorscale.handleDefaults = function(traceIn, traceOut, layout, coerce, opts) {
117113
var prefix = opts.prefix,
118114
cLetter = opts.cLetter,

test/jasmine/tests/colorbar_test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var Colorbar = require('@src/components/colorbar');
2+
3+
describe('Test colorbar:', function () {
4+
'use strict';
5+
6+
describe('hasColorbar', function() {
7+
var hasColorbar = Colorbar.hasColorbar,
8+
trace;
9+
10+
it('should return true when marker colorbar is defined', function() {
11+
trace = {
12+
marker: {
13+
colorbar: {},
14+
line: {
15+
colorbar: {}
16+
}
17+
}
18+
};
19+
expect(hasColorbar(trace.marker)).toBe(true);
20+
expect(hasColorbar(trace.marker.line)).toBe(true);
21+
22+
trace = {
23+
marker: {
24+
line: {}
25+
}
26+
};
27+
expect(hasColorbar(trace.marker)).toBe(false);
28+
expect(hasColorbar(trace.marker.line)).toBe(false);
29+
});
30+
});
31+
});

test/jasmine/tests/colorscale_test.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,32 +180,6 @@ describe('Test colorscale:', function () {
180180
});
181181
});
182182

183-
describe('hasColorbar', function() {
184-
var hasColorbar = Plotly.Colorscale.hasColorbar,
185-
trace;
186-
187-
it('should return true when marker colorbar is defined', function() {
188-
trace = {
189-
marker: {
190-
colorbar: {},
191-
line: {
192-
colorbar: {}
193-
}
194-
}
195-
};
196-
expect(hasColorbar(trace.marker)).toBe(true);
197-
expect(hasColorbar(trace.marker.line)).toBe(true);
198-
199-
trace = {
200-
marker: {
201-
line: {}
202-
}
203-
};
204-
expect(hasColorbar(trace.marker)).toBe(false);
205-
expect(hasColorbar(trace.marker.line)).toBe(false);
206-
});
207-
});
208-
209183
describe('handleDefaults (heatmap-like version)', function() {
210184
var handleDefaults = Plotly.Colorscale.handleDefaults,
211185
layout = {

0 commit comments

Comments
 (0)