(dimensionIn, dimensionOut)
| 29 | } |
| 30 | |
| 31 | function dimensionDefaults(dimensionIn, dimensionOut) { |
| 32 | function coerce(attr, dflt) { |
| 33 | return Lib.coerce(dimensionIn, dimensionOut, attributes.dimensions, attr, dflt); |
| 34 | } |
| 35 | |
| 36 | var values = coerce('values'); |
| 37 | var visible = coerce('visible'); |
| 38 | if (!(values && values.length)) { |
| 39 | visible = dimensionOut.visible = false; |
| 40 | } |
| 41 | |
| 42 | if (visible) { |
| 43 | // Dimension level |
| 44 | coerce('label'); |
| 45 | coerce('displayindex', dimensionOut._index); |
| 46 | |
| 47 | // Category level |
| 48 | var arrayIn = dimensionIn.categoryarray; |
| 49 | var isValidArray = (Lib.isArrayOrTypedArray(arrayIn) && arrayIn.length > 0) || isTypedArraySpec(arrayIn); |
| 50 | |
| 51 | var orderDefault; |
| 52 | if (isValidArray) orderDefault = 'array'; |
| 53 | var order = coerce('categoryorder', orderDefault); |
| 54 | |
| 55 | // coerce 'categoryarray' only in array order case |
| 56 | if (order === 'array') { |
| 57 | coerce('categoryarray'); |
| 58 | coerce('ticktext'); |
| 59 | } else { |
| 60 | delete dimensionIn.categoryarray; |
| 61 | delete dimensionIn.ticktext; |
| 62 | } |
| 63 | |
| 64 | // cannot set 'categoryorder' to 'array' with an invalid 'categoryarray' |
| 65 | if (!isValidArray && order === 'array') { |
| 66 | dimensionOut.categoryorder = 'trace'; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) { |
| 72 | function coerce(attr, dflt) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…