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
26 changes: 26 additions & 0 deletions src/components/colorbar/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
cn: {
colorbar: 'colorbar',
cbbg: 'cbbg',
cbfill: 'cbfill',
cbfills: 'cbfills',
cbline: 'cbline',
cblines: 'cblines',
cbaxis: 'cbaxis',
cbtitleunshift: 'cbtitleunshift',
cbtitle: 'cbtitle',
cboutline: 'cboutline',
crisp: 'crisp',
jsPlaceholder: 'js-placeholder'
}
};
25 changes: 13 additions & 12 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var handleAxisPositionDefaults = require('../../plots/cartesian/position_default
var axisLayoutAttrs = require('../../plots/cartesian/layout_attributes');

var attributes = require('./attributes');

var cn = require('./constants').cn;

module.exports = function draw(gd, id) {
// opts: options object, containing everything from attributes
Expand Down Expand Up @@ -248,15 +248,16 @@ module.exports = function draw(gd, id) {
// now draw the elements
var container = fullLayout._infolayer.selectAll('g.' + id).data([0]);
container.enter().append('g').classed(id, true)
.classed(cn.colorbar, true)
.each(function() {
var s = d3.select(this);
s.append('rect').classed('cbbg', true);
s.append('g').classed('cbfills', true);
s.append('g').classed('cblines', true);
s.append('g').classed('cbaxis', true).classed('crisp', true);
s.append('g').classed('cbtitleunshift', true)
.append('g').classed('cbtitle', true);
s.append('rect').classed('cboutline', true);
s.append('rect').classed(cn.cbbg, true);
s.append('g').classed(cn.cbfills, true);
s.append('g').classed(cn.cblines, true);
s.append('g').classed(cn.cbaxis, true).classed(cn.crisp, true);
s.append('g').classed(cn.cbtitleunshift, true)
.append('g').classed(cn.cbtitle, true);
s.append('rect').classed(cn.cboutline, true);
s.select('.cbtitle').datum(0);
});
container.attr('transform', 'translate(' + Math.round(gs.l) +
Expand Down Expand Up @@ -315,7 +316,7 @@ module.exports = function draw(gd, id) {
}
}
else if(titleText.node() &&
!titleText.classed('js-placeholder')) {
!titleText.classed(cn.jsPlaceholder)) {
titleHeight = Drawing.bBox(titleText.node()).height;
}
if(titleHeight) {
Expand Down Expand Up @@ -348,7 +349,7 @@ module.exports = function draw(gd, id) {
.selectAll('rect.cbfill')
.data(filllevels);
fills.enter().append('rect')
.classed('cbfill', true)
.classed(cn.cbfill, true)
.style('stroke', 'none');
fills.exit().remove();
fills.each(function(d, i) {
Expand Down Expand Up @@ -389,7 +390,7 @@ module.exports = function draw(gd, id) {
.data(opts.line.color && opts.line.width ?
linelevels : []);
lines.enter().append('path')
.classed('cbline', true);
.classed(cn.cbline, true);
lines.exit().remove();
lines.each(function(d) {
d3.select(this)
Expand Down Expand Up @@ -479,7 +480,7 @@ module.exports = function draw(gd, id) {
var innerWidth = thickPx + opts.outlinewidth / 2 +
Drawing.bBox(cbAxisOut._axislayer.node()).width;
titleEl = titleCont.select('text');
if(titleEl.node() && !titleEl.classed('js-placeholder')) {
if(titleEl.node() && !titleEl.classed(cn.jsPlaceholder)) {
var mathJaxNode = titleCont
.select('.h' + cbAxisOut._id + 'title-math-group')
.node(),
Expand Down
2 changes: 1 addition & 1 deletion src/traces/choropleth/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = extendFlat({
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
editType: 'calc',
flags: ['location', 'z', 'text', 'name']
}),
})
},
extendDeepAll({}, colorscaleAttrs, {
zmax: {editType: 'calc'},
Expand Down