|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs; |
| 4 | +var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs; |
| 5 | + |
| 6 | +var colorScaleAttrs = require('../../components/colorscale/attributes'); |
| 7 | +var domainAttrs = require('../../plots/domain').attributes; |
| 8 | +var pieAttrs = require('../pie/attributes'); |
| 9 | +var sunburstAttrs = require('../sunburst/attributes'); |
| 10 | +var constants = require('./constants'); |
| 11 | +var extendFlat = require('../../lib/extend').extendFlat; |
| 12 | + |
| 13 | +module.exports = { |
| 14 | + labels: sunburstAttrs.labels, |
| 15 | + parents: sunburstAttrs.parents, |
| 16 | + |
| 17 | + values: sunburstAttrs.values, |
| 18 | + branchvalues: sunburstAttrs.branchvalues, |
| 19 | + count: sunburstAttrs.count, |
| 20 | + |
| 21 | + level: sunburstAttrs.level, |
| 22 | + maxdepth: sunburstAttrs.maxdepth, |
| 23 | + |
| 24 | + tiling: { |
| 25 | + packing: { |
| 26 | + valType: 'enumerated', |
| 27 | + values: [ |
| 28 | + 'squarify', |
| 29 | + 'binary', |
| 30 | + 'dice', |
| 31 | + 'slice', |
| 32 | + 'slice-dice', |
| 33 | + 'dice-slice' |
| 34 | + ], |
| 35 | + dflt: 'squarify', |
| 36 | + editType: 'plot', |
| 37 | + description: [ |
| 38 | + 'Determines d3 icicle solver.', |
| 39 | + 'For more info please refer to https://github.com/d3/d3-hierarchy#icicle-tiling' |
| 40 | + ].join(' ') |
| 41 | + }, |
| 42 | + |
| 43 | + squarifyratio: { |
| 44 | + valType: 'number', |
| 45 | + min: 1, |
| 46 | + dflt: 1, |
| 47 | + editType: 'plot', |
| 48 | + description: [ |
| 49 | + 'When using *squarify* `packing` algorithm, according to https://github.com/d3/d3-hierarchy/blob/master/README.md#squarify_ratio', |
| 50 | + 'this option specifies the desired aspect ratio of the generated rectangles.', |
| 51 | + 'The ratio must be specified as a number greater than or equal to one.', |
| 52 | + 'Note that the orientation of the generated rectangles (tall or wide)', |
| 53 | + 'is not implied by the ratio; for example, a ratio of two will attempt', |
| 54 | + 'to produce a mixture of rectangles whose width:height ratio is either 2:1 or 1:2.', |
| 55 | + 'When using *squarify*, unlike d3 which uses the Golden Ratio i.e. 1.618034,', |
| 56 | + 'Plotly applies 1 to increase squares in icicle layouts.' |
| 57 | + ].join(' ') |
| 58 | + }, |
| 59 | + |
| 60 | + flip: { |
| 61 | + valType: 'flaglist', |
| 62 | + flags: [ |
| 63 | + 'x', |
| 64 | + 'y' |
| 65 | + ], |
| 66 | + dflt: '', |
| 67 | + editType: 'plot', |
| 68 | + description: [ |
| 69 | + 'Determines if the positions obtained from solver are flipped on each axis.' |
| 70 | + ].join(' ') |
| 71 | + }, |
| 72 | + |
| 73 | + pad: { |
| 74 | + valType: 'number', |
| 75 | + min: 0, |
| 76 | + dflt: 3, |
| 77 | + editType: 'plot', |
| 78 | + description: [ |
| 79 | + 'Sets the inner padding (in px).' |
| 80 | + ].join(' ') |
| 81 | + }, |
| 82 | + |
| 83 | + editType: 'calc', |
| 84 | + }, |
| 85 | + |
| 86 | + marker: extendFlat({ |
| 87 | + pad: { |
| 88 | + t: { |
| 89 | + valType: 'number', |
| 90 | + min: 0, |
| 91 | + editType: 'plot', |
| 92 | + description: [ |
| 93 | + 'Sets the padding form the top (in px).' |
| 94 | + ].join(' ') |
| 95 | + }, |
| 96 | + l: { |
| 97 | + valType: 'number', |
| 98 | + min: 0, |
| 99 | + editType: 'plot', |
| 100 | + description: [ |
| 101 | + 'Sets the padding form the left (in px).' |
| 102 | + ].join(' ') |
| 103 | + }, |
| 104 | + r: { |
| 105 | + valType: 'number', |
| 106 | + min: 0, |
| 107 | + editType: 'plot', |
| 108 | + description: [ |
| 109 | + 'Sets the padding form the right (in px).' |
| 110 | + ].join(' ') |
| 111 | + }, |
| 112 | + b: { |
| 113 | + valType: 'number', |
| 114 | + min: 0, |
| 115 | + editType: 'plot', |
| 116 | + description: [ |
| 117 | + 'Sets the padding form the bottom (in px).' |
| 118 | + ].join(' ') |
| 119 | + }, |
| 120 | + |
| 121 | + editType: 'calc' |
| 122 | + }, |
| 123 | + |
| 124 | + colors: sunburstAttrs.marker.colors, |
| 125 | + |
| 126 | + depthfade: { |
| 127 | + valType: 'enumerated', |
| 128 | + values: [true, false, 'reversed'], |
| 129 | + editType: 'style', |
| 130 | + description: [ |
| 131 | + 'Determines if the sector colors are faded towards', |
| 132 | + 'the background from the leaves up to the headers.', |
| 133 | + 'This option is unavailable when a `colorscale` is present,', |
| 134 | + 'defaults to false when `marker.colors` is set,', |
| 135 | + 'but otherwise defaults to true.', |
| 136 | + 'When set to *reversed*, the fading direction is inverted,', |
| 137 | + 'that is the top elements within hierarchy are drawn with fully saturated colors', |
| 138 | + 'while the leaves are faded towards the background color.' |
| 139 | + ].join(' ') |
| 140 | + }, |
| 141 | + |
| 142 | + line: sunburstAttrs.marker.line, |
| 143 | + |
| 144 | + editType: 'calc' |
| 145 | + }, |
| 146 | + colorScaleAttrs('marker', { |
| 147 | + colorAttr: 'colors', |
| 148 | + anim: false // TODO: set to anim: true? |
| 149 | + }) |
| 150 | + ), |
| 151 | + |
| 152 | + pathbar: { |
| 153 | + visible: { |
| 154 | + valType: 'boolean', |
| 155 | + dflt: true, |
| 156 | + editType: 'plot', |
| 157 | + description: [ |
| 158 | + 'Determines if the path bar is drawn', |
| 159 | + 'i.e. outside the trace `domain` and', |
| 160 | + 'with one pixel gap.' |
| 161 | + ].join(' ') |
| 162 | + }, |
| 163 | + |
| 164 | + side: { |
| 165 | + valType: 'enumerated', |
| 166 | + values: [ |
| 167 | + 'top', |
| 168 | + 'bottom' |
| 169 | + ], |
| 170 | + dflt: 'top', |
| 171 | + editType: 'plot', |
| 172 | + description: [ |
| 173 | + 'Determines on which side of the the icicle the', |
| 174 | + '`pathbar` should be presented.' |
| 175 | + ].join(' ') |
| 176 | + }, |
| 177 | + |
| 178 | + edgeshape: { |
| 179 | + valType: 'enumerated', |
| 180 | + values: [ |
| 181 | + '>', |
| 182 | + '<', |
| 183 | + '|', |
| 184 | + '/', |
| 185 | + '\\' |
| 186 | + ], |
| 187 | + dflt: '>', |
| 188 | + editType: 'plot', |
| 189 | + description: [ |
| 190 | + 'Determines which shape is used for edges between `barpath` labels.' |
| 191 | + ].join(' ') |
| 192 | + }, |
| 193 | + |
| 194 | + thickness: { |
| 195 | + valType: 'number', |
| 196 | + min: 12, |
| 197 | + editType: 'plot', |
| 198 | + description: [ |
| 199 | + 'Sets the thickness of `pathbar` (in px). If not specified the `pathbar.textfont.size` is used', |
| 200 | + 'with 3 pixles extra padding on each side.' |
| 201 | + ].join(' ') |
| 202 | + }, |
| 203 | + |
| 204 | + textfont: extendFlat({}, pieAttrs.textfont, { |
| 205 | + description: 'Sets the font used inside `pathbar`.' |
| 206 | + }), |
| 207 | + |
| 208 | + editType: 'calc' |
| 209 | + }, |
| 210 | + |
| 211 | + text: pieAttrs.text, |
| 212 | + textinfo: sunburstAttrs.textinfo, |
| 213 | + // TODO: incorporate `label` and `value` in the eventData |
| 214 | + texttemplate: texttemplateAttrs({editType: 'plot'}, { |
| 215 | + keys: constants.eventDataKeys.concat(['label', 'value']) |
| 216 | + }), |
| 217 | + |
| 218 | + hovertext: pieAttrs.hovertext, |
| 219 | + hoverinfo: sunburstAttrs.hoverinfo, |
| 220 | + hovertemplate: hovertemplateAttrs({}, { |
| 221 | + keys: constants.eventDataKeys |
| 222 | + }), |
| 223 | + |
| 224 | + textfont: pieAttrs.textfont, |
| 225 | + insidetextfont: pieAttrs.insidetextfont, |
| 226 | + outsidetextfont: extendFlat({}, pieAttrs.outsidetextfont, { |
| 227 | + description: [ |
| 228 | + 'Sets the font used for `textinfo` lying outside the sector.', |
| 229 | + 'This option refers to the root of the hierarchy', |
| 230 | + 'presented on top left corner of a icicle graph.', |
| 231 | + 'Please note that if a hierarchy has multiple root nodes,', |
| 232 | + 'this option won\'t have any effect and `insidetextfont` would be used.' |
| 233 | + ].join(' ') |
| 234 | + }), |
| 235 | + |
| 236 | + textposition: { |
| 237 | + valType: 'enumerated', |
| 238 | + values: [ |
| 239 | + 'top left', 'top center', 'top right', |
| 240 | + 'middle left', 'middle center', 'middle right', |
| 241 | + 'bottom left', 'bottom center', 'bottom right' |
| 242 | + ], |
| 243 | + dflt: 'top left', |
| 244 | + editType: 'plot', |
| 245 | + description: [ |
| 246 | + 'Sets the positions of the `text` elements.' |
| 247 | + ].join(' ') |
| 248 | + }, |
| 249 | + sort: pieAttrs.sort, |
| 250 | + root: sunburstAttrs.root, |
| 251 | + |
| 252 | + domain: domainAttrs({name: 'icicle', trace: true, editType: 'calc'}), |
| 253 | +}; |
0 commit comments