|  | 
|  | 1 | +/** | 
|  | 2 | +* Copyright 2012-2019, 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 plotAttrs = require('../../plots/attributes'); | 
|  | 12 | +var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs; | 
|  | 13 | +var extendFlat = require('../../lib/extend').extendFlat; | 
|  | 14 | +var colormodel = require('./constants').colormodel; | 
|  | 15 | + | 
|  | 16 | +var cm = ['rgb', 'rgba', 'hsl', 'hsla']; | 
|  | 17 | +var zminDesc = []; | 
|  | 18 | +var zmaxDesc = []; | 
|  | 19 | +for(var i = 0; i < cm.length; i++) { | 
|  | 20 | +    zminDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].min.join(', ') + '].'); | 
|  | 21 | +    zmaxDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].max.join(', ') + '].'); | 
|  | 22 | +} | 
|  | 23 | + | 
|  | 24 | +module.exports = extendFlat({ | 
|  | 25 | +    z: { | 
|  | 26 | +        valType: 'data_array', | 
|  | 27 | +        role: 'info', | 
|  | 28 | +        editType: 'calc', | 
|  | 29 | +        description: [ | 
|  | 30 | +            'A 2-dimensional array in which each element is an array of 3 or 4 numbers representing a color.', | 
|  | 31 | +        ].join(' ') | 
|  | 32 | +    }, | 
|  | 33 | +    colormodel: { | 
|  | 34 | +        valType: 'enumerated', | 
|  | 35 | +        values: cm, | 
|  | 36 | +        dflt: 'rgb', | 
|  | 37 | +        role: 'info', | 
|  | 38 | +        editType: 'plot', | 
|  | 39 | +        description: 'Color model used to map the numerical color components described in `z` into colors.' | 
|  | 40 | +    }, | 
|  | 41 | +    zmin: { | 
|  | 42 | +        valType: 'info_array', | 
|  | 43 | +        items: [ | 
|  | 44 | +            {valType: 'number', editType: 'plot'}, | 
|  | 45 | +            {valType: 'number', editType: 'plot'}, | 
|  | 46 | +            {valType: 'number', editType: 'plot'}, | 
|  | 47 | +            {valType: 'number', editType: 'plot'} | 
|  | 48 | +        ], | 
|  | 49 | +        role: 'info', | 
|  | 50 | +        editType: 'plot', | 
|  | 51 | +        description: [ | 
|  | 52 | +            'Array defining the lower bound for each color component.', | 
|  | 53 | +            'Note that the default value will depend on the colormodel.', | 
|  | 54 | +            zminDesc.join(' ') | 
|  | 55 | +        ].join(' ') | 
|  | 56 | +    }, | 
|  | 57 | +    zmax: { | 
|  | 58 | +        valType: 'info_array', | 
|  | 59 | +        items: [ | 
|  | 60 | +            {valType: 'number', editType: 'plot'}, | 
|  | 61 | +            {valType: 'number', editType: 'plot'}, | 
|  | 62 | +            {valType: 'number', editType: 'plot'}, | 
|  | 63 | +            {valType: 'number', editType: 'plot'} | 
|  | 64 | +        ], | 
|  | 65 | +        role: 'info', | 
|  | 66 | +        editType: 'plot', | 
|  | 67 | +        description: [ | 
|  | 68 | +            'Array defining the higher bound for each color component.', | 
|  | 69 | +            'Note that the default value will depend on the colormodel.', | 
|  | 70 | +            zmaxDesc.join(' ') | 
|  | 71 | +        ].join(' ') | 
|  | 72 | +    }, | 
|  | 73 | +    x0: { | 
|  | 74 | +        valType: 'any', | 
|  | 75 | +        dflt: 0, | 
|  | 76 | +        role: 'info', | 
|  | 77 | +        editType: 'calc+clearAxisTypes', | 
|  | 78 | +        description: 'Set the image\'s x position.' | 
|  | 79 | +    }, | 
|  | 80 | +    y0: { | 
|  | 81 | +        valType: 'any', | 
|  | 82 | +        dflt: 0, | 
|  | 83 | +        role: 'info', | 
|  | 84 | +        editType: 'calc+clearAxisTypes', | 
|  | 85 | +        description: 'Set the image\'s y position.' | 
|  | 86 | +    }, | 
|  | 87 | +    dx: { | 
|  | 88 | +        valType: 'number', | 
|  | 89 | +        dflt: 1, | 
|  | 90 | +        role: 'info', | 
|  | 91 | +        editType: 'calc', | 
|  | 92 | +        description: 'Set the pixel\'s horizontal size.' | 
|  | 93 | +    }, | 
|  | 94 | +    dy: { | 
|  | 95 | +        valType: 'number', | 
|  | 96 | +        dflt: 1, | 
|  | 97 | +        role: 'info', | 
|  | 98 | +        editType: 'calc', | 
|  | 99 | +        description: 'Set the pixel\'s vertical size' | 
|  | 100 | +    }, | 
|  | 101 | +    text: { | 
|  | 102 | +        valType: 'data_array', | 
|  | 103 | +        editType: 'plot', | 
|  | 104 | +        description: 'Sets the text elements associated with each z value.' | 
|  | 105 | +    }, | 
|  | 106 | +    hovertext: { | 
|  | 107 | +        valType: 'data_array', | 
|  | 108 | +        editType: 'plot', | 
|  | 109 | +        description: 'Same as `text`.' | 
|  | 110 | +    }, | 
|  | 111 | +    hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { | 
|  | 112 | +        flags: ['x', 'y', 'z', 'color', 'name', 'text'], | 
|  | 113 | +        dflt: 'x+y+z+text+name' | 
|  | 114 | +    }), | 
|  | 115 | +    hovertemplate: hovertemplateAttrs({}, { | 
|  | 116 | +        keys: ['z', 'color', 'colormodel'] | 
|  | 117 | +    }) | 
|  | 118 | +}); | 
0 commit comments