|
| 1 | +/** |
| 2 | +* Copyright 2012-2016, 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 | +var fontAttrs = require('../../plots/font_attributes'); |
| 12 | +var padAttrs = require('../../plots/pad_attributes'); |
| 13 | +var extendFlat = require('../../lib/extend').extendFlat; |
| 14 | +var animationAttrs = require('../../plots/animation_attributes'); |
| 15 | +var constants = require('./constants'); |
| 16 | + |
| 17 | +var stepsAttrs = { |
| 18 | + _isLinkedToArray: true, |
| 19 | + |
| 20 | + method: { |
| 21 | + valType: 'enumerated', |
| 22 | + values: ['restyle', 'relayout', 'animate', 'update'], |
| 23 | + dflt: 'restyle', |
| 24 | + role: 'info', |
| 25 | + description: [ |
| 26 | + 'Sets the Plotly method to be called when the slider value is changed.' |
| 27 | + ].join(' ') |
| 28 | + }, |
| 29 | + args: { |
| 30 | + valType: 'info_array', |
| 31 | + role: 'info', |
| 32 | + freeLength: true, |
| 33 | + items: [ |
| 34 | + { valType: 'any' }, |
| 35 | + { valType: 'any' }, |
| 36 | + { valType: 'any' } |
| 37 | + ], |
| 38 | + description: [ |
| 39 | + 'Sets the arguments values to be passed to the Plotly', |
| 40 | + 'method set in `method` on slide.' |
| 41 | + ].join(' ') |
| 42 | + }, |
| 43 | + label: { |
| 44 | + valType: 'string', |
| 45 | + role: 'info', |
| 46 | + description: 'Sets the text label to appear on the slider' |
| 47 | + }, |
| 48 | + value: { |
| 49 | + valType: 'string', |
| 50 | + role: 'info', |
| 51 | + description: [ |
| 52 | + 'Sets the value of the slider step, used to refer to the step programatically.', |
| 53 | + 'Defaults to the slider label if not provided.' |
| 54 | + ].join(' ') |
| 55 | + } |
| 56 | +}; |
| 57 | + |
| 58 | +module.exports = { |
| 59 | + visible: { |
| 60 | + valType: 'boolean', |
| 61 | + role: 'info', |
| 62 | + dflt: true, |
| 63 | + description: [ |
| 64 | + 'Determines whether or not the slider is visible.' |
| 65 | + ].join(' ') |
| 66 | + }, |
| 67 | + |
| 68 | + active: { |
| 69 | + valType: 'number', |
| 70 | + role: 'info', |
| 71 | + min: -10, |
| 72 | + dflt: 0, |
| 73 | + description: [ |
| 74 | + 'Determines which button (by index starting from 0) is', |
| 75 | + 'considered active.' |
| 76 | + ].join(' ') |
| 77 | + }, |
| 78 | + |
| 79 | + steps: stepsAttrs, |
| 80 | + |
| 81 | + lenmode: { |
| 82 | + valType: 'enumerated', |
| 83 | + values: ['fraction', 'pixels'], |
| 84 | + role: 'info', |
| 85 | + dflt: 'fraction', |
| 86 | + description: [ |
| 87 | + 'Determines whether this slider length', |
| 88 | + 'is set in units of plot *fraction* or in *pixels.', |
| 89 | + 'Use `len` to set the value.' |
| 90 | + ].join(' ') |
| 91 | + }, |
| 92 | + len: { |
| 93 | + valType: 'number', |
| 94 | + min: 0, |
| 95 | + dflt: 1, |
| 96 | + role: 'style', |
| 97 | + description: [ |
| 98 | + 'Sets the length of the slider', |
| 99 | + 'This measure excludes the padding of both ends.', |
| 100 | + 'That is, the slider\'s length is this length minus the', |
| 101 | + 'padding on both ends.' |
| 102 | + ].join(' ') |
| 103 | + }, |
| 104 | + x: { |
| 105 | + valType: 'number', |
| 106 | + min: -2, |
| 107 | + max: 3, |
| 108 | + dflt: -0.05, |
| 109 | + role: 'style', |
| 110 | + description: 'Sets the x position (in normalized coordinates) of the slider.' |
| 111 | + }, |
| 112 | + pad: extendFlat({}, padAttrs, { |
| 113 | + description: 'Set the padding of the slider component along each side.' |
| 114 | + }), |
| 115 | + xanchor: { |
| 116 | + valType: 'enumerated', |
| 117 | + values: ['auto', 'left', 'center', 'right'], |
| 118 | + dflt: 'left', |
| 119 | + role: 'info', |
| 120 | + description: [ |
| 121 | + 'Sets the slider\'s horizontal position anchor.', |
| 122 | + 'This anchor binds the `x` position to the *left*, *center*', |
| 123 | + 'or *right* of the range selector.' |
| 124 | + ].join(' ') |
| 125 | + }, |
| 126 | + y: { |
| 127 | + valType: 'number', |
| 128 | + min: -2, |
| 129 | + max: 3, |
| 130 | + dflt: 1, |
| 131 | + role: 'style', |
| 132 | + description: 'Sets the y position (in normalized coordinates) of the slider.' |
| 133 | + }, |
| 134 | + yanchor: { |
| 135 | + valType: 'enumerated', |
| 136 | + values: ['auto', 'top', 'middle', 'bottom'], |
| 137 | + dflt: 'bottom', |
| 138 | + role: 'info', |
| 139 | + description: [ |
| 140 | + 'Sets the slider\'s vertical position anchor', |
| 141 | + 'This anchor binds the `y` position to the *top*, *middle*', |
| 142 | + 'or *bottom* of the range selector.' |
| 143 | + ].join(' ') |
| 144 | + }, |
| 145 | + |
| 146 | + transition: { |
| 147 | + duration: { |
| 148 | + valType: 'number', |
| 149 | + role: 'info', |
| 150 | + min: 0, |
| 151 | + dflt: 150, |
| 152 | + description: 'Sets the duration of the slider transition' |
| 153 | + }, |
| 154 | + easing: { |
| 155 | + valType: 'enumerated', |
| 156 | + values: animationAttrs.transition.easing.values, |
| 157 | + role: 'info', |
| 158 | + dflt: 'cubic-in-out', |
| 159 | + description: 'Sets the easing function of the slider transition' |
| 160 | + }, |
| 161 | + }, |
| 162 | + |
| 163 | + currentvalue: { |
| 164 | + visible: { |
| 165 | + valType: 'boolean', |
| 166 | + role: 'info', |
| 167 | + dflt: true, |
| 168 | + description: [ |
| 169 | + 'Shows the currently-selected value above the slider.' |
| 170 | + ].join(' ') |
| 171 | + }, |
| 172 | + |
| 173 | + xanchor: { |
| 174 | + valType: 'enumerated', |
| 175 | + values: ['left', 'center', 'right'], |
| 176 | + dflt: 'left', |
| 177 | + role: 'info', |
| 178 | + description: [ |
| 179 | + 'The alignment of the value readout relative to the length of the slider.' |
| 180 | + ].join(' ') |
| 181 | + }, |
| 182 | + |
| 183 | + offset: { |
| 184 | + valType: 'number', |
| 185 | + dflt: 10, |
| 186 | + role: 'info', |
| 187 | + description: [ |
| 188 | + 'The amount of space, in pixels, between the current value label', |
| 189 | + 'and the slider.' |
| 190 | + ].join(' ') |
| 191 | + }, |
| 192 | + |
| 193 | + prefix: { |
| 194 | + valType: 'string', |
| 195 | + role: 'info', |
| 196 | + description: 'When currentvalue.visible is true, this sets the prefix of the label.' |
| 197 | + }, |
| 198 | + |
| 199 | + suffix: { |
| 200 | + valType: 'string', |
| 201 | + role: 'info', |
| 202 | + description: 'When currentvalue.visible is true, this sets the suffix of the label.' |
| 203 | + }, |
| 204 | + |
| 205 | + font: extendFlat({}, fontAttrs, { |
| 206 | + description: 'Sets the font of the current value label text.' |
| 207 | + }), |
| 208 | + }, |
| 209 | + |
| 210 | + font: extendFlat({}, fontAttrs, { |
| 211 | + description: 'Sets the font of the slider step labels.' |
| 212 | + }), |
| 213 | + |
| 214 | + activebgcolor: { |
| 215 | + valType: 'color', |
| 216 | + role: 'style', |
| 217 | + dflt: constants.gripBgActiveColor, |
| 218 | + description: [ |
| 219 | + 'Sets the background color of the slider grip', |
| 220 | + 'while dragging.' |
| 221 | + ].join(' ') |
| 222 | + }, |
| 223 | + bgcolor: { |
| 224 | + valType: 'color', |
| 225 | + role: 'style', |
| 226 | + dflt: constants.railBgColor, |
| 227 | + description: 'Sets the background color of the slider.' |
| 228 | + }, |
| 229 | + bordercolor: { |
| 230 | + valType: 'color', |
| 231 | + dflt: constants.railBorderColor, |
| 232 | + role: 'style', |
| 233 | + description: 'Sets the color of the border enclosing the slider.' |
| 234 | + }, |
| 235 | + borderwidth: { |
| 236 | + valType: 'number', |
| 237 | + min: 0, |
| 238 | + dflt: constants.railBorderWidth, |
| 239 | + role: 'style', |
| 240 | + description: 'Sets the width (in px) of the border enclosing the slider.' |
| 241 | + }, |
| 242 | + ticklen: { |
| 243 | + valType: 'number', |
| 244 | + min: 0, |
| 245 | + dflt: constants.tickLength, |
| 246 | + role: 'style', |
| 247 | + description: 'Sets the length in pixels of step tick marks' |
| 248 | + }, |
| 249 | + tickcolor: { |
| 250 | + valType: 'color', |
| 251 | + dflt: constants.tickColor, |
| 252 | + role: 'style', |
| 253 | + description: 'Sets the color of the border enclosing the slider.' |
| 254 | + }, |
| 255 | + tickwidth: { |
| 256 | + valType: 'number', |
| 257 | + min: 0, |
| 258 | + dflt: 1, |
| 259 | + role: 'style', |
| 260 | + description: 'Sets the tick width (in px).' |
| 261 | + }, |
| 262 | + minorticklen: { |
| 263 | + valType: 'number', |
| 264 | + min: 0, |
| 265 | + dflt: constants.minorTickLength, |
| 266 | + role: 'style', |
| 267 | + description: 'Sets the length in pixels of minor step tick marks' |
| 268 | + }, |
| 269 | +}; |
0 commit comments