|
| 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 | +var Axes = require('../../plots/cartesian/axes'); |
| 13 | +var Lib = require('../../lib'); |
| 14 | + |
| 15 | +var attributes = require('./attributes'); |
| 16 | + |
| 17 | + |
| 18 | +module.exports = function colorbarDefaults(containerIn, containerOut, layout) { |
| 19 | + var colorbarOut = containerOut.colorbar = {}, |
| 20 | + colorbarIn = containerIn.colorbar || {}; |
| 21 | + |
| 22 | + function coerce(attr, dflt) { |
| 23 | + return Lib.coerce(colorbarIn, colorbarOut, attributes, attr, dflt); |
| 24 | + } |
| 25 | + |
| 26 | + var thicknessmode = coerce('thicknessmode'); |
| 27 | + coerce('thickness', (thicknessmode === 'fraction') ? |
| 28 | + 30 / (layout.width - layout.margin.l - layout.margin.r) : |
| 29 | + 30 |
| 30 | + ); |
| 31 | + |
| 32 | + var lenmode = coerce('lenmode'); |
| 33 | + coerce('len', (lenmode === 'fraction') ? |
| 34 | + 1 : |
| 35 | + layout.height - layout.margin.t - layout.margin.b |
| 36 | + ); |
| 37 | + |
| 38 | + coerce('x'); |
| 39 | + coerce('xanchor'); |
| 40 | + coerce('xpad'); |
| 41 | + coerce('y'); |
| 42 | + coerce('yanchor'); |
| 43 | + coerce('ypad'); |
| 44 | + Lib.noneOrAll(colorbarIn, colorbarOut, ['x', 'y']); |
| 45 | + |
| 46 | + coerce('outlinecolor'); |
| 47 | + coerce('outlinewidth'); |
| 48 | + coerce('bordercolor'); |
| 49 | + coerce('borderwidth'); |
| 50 | + coerce('bgcolor'); |
| 51 | + |
| 52 | + Axes.handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear'); |
| 53 | + |
| 54 | + Axes.handleTickDefaults(colorbarIn, colorbarOut, coerce, 'linear', |
| 55 | + {outerTicks: false, font: layout.font, noHover: true}); |
| 56 | + |
| 57 | + coerce('title'); |
| 58 | + Lib.coerceFont(coerce, 'titlefont', layout.font); |
| 59 | + coerce('titleside'); |
| 60 | +}; |
0 commit comments