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
60 changes: 60 additions & 0 deletions src/components/colorbar/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright 2012-2015, 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';

var Axes = require('../../plots/cartesian/axes');
var Lib = require('../../lib');

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


module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
var colorbarOut = containerOut.colorbar = {},
colorbarIn = containerIn.colorbar || {};

function coerce(attr, dflt) {
return Lib.coerce(colorbarIn, colorbarOut, attributes, attr, dflt);
}

var thicknessmode = coerce('thicknessmode');
coerce('thickness', (thicknessmode === 'fraction') ?
30 / (layout.width - layout.margin.l - layout.margin.r) :
30
);

var lenmode = coerce('lenmode');
coerce('len', (lenmode === 'fraction') ?
1 :
layout.height - layout.margin.t - layout.margin.b
);

coerce('x');
coerce('xanchor');
coerce('xpad');
coerce('y');
coerce('yanchor');
coerce('ypad');
Lib.noneOrAll(colorbarIn, colorbarOut, ['x', 'y']);

coerce('outlinecolor');
coerce('outlinewidth');
coerce('bordercolor');
coerce('borderwidth');
coerce('bgcolor');

Axes.handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear');

Axes.handleTickDefaults(colorbarIn, colorbarOut, coerce, 'linear',
{outerTicks: false, font: layout.font, noHover: true});

coerce('title');
Lib.coerceFont(coerce, 'titlefont', layout.font);
coerce('titleside');
};
Loading