Skip to content

Commit 5d9bc08

Browse files
committed
extracting out class names
1 parent 09ab60c commit 5d9bc08

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

src/components/colorbar/constants.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright 2012-2017, 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+
'use strict';
10+
11+
module.exports = {
12+
cn: {
13+
colorbar: 'colorbar',
14+
cbbg: 'cbbg',
15+
cbfill: 'cbfill',
16+
cbfills: 'cbfills',
17+
cbline: 'cbline',
18+
cblines: 'cblines',
19+
cbaxis: 'cbaxis',
20+
cbtitleunshift: 'cbtitleunshift',
21+
cbtitle: 'cbtitle',
22+
cboutline: 'cboutline',
23+
crisp: 'crisp',
24+
jsPlaceholder: 'js-placeholder'
25+
}
26+
};

src/components/colorbar/draw.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var handleAxisPositionDefaults = require('../../plots/cartesian/position_default
3131
var axisLayoutAttrs = require('../../plots/cartesian/layout_attributes');
3232

3333
var attributes = require('./attributes');
34-
34+
var cn = require('./constants').cn;
3535

3636
module.exports = function draw(gd, id) {
3737
// opts: options object, containing everything from attributes
@@ -248,16 +248,16 @@ module.exports = function draw(gd, id) {
248248
// now draw the elements
249249
var container = fullLayout._infolayer.selectAll('g.' + id).data([0]);
250250
container.enter().append('g').classed(id, true)
251-
.classed('colorbar', true)
251+
.classed(cn.colorbar, true)
252252
.each(function() {
253253
var s = d3.select(this);
254-
s.append('rect').classed('cbbg', true);
255-
s.append('g').classed('cbfills', true);
256-
s.append('g').classed('cblines', true);
257-
s.append('g').classed('cbaxis', true).classed('crisp', true);
258-
s.append('g').classed('cbtitleunshift', true)
259-
.append('g').classed('cbtitle', true);
260-
s.append('rect').classed('cboutline', true);
254+
s.append('rect').classed(cn.cbbg, true);
255+
s.append('g').classed(cn.cbfills, true);
256+
s.append('g').classed(cn.cblines, true);
257+
s.append('g').classed(cn.cbaxis, true).classed(cn.crisp, true);
258+
s.append('g').classed(cn.cbtitleunshift, true)
259+
.append('g').classed(cn.cbtitle, true);
260+
s.append('rect').classed(cn.cboutline, true);
261261
s.select('.cbtitle').datum(0);
262262
});
263263
container.attr('transform', 'translate(' + Math.round(gs.l) +
@@ -316,7 +316,7 @@ module.exports = function draw(gd, id) {
316316
}
317317
}
318318
else if(titleText.node() &&
319-
!titleText.classed('js-placeholder')) {
319+
!titleText.classed(cn.jsPlaceholder)) {
320320
titleHeight = Drawing.bBox(titleText.node()).height;
321321
}
322322
if(titleHeight) {
@@ -349,7 +349,7 @@ module.exports = function draw(gd, id) {
349349
.selectAll('rect.cbfill')
350350
.data(filllevels);
351351
fills.enter().append('rect')
352-
.classed('cbfill', true)
352+
.classed(cn.cbfill, true)
353353
.style('stroke', 'none');
354354
fills.exit().remove();
355355
fills.each(function(d, i) {
@@ -390,7 +390,7 @@ module.exports = function draw(gd, id) {
390390
.data(opts.line.color && opts.line.width ?
391391
linelevels : []);
392392
lines.enter().append('path')
393-
.classed('cbline', true);
393+
.classed(cn.cbline, true);
394394
lines.exit().remove();
395395
lines.each(function(d) {
396396
d3.select(this)
@@ -480,7 +480,7 @@ module.exports = function draw(gd, id) {
480480
var innerWidth = thickPx + opts.outlinewidth / 2 +
481481
Drawing.bBox(cbAxisOut._axislayer.node()).width;
482482
titleEl = titleCont.select('text');
483-
if(titleEl.node() && !titleEl.classed('js-placeholder')) {
483+
if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) {
484484
var mathJaxNode = titleCont
485485
.select('.h' + cbAxisOut._id + 'title-math-group')
486486
.node(),

src/traces/choropleth/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = extendFlat({
4848
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
4949
editType: 'calc',
5050
flags: ['location', 'z', 'text', 'name']
51-
}),
51+
})
5252
},
5353
extendDeepAll({}, colorscaleAttrs, {
5454
zmax: {editType: 'calc'},

0 commit comments

Comments
 (0)