Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 24)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/plotly.js/src/traces/treemap/attributes.js +266 -0
- node_modules/plotly.js/src/traces/treemap/base_plot.js +13 -0
- node_modules/plotly.js/src/traces/treemap/calc.js +11 -0
- node_modules/plotly.js/src/traces/treemap/constants.js +19 -0
- node_modules/plotly.js/src/traces/treemap/defaults.js +113 -0
- node_modules/plotly.js/src/traces/treemap/draw.js +69 -0
- node_modules/plotly.js/src/traces/treemap/draw_ancestors.js +170 -0
- node_modules/plotly.js/src/traces/treemap/draw_descendants.js +211 -0
- node_modules/plotly.js/src/traces/treemap/flip_tree.js +36 -0
- node_modules/plotly.js/src/traces/treemap/index.js +30 -0
- node_modules/plotly.js/src/traces/treemap/layout_attributes.js +29 -0
- node_modules/plotly.js/src/traces/treemap/layout_defaults.js +12 -0
- node_modules/plotly.js/src/traces/treemap/partition.js +62 -0
- node_modules/plotly.js/src/traces/treemap/plot.js +11 -0
- node_modules/plotly.js/src/traces/treemap/plot_one.js +602 -0
- node_modules/plotly.js/src/traces/treemap/style.js +93 -0
- node_modules/plotly.js/src/traces/violin/attributes.js +258 -0
- node_modules/plotly.js/src/traces/violin/calc.js +166 -0
- node_modules/plotly.js/src/traces/violin/cross_trace_calc.js +33 -0
- node_modules/plotly.js/src/traces/violin/defaults.js +53 -0
- node_modules/plotly.js/src/traces/violin/helpers.js +63 -0
- node_modules/plotly.js/src/traces/violin/hover.js +114 -0
- node_modules/plotly.js/src/traces/violin/index.js +32 -0
- node_modules/plotly.js/src/traces/violin/layout_attributes.js +32 -0
- node_modules/plotly.js/src/traces/violin/layout_defaults.js +12 -0
- node_modules/plotly.js/src/traces/violin/plot.js +182 -0
- node_modules/plotly.js/src/traces/violin/style.js +45 -0
- node_modules/plotly.js/src/traces/volume/attributes.js +73 -0
- node_modules/plotly.js/src/traces/volume/convert.js +124 -0
- node_modules/plotly.js/src/traces/volume/defaults.js +16 -0
- node_modules/plotly.js/src/traces/volume/index.js +25 -0
- node_modules/plotly.js/src/traces/waterfall/attributes.js +155 -0
- node_modules/plotly.js/src/traces/waterfall/calc.js +108 -0
- node_modules/plotly.js/src/traces/waterfall/constants.js +9 -0
- node_modules/plotly.js/src/traces/waterfall/cross_trace_calc.js +63 -0
- node_modules/plotly.js/src/traces/waterfall/defaults.js +101 -0
- node_modules/plotly.js/src/traces/waterfall/event_data.js +17 -0
- node_modules/plotly.js/src/traces/waterfall/hover.js +84 -0
- node_modules/plotly.js/src/traces/waterfall/index.js +32 -0
- node_modules/plotly.js/src/traces/waterfall/layout_attributes.js +39 -0
- node_modules/plotly.js/src/traces/waterfall/layout_defaults.js +27 -0
- node_modules/plotly.js/src/traces/waterfall/plot.js +121 -0
- node_modules/plotly.js/src/traces/waterfall/style.js +51 -0
- node_modules/plotly.js/src/transforms/aggregate.js +450 -0
- node_modules/plotly.js/src/transforms/filter.js +323 -0
- node_modules/plotly.js/src/transforms/groupby.js +269 -0
- node_modules/plotly.js/src/transforms/helpers.js +16 -0
- node_modules/plotly.js/src/transforms/sort.js +154 -0
- node_modules/plotly.js/src/version.js +4 -0
- node_modules/plotly.js/stackgl_modules/index.js +0 -0
node_modules/plotly.js/src/traces/treemap/attributes.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
var pattern = require('../../components/drawing/attributes').pattern;
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
labels: sunburstAttrs.labels,
|
| 16 |
+
parents: sunburstAttrs.parents,
|
| 17 |
+
|
| 18 |
+
values: sunburstAttrs.values,
|
| 19 |
+
branchvalues: sunburstAttrs.branchvalues,
|
| 20 |
+
count: sunburstAttrs.count,
|
| 21 |
+
|
| 22 |
+
level: sunburstAttrs.level,
|
| 23 |
+
maxdepth: sunburstAttrs.maxdepth,
|
| 24 |
+
|
| 25 |
+
tiling: {
|
| 26 |
+
packing: {
|
| 27 |
+
valType: 'enumerated',
|
| 28 |
+
values: [
|
| 29 |
+
'squarify',
|
| 30 |
+
'binary',
|
| 31 |
+
'dice',
|
| 32 |
+
'slice',
|
| 33 |
+
'slice-dice',
|
| 34 |
+
'dice-slice'
|
| 35 |
+
],
|
| 36 |
+
dflt: 'squarify',
|
| 37 |
+
editType: 'plot',
|
| 38 |
+
description: [
|
| 39 |
+
'Determines d3 treemap solver.',
|
| 40 |
+
'For more info please refer to https://github.com/d3/d3-hierarchy#treemap-tiling'
|
| 41 |
+
].join(' ')
|
| 42 |
+
},
|
| 43 |
+
|
| 44 |
+
squarifyratio: {
|
| 45 |
+
valType: 'number',
|
| 46 |
+
min: 1,
|
| 47 |
+
dflt: 1,
|
| 48 |
+
editType: 'plot',
|
| 49 |
+
description: [
|
| 50 |
+
'When using *squarify* `packing` algorithm, according to https://github.com/d3/d3-hierarchy/blob/v3.1.1/README.md#squarify_ratio',
|
| 51 |
+
'this option specifies the desired aspect ratio of the generated rectangles.',
|
| 52 |
+
'The ratio must be specified as a number greater than or equal to one.',
|
| 53 |
+
'Note that the orientation of the generated rectangles (tall or wide)',
|
| 54 |
+
'is not implied by the ratio; for example, a ratio of two will attempt',
|
| 55 |
+
'to produce a mixture of rectangles whose width:height ratio is either 2:1 or 1:2.',
|
| 56 |
+
'When using *squarify*, unlike d3 which uses the Golden Ratio i.e. 1.618034,',
|
| 57 |
+
'Plotly applies 1 to increase squares in treemap layouts.'
|
| 58 |
+
].join(' ')
|
| 59 |
+
},
|
| 60 |
+
|
| 61 |
+
flip: {
|
| 62 |
+
valType: 'flaglist',
|
| 63 |
+
flags: [
|
| 64 |
+
'x',
|
| 65 |
+
'y'
|
| 66 |
+
],
|
| 67 |
+
dflt: '',
|
| 68 |
+
editType: 'plot',
|
| 69 |
+
description: [
|
| 70 |
+
'Determines if the positions obtained from solver are flipped on each axis.'
|
| 71 |
+
].join(' ')
|
| 72 |
+
},
|
| 73 |
+
|
| 74 |
+
pad: {
|
| 75 |
+
valType: 'number',
|
| 76 |
+
min: 0,
|
| 77 |
+
dflt: 3,
|
| 78 |
+
editType: 'plot',
|
| 79 |
+
description: [
|
| 80 |
+
'Sets the inner padding (in px).'
|
| 81 |
+
].join(' ')
|
| 82 |
+
},
|
| 83 |
+
|
| 84 |
+
editType: 'calc',
|
| 85 |
+
},
|
| 86 |
+
|
| 87 |
+
marker: extendFlat({
|
| 88 |
+
pad: {
|
| 89 |
+
t: {
|
| 90 |
+
valType: 'number',
|
| 91 |
+
min: 0,
|
| 92 |
+
editType: 'plot',
|
| 93 |
+
description: [
|
| 94 |
+
'Sets the padding form the top (in px).'
|
| 95 |
+
].join(' ')
|
| 96 |
+
},
|
| 97 |
+
l: {
|
| 98 |
+
valType: 'number',
|
| 99 |
+
min: 0,
|
| 100 |
+
editType: 'plot',
|
| 101 |
+
description: [
|
| 102 |
+
'Sets the padding form the left (in px).'
|
| 103 |
+
].join(' ')
|
| 104 |
+
},
|
| 105 |
+
r: {
|
| 106 |
+
valType: 'number',
|
| 107 |
+
min: 0,
|
| 108 |
+
editType: 'plot',
|
| 109 |
+
description: [
|
| 110 |
+
'Sets the padding form the right (in px).'
|
| 111 |
+
].join(' ')
|
| 112 |
+
},
|
| 113 |
+
b: {
|
| 114 |
+
valType: 'number',
|
| 115 |
+
min: 0,
|
| 116 |
+
editType: 'plot',
|
| 117 |
+
description: [
|
| 118 |
+
'Sets the padding form the bottom (in px).'
|
| 119 |
+
].join(' ')
|
| 120 |
+
},
|
| 121 |
+
|
| 122 |
+
editType: 'calc'
|
| 123 |
+
},
|
| 124 |
+
|
| 125 |
+
colors: sunburstAttrs.marker.colors,
|
| 126 |
+
|
| 127 |
+
pattern: pattern,
|
| 128 |
+
|
| 129 |
+
depthfade: {
|
| 130 |
+
valType: 'enumerated',
|
| 131 |
+
values: [true, false, 'reversed'],
|
| 132 |
+
editType: 'style',
|
| 133 |
+
description: [
|
| 134 |
+
'Determines if the sector colors are faded towards',
|
| 135 |
+
'the background from the leaves up to the headers.',
|
| 136 |
+
'This option is unavailable when a `colorscale` is present,',
|
| 137 |
+
'defaults to false when `marker.colors` is set,',
|
| 138 |
+
'but otherwise defaults to true.',
|
| 139 |
+
'When set to *reversed*, the fading direction is inverted,',
|
| 140 |
+
'that is the top elements within hierarchy are drawn with fully saturated colors',
|
| 141 |
+
'while the leaves are faded towards the background color.'
|
| 142 |
+
].join(' ')
|
| 143 |
+
},
|
| 144 |
+
|
| 145 |
+
line: sunburstAttrs.marker.line,
|
| 146 |
+
|
| 147 |
+
cornerradius: {
|
| 148 |
+
valType: 'number',
|
| 149 |
+
min: 0,
|
| 150 |
+
dflt: 0,
|
| 151 |
+
editType: 'plot',
|
| 152 |
+
description: [
|
| 153 |
+
'Sets the maximum rounding of corners (in px).'
|
| 154 |
+
].join(' ')
|
| 155 |
+
},
|
| 156 |
+
|
| 157 |
+
editType: 'calc',
|
| 158 |
+
},
|
| 159 |
+
colorScaleAttrs('marker', {
|
| 160 |
+
colorAttr: 'colors',
|
| 161 |
+
anim: false // TODO: set to anim: true?
|
| 162 |
+
})
|
| 163 |
+
),
|
| 164 |
+
|
| 165 |
+
pathbar: {
|
| 166 |
+
visible: {
|
| 167 |
+
valType: 'boolean',
|
| 168 |
+
dflt: true,
|
| 169 |
+
editType: 'plot',
|
| 170 |
+
description: [
|
| 171 |
+
'Determines if the path bar is drawn',
|
| 172 |
+
'i.e. outside the trace `domain` and',
|
| 173 |
+
'with one pixel gap.'
|
| 174 |
+
].join(' ')
|
| 175 |
+
},
|
| 176 |
+
|
| 177 |
+
side: {
|
| 178 |
+
valType: 'enumerated',
|
| 179 |
+
values: [
|
| 180 |
+
'top',
|
| 181 |
+
'bottom'
|
| 182 |
+
],
|
| 183 |
+
dflt: 'top',
|
| 184 |
+
editType: 'plot',
|
| 185 |
+
description: [
|
| 186 |
+
'Determines on which side of the the treemap the',
|
| 187 |
+
'`pathbar` should be presented.'
|
| 188 |
+
].join(' ')
|
| 189 |
+
},
|
| 190 |
+
|
| 191 |
+
edgeshape: {
|
| 192 |
+
valType: 'enumerated',
|
| 193 |
+
values: [
|
| 194 |
+
'>',
|
| 195 |
+
'<',
|
| 196 |
+
'|',
|
| 197 |
+
'/',
|
| 198 |
+
'\\'
|
| 199 |
+
],
|
| 200 |
+
dflt: '>',
|
| 201 |
+
editType: 'plot',
|
| 202 |
+
description: [
|
| 203 |
+
'Determines which shape is used for edges between `barpath` labels.'
|
| 204 |
+
].join(' ')
|
| 205 |
+
},
|
| 206 |
+
|
| 207 |
+
thickness: {
|
| 208 |
+
valType: 'number',
|
| 209 |
+
min: 12,
|
| 210 |
+
editType: 'plot',
|
| 211 |
+
description: [
|
| 212 |
+
'Sets the thickness of `pathbar` (in px). If not specified the `pathbar.textfont.size` is used',
|
| 213 |
+
'with 3 pixles extra padding on each side.'
|
| 214 |
+
].join(' ')
|
| 215 |
+
},
|
| 216 |
+
|
| 217 |
+
textfont: extendFlat({}, pieAttrs.textfont, {
|
| 218 |
+
description: 'Sets the font used inside `pathbar`.'
|
| 219 |
+
}),
|
| 220 |
+
|
| 221 |
+
editType: 'calc'
|
| 222 |
+
},
|
| 223 |
+
|
| 224 |
+
text: pieAttrs.text,
|
| 225 |
+
textinfo: sunburstAttrs.textinfo,
|
| 226 |
+
// TODO: incorporate `label` and `value` in the eventData
|
| 227 |
+
texttemplate: texttemplateAttrs({editType: 'plot'}, {
|
| 228 |
+
keys: constants.eventDataKeys.concat(['label', 'value'])
|
| 229 |
+
}),
|
| 230 |
+
|
| 231 |
+
hovertext: pieAttrs.hovertext,
|
| 232 |
+
hoverinfo: sunburstAttrs.hoverinfo,
|
| 233 |
+
hovertemplate: hovertemplateAttrs({}, {
|
| 234 |
+
keys: constants.eventDataKeys
|
| 235 |
+
}),
|
| 236 |
+
|
| 237 |
+
textfont: pieAttrs.textfont,
|
| 238 |
+
insidetextfont: pieAttrs.insidetextfont,
|
| 239 |
+
outsidetextfont: extendFlat({}, pieAttrs.outsidetextfont, {
|
| 240 |
+
description: [
|
| 241 |
+
'Sets the font used for `textinfo` lying outside the sector.',
|
| 242 |
+
'This option refers to the root of the hierarchy',
|
| 243 |
+
'presented on top left corner of a treemap graph.',
|
| 244 |
+
'Please note that if a hierarchy has multiple root nodes,',
|
| 245 |
+
'this option won\'t have any effect and `insidetextfont` would be used.'
|
| 246 |
+
].join(' ')
|
| 247 |
+
}),
|
| 248 |
+
|
| 249 |
+
textposition: {
|
| 250 |
+
valType: 'enumerated',
|
| 251 |
+
values: [
|
| 252 |
+
'top left', 'top center', 'top right',
|
| 253 |
+
'middle left', 'middle center', 'middle right',
|
| 254 |
+
'bottom left', 'bottom center', 'bottom right'
|
| 255 |
+
],
|
| 256 |
+
dflt: 'top left',
|
| 257 |
+
editType: 'plot',
|
| 258 |
+
description: [
|
| 259 |
+
'Sets the positions of the `text` elements.'
|
| 260 |
+
].join(' ')
|
| 261 |
+
},
|
| 262 |
+
sort: pieAttrs.sort,
|
| 263 |
+
root: sunburstAttrs.root,
|
| 264 |
+
|
| 265 |
+
domain: domainAttrs({name: 'treemap', trace: true, editType: 'calc'}),
|
| 266 |
+
};
|
node_modules/plotly.js/src/traces/treemap/base_plot.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var plots = require('../../plots/plots');
|
| 4 |
+
|
| 5 |
+
exports.name = 'treemap';
|
| 6 |
+
|
| 7 |
+
exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
|
| 8 |
+
plots.plotBasePlot(exports.name, gd, traces, transitionOpts, makeOnCompleteCallback);
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
|
| 12 |
+
plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout);
|
| 13 |
+
};
|
node_modules/plotly.js/src/traces/treemap/calc.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var calc = require('../sunburst/calc');
|
| 4 |
+
|
| 5 |
+
exports.calc = function(gd, trace) {
|
| 6 |
+
return calc.calc(gd, trace);
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
exports.crossTraceCalc = function(gd) {
|
| 10 |
+
return calc._runCrossTraceCalc('treemap', gd);
|
| 11 |
+
};
|
node_modules/plotly.js/src/traces/treemap/constants.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
CLICK_TRANSITION_TIME: 750,
|
| 5 |
+
CLICK_TRANSITION_EASING: 'poly',
|
| 6 |
+
eventDataKeys: [
|
| 7 |
+
// string
|
| 8 |
+
'currentPath',
|
| 9 |
+
'root',
|
| 10 |
+
'entry',
|
| 11 |
+
// no need to add 'parent' here
|
| 12 |
+
|
| 13 |
+
// percentages i.e. ratios
|
| 14 |
+
'percentRoot',
|
| 15 |
+
'percentEntry',
|
| 16 |
+
'percentParent'
|
| 17 |
+
],
|
| 18 |
+
gapWithPathbar: 1 // i.e. one pixel
|
| 19 |
+
};
|
node_modules/plotly.js/src/traces/treemap/defaults.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var attributes = require('./attributes');
|
| 5 |
+
var Color = require('../../components/color');
|
| 6 |
+
var handleDomainDefaults = require('../../plots/domain').defaults;
|
| 7 |
+
var handleText = require('../bar/defaults').handleText;
|
| 8 |
+
var TEXTPAD = require('../bar/constants').TEXTPAD;
|
| 9 |
+
var handleMarkerDefaults = require('../pie/defaults').handleMarkerDefaults;
|
| 10 |
+
|
| 11 |
+
var Colorscale = require('../../components/colorscale');
|
| 12 |
+
var hasColorscale = Colorscale.hasColorscale;
|
| 13 |
+
var colorscaleDefaults = Colorscale.handleDefaults;
|
| 14 |
+
|
| 15 |
+
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
|
| 16 |
+
function coerce(attr, dflt) {
|
| 17 |
+
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
var labels = coerce('labels');
|
| 21 |
+
var parents = coerce('parents');
|
| 22 |
+
|
| 23 |
+
if(!labels || !labels.length || !parents || !parents.length) {
|
| 24 |
+
traceOut.visible = false;
|
| 25 |
+
return;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
var vals = coerce('values');
|
| 29 |
+
if(vals && vals.length) {
|
| 30 |
+
coerce('branchvalues');
|
| 31 |
+
} else {
|
| 32 |
+
coerce('count');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
coerce('level');
|
| 36 |
+
coerce('maxdepth');
|
| 37 |
+
|
| 38 |
+
var packing = coerce('tiling.packing');
|
| 39 |
+
if(packing === 'squarify') {
|
| 40 |
+
coerce('tiling.squarifyratio');
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
coerce('tiling.flip');
|
| 44 |
+
coerce('tiling.pad');
|
| 45 |
+
|
| 46 |
+
var text = coerce('text');
|
| 47 |
+
coerce('texttemplate');
|
| 48 |
+
if(!traceOut.texttemplate) coerce('textinfo', Lib.isArrayOrTypedArray(text) ? 'text+label' : 'label');
|
| 49 |
+
|
| 50 |
+
coerce('hovertext');
|
| 51 |
+
coerce('hovertemplate');
|
| 52 |
+
|
| 53 |
+
var hasPathbar = coerce('pathbar.visible');
|
| 54 |
+
|
| 55 |
+
var textposition = 'auto';
|
| 56 |
+
handleText(traceIn, traceOut, layout, coerce, textposition, {
|
| 57 |
+
hasPathbar: hasPathbar,
|
| 58 |
+
moduleHasSelected: false,
|
| 59 |
+
moduleHasUnselected: false,
|
| 60 |
+
moduleHasConstrain: false,
|
| 61 |
+
moduleHasCliponaxis: false,
|
| 62 |
+
moduleHasTextangle: false,
|
| 63 |
+
moduleHasInsideanchor: false
|
| 64 |
+
});
|
| 65 |
+
coerce('textposition');
|
| 66 |
+
var bottomText = traceOut.textposition.indexOf('bottom') !== -1;
|
| 67 |
+
|
| 68 |
+
handleMarkerDefaults(traceIn, traceOut, layout, coerce);
|
| 69 |
+
var withColorscale = traceOut._hasColorscale = (
|
| 70 |
+
hasColorscale(traceIn, 'marker', 'colors') ||
|
| 71 |
+
(traceIn.marker || {}).coloraxis // N.B. special logic to consider "values" colorscales
|
| 72 |
+
);
|
| 73 |
+
if(withColorscale) {
|
| 74 |
+
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
|
| 75 |
+
} else {
|
| 76 |
+
coerce('marker.depthfade', !(traceOut.marker.colors || []).length);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
var headerSize = traceOut.textfont.size * 2;
|
| 80 |
+
|
| 81 |
+
coerce('marker.pad.t', bottomText ? headerSize / 4 : headerSize);
|
| 82 |
+
coerce('marker.pad.l', headerSize / 4);
|
| 83 |
+
coerce('marker.pad.r', headerSize / 4);
|
| 84 |
+
coerce('marker.pad.b', bottomText ? headerSize : headerSize / 4);
|
| 85 |
+
|
| 86 |
+
coerce('marker.cornerradius');
|
| 87 |
+
|
| 88 |
+
traceOut._hovered = {
|
| 89 |
+
marker: {
|
| 90 |
+
line: {
|
| 91 |
+
width: 2,
|
| 92 |
+
color: Color.contrast(layout.paper_bgcolor)
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
if(hasPathbar) {
|
| 98 |
+
// This works even for multi-line labels as treemap pathbar trim out line breaks
|
| 99 |
+
coerce('pathbar.thickness', traceOut.pathbar.textfont.size + 2 * TEXTPAD);
|
| 100 |
+
|
| 101 |
+
coerce('pathbar.side');
|
| 102 |
+
coerce('pathbar.edgeshape');
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
coerce('sort');
|
| 106 |
+
|
| 107 |
+
coerce('root.color');
|
| 108 |
+
|
| 109 |
+
handleDomainDefaults(traceOut, layout, coerce);
|
| 110 |
+
|
| 111 |
+
// do not support transforms for now
|
| 112 |
+
traceOut._length = null;
|
| 113 |
+
};
|
node_modules/plotly.js/src/traces/treemap/draw.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
|
| 5 |
+
var helpers = require('../sunburst/helpers');
|
| 6 |
+
var uniformText = require('../bar/uniform_text');
|
| 7 |
+
var clearMinTextSize = uniformText.clearMinTextSize;
|
| 8 |
+
var resizeText = require('../bar/style').resizeText;
|
| 9 |
+
|
| 10 |
+
var plotOne = require('./plot_one');
|
| 11 |
+
|
| 12 |
+
module.exports = function _plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback, opts) {
|
| 13 |
+
var type = opts.type;
|
| 14 |
+
var drawDescendants = opts.drawDescendants;
|
| 15 |
+
|
| 16 |
+
var fullLayout = gd._fullLayout;
|
| 17 |
+
var layer = fullLayout['_' + type + 'layer'];
|
| 18 |
+
var join, onComplete;
|
| 19 |
+
|
| 20 |
+
// If transition config is provided, then it is only a partial replot and traces not
|
| 21 |
+
// updated are removed.
|
| 22 |
+
var isFullReplot = !transitionOpts;
|
| 23 |
+
|
| 24 |
+
clearMinTextSize(type, fullLayout);
|
| 25 |
+
|
| 26 |
+
join = layer.selectAll('g.trace.' + type)
|
| 27 |
+
.data(cdmodule, function(cd) { return cd[0].trace.uid; });
|
| 28 |
+
|
| 29 |
+
join.enter().append('g')
|
| 30 |
+
.classed('trace', true)
|
| 31 |
+
.classed(type, true);
|
| 32 |
+
|
| 33 |
+
join.order();
|
| 34 |
+
|
| 35 |
+
if(!fullLayout.uniformtext.mode && helpers.hasTransition(transitionOpts)) {
|
| 36 |
+
if(makeOnCompleteCallback) {
|
| 37 |
+
// If it was passed a callback to register completion, make a callback. If
|
| 38 |
+
// this is created, then it must be executed on completion, otherwise the
|
| 39 |
+
// pos-transition redraw will not execute:
|
| 40 |
+
onComplete = makeOnCompleteCallback();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
var transition = d3.transition()
|
| 44 |
+
.duration(transitionOpts.duration)
|
| 45 |
+
.ease(transitionOpts.easing)
|
| 46 |
+
.each('end', function() { onComplete && onComplete(); })
|
| 47 |
+
.each('interrupt', function() { onComplete && onComplete(); });
|
| 48 |
+
|
| 49 |
+
transition.each(function() {
|
| 50 |
+
// Must run the selection again since otherwise enters/updates get grouped together
|
| 51 |
+
// and these get executed out of order. Except we need them in order!
|
| 52 |
+
layer.selectAll('g.trace').each(function(cd) {
|
| 53 |
+
plotOne(gd, cd, this, transitionOpts, drawDescendants);
|
| 54 |
+
});
|
| 55 |
+
});
|
| 56 |
+
} else {
|
| 57 |
+
join.each(function(cd) {
|
| 58 |
+
plotOne(gd, cd, this, transitionOpts, drawDescendants);
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
if(fullLayout.uniformtext.mode) {
|
| 62 |
+
resizeText(gd, layer.selectAll('.trace'), type);
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
if(isFullReplot) {
|
| 67 |
+
join.exit().remove();
|
| 68 |
+
}
|
| 69 |
+
};
|
node_modules/plotly.js/src/traces/treemap/draw_ancestors.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Lib = require('../../lib');
|
| 5 |
+
var Drawing = require('../../components/drawing');
|
| 6 |
+
var svgTextUtils = require('../../lib/svg_text_utils');
|
| 7 |
+
|
| 8 |
+
var partition = require('./partition');
|
| 9 |
+
var styleOne = require('./style').styleOne;
|
| 10 |
+
var constants = require('./constants');
|
| 11 |
+
var helpers = require('../sunburst/helpers');
|
| 12 |
+
var attachFxHandlers = require('../sunburst/fx');
|
| 13 |
+
|
| 14 |
+
var onPathbar = true; // for Ancestors
|
| 15 |
+
|
| 16 |
+
module.exports = function drawAncestors(gd, cd, entry, slices, opts) {
|
| 17 |
+
var barDifY = opts.barDifY;
|
| 18 |
+
var width = opts.width;
|
| 19 |
+
var height = opts.height;
|
| 20 |
+
var viewX = opts.viewX;
|
| 21 |
+
var viewY = opts.viewY;
|
| 22 |
+
var pathSlice = opts.pathSlice;
|
| 23 |
+
var toMoveInsideSlice = opts.toMoveInsideSlice;
|
| 24 |
+
var strTransform = opts.strTransform;
|
| 25 |
+
var hasTransition = opts.hasTransition;
|
| 26 |
+
var handleSlicesExit = opts.handleSlicesExit;
|
| 27 |
+
var makeUpdateSliceInterpolator = opts.makeUpdateSliceInterpolator;
|
| 28 |
+
var makeUpdateTextInterpolator = opts.makeUpdateTextInterpolator;
|
| 29 |
+
var refRect = {};
|
| 30 |
+
|
| 31 |
+
var isStatic = gd._context.staticPlot;
|
| 32 |
+
|
| 33 |
+
var fullLayout = gd._fullLayout;
|
| 34 |
+
var cd0 = cd[0];
|
| 35 |
+
var trace = cd0.trace;
|
| 36 |
+
var hierarchy = cd0.hierarchy;
|
| 37 |
+
|
| 38 |
+
var eachWidth = width / trace._entryDepth;
|
| 39 |
+
|
| 40 |
+
var pathIds = helpers.listPath(entry.data, 'id');
|
| 41 |
+
|
| 42 |
+
var sliceData = partition(hierarchy.copy(), [width, height], {
|
| 43 |
+
packing: 'dice',
|
| 44 |
+
pad: {
|
| 45 |
+
inner: 0,
|
| 46 |
+
top: 0,
|
| 47 |
+
left: 0,
|
| 48 |
+
right: 0,
|
| 49 |
+
bottom: 0
|
| 50 |
+
}
|
| 51 |
+
}).descendants();
|
| 52 |
+
|
| 53 |
+
// edit slices that show up on graph
|
| 54 |
+
sliceData = sliceData.filter(function(pt) {
|
| 55 |
+
var level = pathIds.indexOf(pt.data.id);
|
| 56 |
+
if(level === -1) return false;
|
| 57 |
+
|
| 58 |
+
pt.x0 = eachWidth * level;
|
| 59 |
+
pt.x1 = eachWidth * (level + 1);
|
| 60 |
+
pt.y0 = barDifY;
|
| 61 |
+
pt.y1 = barDifY + height;
|
| 62 |
+
|
| 63 |
+
pt.onPathbar = true;
|
| 64 |
+
|
| 65 |
+
return true;
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
sliceData.reverse();
|
| 69 |
+
|
| 70 |
+
slices = slices.data(sliceData, helpers.getPtId);
|
| 71 |
+
|
| 72 |
+
slices.enter().append('g')
|
| 73 |
+
.classed('pathbar', true);
|
| 74 |
+
|
| 75 |
+
handleSlicesExit(slices, onPathbar, refRect, [width, height], pathSlice);
|
| 76 |
+
|
| 77 |
+
slices.order();
|
| 78 |
+
|
| 79 |
+
var updateSlices = slices;
|
| 80 |
+
if(hasTransition) {
|
| 81 |
+
updateSlices = updateSlices.transition().each('end', function() {
|
| 82 |
+
// N.B. gd._transitioning is (still) *true* by the time
|
| 83 |
+
// transition updates get here
|
| 84 |
+
var sliceTop = d3.select(this);
|
| 85 |
+
helpers.setSliceCursor(sliceTop, gd, {
|
| 86 |
+
hideOnRoot: false,
|
| 87 |
+
hideOnLeaves: false,
|
| 88 |
+
isTransitioning: false
|
| 89 |
+
});
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
updateSlices.each(function(pt) {
|
| 94 |
+
// for bbox
|
| 95 |
+
pt._x0 = viewX(pt.x0);
|
| 96 |
+
pt._x1 = viewX(pt.x1);
|
| 97 |
+
pt._y0 = viewY(pt.y0);
|
| 98 |
+
pt._y1 = viewY(pt.y1);
|
| 99 |
+
|
| 100 |
+
pt._hoverX = viewX(pt.x1 - Math.min(width, height) / 2);
|
| 101 |
+
pt._hoverY = viewY(pt.y1 - height / 2);
|
| 102 |
+
|
| 103 |
+
var sliceTop = d3.select(this);
|
| 104 |
+
|
| 105 |
+
var slicePath = Lib.ensureSingle(sliceTop, 'path', 'surface', function(s) {
|
| 106 |
+
s.style('pointer-events', isStatic ? 'none' : 'all');
|
| 107 |
+
});
|
| 108 |
+
|
| 109 |
+
if(hasTransition) {
|
| 110 |
+
slicePath.transition().attrTween('d', function(pt2) {
|
| 111 |
+
var interp = makeUpdateSliceInterpolator(pt2, onPathbar, refRect, [width, height]);
|
| 112 |
+
return function(t) { return pathSlice(interp(t)); };
|
| 113 |
+
});
|
| 114 |
+
} else {
|
| 115 |
+
slicePath.attr('d', pathSlice);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
sliceTop
|
| 119 |
+
.call(attachFxHandlers, entry, gd, cd, {
|
| 120 |
+
styleOne: styleOne,
|
| 121 |
+
eventDataKeys: constants.eventDataKeys,
|
| 122 |
+
transitionTime: constants.CLICK_TRANSITION_TIME,
|
| 123 |
+
transitionEasing: constants.CLICK_TRANSITION_EASING
|
| 124 |
+
})
|
| 125 |
+
.call(helpers.setSliceCursor, gd, {
|
| 126 |
+
hideOnRoot: false,
|
| 127 |
+
hideOnLeaves: false,
|
| 128 |
+
isTransitioning: gd._transitioning
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
slicePath.call(styleOne, pt, trace, gd, {
|
| 132 |
+
hovered: false
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
pt._text = (helpers.getPtLabel(pt) || '').split('<br>').join(' ') || '';
|
| 136 |
+
|
| 137 |
+
var sliceTextGroup = Lib.ensureSingle(sliceTop, 'g', 'slicetext');
|
| 138 |
+
var sliceText = Lib.ensureSingle(sliceTextGroup, 'text', '', function(s) {
|
| 139 |
+
// prohibit tex interpretation until we can handle
|
| 140 |
+
// tex and regular text together
|
| 141 |
+
s.attr('data-notex', 1);
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
var font = Lib.ensureUniformFontSize(gd, helpers.determineTextFont(trace, pt, fullLayout.font, {
|
| 145 |
+
onPathbar: true
|
| 146 |
+
}));
|
| 147 |
+
|
| 148 |
+
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
|
| 149 |
+
.classed('slicetext', true)
|
| 150 |
+
.attr('text-anchor', 'start')
|
| 151 |
+
.call(Drawing.font, font)
|
| 152 |
+
.call(svgTextUtils.convertToTspans, gd);
|
| 153 |
+
|
| 154 |
+
pt.textBB = Drawing.bBox(sliceText.node());
|
| 155 |
+
pt.transform = toMoveInsideSlice(pt, {
|
| 156 |
+
fontSize: font.size,
|
| 157 |
+
onPathbar: true
|
| 158 |
+
});
|
| 159 |
+
pt.transform.fontSize = font.size;
|
| 160 |
+
|
| 161 |
+
if(hasTransition) {
|
| 162 |
+
sliceText.transition().attrTween('transform', function(pt2) {
|
| 163 |
+
var interp = makeUpdateTextInterpolator(pt2, onPathbar, refRect, [width, height]);
|
| 164 |
+
return function(t) { return strTransform(interp(t)); };
|
| 165 |
+
});
|
| 166 |
+
} else {
|
| 167 |
+
sliceText.attr('transform', strTransform(pt));
|
| 168 |
+
}
|
| 169 |
+
});
|
| 170 |
+
};
|
node_modules/plotly.js/src/traces/treemap/draw_descendants.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Lib = require('../../lib');
|
| 5 |
+
var Drawing = require('../../components/drawing');
|
| 6 |
+
var svgTextUtils = require('../../lib/svg_text_utils');
|
| 7 |
+
|
| 8 |
+
var partition = require('./partition');
|
| 9 |
+
var styleOne = require('./style').styleOne;
|
| 10 |
+
var constants = require('./constants');
|
| 11 |
+
var helpers = require('../sunburst/helpers');
|
| 12 |
+
var attachFxHandlers = require('../sunburst/fx');
|
| 13 |
+
var formatSliceLabel = require('../sunburst/plot').formatSliceLabel;
|
| 14 |
+
|
| 15 |
+
var onPathbar = false; // for Descendants
|
| 16 |
+
|
| 17 |
+
module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
|
| 18 |
+
var width = opts.width;
|
| 19 |
+
var height = opts.height;
|
| 20 |
+
var viewX = opts.viewX;
|
| 21 |
+
var viewY = opts.viewY;
|
| 22 |
+
var pathSlice = opts.pathSlice;
|
| 23 |
+
var toMoveInsideSlice = opts.toMoveInsideSlice;
|
| 24 |
+
var strTransform = opts.strTransform;
|
| 25 |
+
var hasTransition = opts.hasTransition;
|
| 26 |
+
var handleSlicesExit = opts.handleSlicesExit;
|
| 27 |
+
var makeUpdateSliceInterpolator = opts.makeUpdateSliceInterpolator;
|
| 28 |
+
var makeUpdateTextInterpolator = opts.makeUpdateTextInterpolator;
|
| 29 |
+
var prevEntry = opts.prevEntry;
|
| 30 |
+
var refRect = {};
|
| 31 |
+
|
| 32 |
+
var isStatic = gd._context.staticPlot;
|
| 33 |
+
|
| 34 |
+
var fullLayout = gd._fullLayout;
|
| 35 |
+
var cd0 = cd[0];
|
| 36 |
+
var trace = cd0.trace;
|
| 37 |
+
|
| 38 |
+
var hasLeft = trace.textposition.indexOf('left') !== -1;
|
| 39 |
+
var hasRight = trace.textposition.indexOf('right') !== -1;
|
| 40 |
+
var hasBottom = trace.textposition.indexOf('bottom') !== -1;
|
| 41 |
+
|
| 42 |
+
var noRoomForHeader = (!hasBottom && !trace.marker.pad.t) || (hasBottom && !trace.marker.pad.b);
|
| 43 |
+
|
| 44 |
+
// N.B. slice data isn't the calcdata,
|
| 45 |
+
// grab corresponding calcdata item in sliceData[i].data.data
|
| 46 |
+
var allData = partition(entry, [width, height], {
|
| 47 |
+
packing: trace.tiling.packing,
|
| 48 |
+
squarifyratio: trace.tiling.squarifyratio,
|
| 49 |
+
flipX: trace.tiling.flip.indexOf('x') > -1,
|
| 50 |
+
flipY: trace.tiling.flip.indexOf('y') > -1,
|
| 51 |
+
pad: {
|
| 52 |
+
inner: trace.tiling.pad,
|
| 53 |
+
top: trace.marker.pad.t,
|
| 54 |
+
left: trace.marker.pad.l,
|
| 55 |
+
right: trace.marker.pad.r,
|
| 56 |
+
bottom: trace.marker.pad.b,
|
| 57 |
+
}
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
var sliceData = allData.descendants();
|
| 61 |
+
|
| 62 |
+
var minVisibleDepth = Infinity;
|
| 63 |
+
var maxVisibleDepth = -Infinity;
|
| 64 |
+
sliceData.forEach(function(pt) {
|
| 65 |
+
var depth = pt.depth;
|
| 66 |
+
if(depth >= trace._maxDepth) {
|
| 67 |
+
// hide slices that won't show up on graph
|
| 68 |
+
pt.x0 = pt.x1 = (pt.x0 + pt.x1) / 2;
|
| 69 |
+
pt.y0 = pt.y1 = (pt.y0 + pt.y1) / 2;
|
| 70 |
+
} else {
|
| 71 |
+
minVisibleDepth = Math.min(minVisibleDepth, depth);
|
| 72 |
+
maxVisibleDepth = Math.max(maxVisibleDepth, depth);
|
| 73 |
+
}
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
slices = slices.data(sliceData, helpers.getPtId);
|
| 77 |
+
|
| 78 |
+
trace._maxVisibleLayers = isFinite(maxVisibleDepth) ? maxVisibleDepth - minVisibleDepth + 1 : 0;
|
| 79 |
+
|
| 80 |
+
slices.enter().append('g')
|
| 81 |
+
.classed('slice', true);
|
| 82 |
+
|
| 83 |
+
handleSlicesExit(slices, onPathbar, refRect, [width, height], pathSlice);
|
| 84 |
+
|
| 85 |
+
slices.order();
|
| 86 |
+
|
| 87 |
+
// next coords of previous entry
|
| 88 |
+
var nextOfPrevEntry = null;
|
| 89 |
+
if(hasTransition && prevEntry) {
|
| 90 |
+
var prevEntryId = helpers.getPtId(prevEntry);
|
| 91 |
+
slices.each(function(pt) {
|
| 92 |
+
if(nextOfPrevEntry === null && (helpers.getPtId(pt) === prevEntryId)) {
|
| 93 |
+
nextOfPrevEntry = {
|
| 94 |
+
x0: pt.x0,
|
| 95 |
+
x1: pt.x1,
|
| 96 |
+
y0: pt.y0,
|
| 97 |
+
y1: pt.y1
|
| 98 |
+
};
|
| 99 |
+
}
|
| 100 |
+
});
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
var getRefRect = function() {
|
| 104 |
+
return nextOfPrevEntry || {
|
| 105 |
+
x0: 0,
|
| 106 |
+
x1: width,
|
| 107 |
+
y0: 0,
|
| 108 |
+
y1: height
|
| 109 |
+
};
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
var updateSlices = slices;
|
| 113 |
+
if(hasTransition) {
|
| 114 |
+
updateSlices = updateSlices.transition().each('end', function() {
|
| 115 |
+
// N.B. gd._transitioning is (still) *true* by the time
|
| 116 |
+
// transition updates get here
|
| 117 |
+
var sliceTop = d3.select(this);
|
| 118 |
+
helpers.setSliceCursor(sliceTop, gd, {
|
| 119 |
+
hideOnRoot: true,
|
| 120 |
+
hideOnLeaves: false,
|
| 121 |
+
isTransitioning: false
|
| 122 |
+
});
|
| 123 |
+
});
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
updateSlices.each(function(pt) {
|
| 127 |
+
var isHeader = helpers.isHeader(pt, trace);
|
| 128 |
+
|
| 129 |
+
// for bbox
|
| 130 |
+
pt._x0 = viewX(pt.x0);
|
| 131 |
+
pt._x1 = viewX(pt.x1);
|
| 132 |
+
pt._y0 = viewY(pt.y0);
|
| 133 |
+
pt._y1 = viewY(pt.y1);
|
| 134 |
+
|
| 135 |
+
pt._hoverX = viewX(pt.x1 - trace.marker.pad.r),
|
| 136 |
+
pt._hoverY = hasBottom ?
|
| 137 |
+
viewY(pt.y1 - trace.marker.pad.b / 2) :
|
| 138 |
+
viewY(pt.y0 + trace.marker.pad.t / 2);
|
| 139 |
+
|
| 140 |
+
var sliceTop = d3.select(this);
|
| 141 |
+
|
| 142 |
+
var slicePath = Lib.ensureSingle(sliceTop, 'path', 'surface', function(s) {
|
| 143 |
+
s.style('pointer-events', isStatic ? 'none' : 'all');
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
if(hasTransition) {
|
| 147 |
+
slicePath.transition().attrTween('d', function(pt2) {
|
| 148 |
+
var interp = makeUpdateSliceInterpolator(pt2, onPathbar, getRefRect(), [width, height]);
|
| 149 |
+
return function(t) { return pathSlice(interp(t)); };
|
| 150 |
+
});
|
| 151 |
+
} else {
|
| 152 |
+
slicePath.attr('d', pathSlice);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
sliceTop
|
| 156 |
+
.call(attachFxHandlers, entry, gd, cd, {
|
| 157 |
+
styleOne: styleOne,
|
| 158 |
+
eventDataKeys: constants.eventDataKeys,
|
| 159 |
+
transitionTime: constants.CLICK_TRANSITION_TIME,
|
| 160 |
+
transitionEasing: constants.CLICK_TRANSITION_EASING
|
| 161 |
+
})
|
| 162 |
+
.call(helpers.setSliceCursor, gd, { isTransitioning: gd._transitioning });
|
| 163 |
+
|
| 164 |
+
slicePath.call(styleOne, pt, trace, gd, {
|
| 165 |
+
hovered: false
|
| 166 |
+
});
|
| 167 |
+
|
| 168 |
+
if(pt.x0 === pt.x1 || pt.y0 === pt.y1) {
|
| 169 |
+
pt._text = '';
|
| 170 |
+
} else {
|
| 171 |
+
if(isHeader) {
|
| 172 |
+
pt._text = noRoomForHeader ? '' : helpers.getPtLabel(pt) || '';
|
| 173 |
+
} else {
|
| 174 |
+
pt._text = formatSliceLabel(pt, entry, trace, cd, fullLayout) || '';
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
var sliceTextGroup = Lib.ensureSingle(sliceTop, 'g', 'slicetext');
|
| 179 |
+
var sliceText = Lib.ensureSingle(sliceTextGroup, 'text', '', function(s) {
|
| 180 |
+
// prohibit tex interpretation until we can handle
|
| 181 |
+
// tex and regular text together
|
| 182 |
+
s.attr('data-notex', 1);
|
| 183 |
+
});
|
| 184 |
+
|
| 185 |
+
var font = Lib.ensureUniformFontSize(gd, helpers.determineTextFont(trace, pt, fullLayout.font));
|
| 186 |
+
|
| 187 |
+
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
|
| 188 |
+
.classed('slicetext', true)
|
| 189 |
+
.attr('text-anchor', hasRight ? 'end' : (hasLeft || isHeader) ? 'start' : 'middle')
|
| 190 |
+
.call(Drawing.font, font)
|
| 191 |
+
.call(svgTextUtils.convertToTspans, gd);
|
| 192 |
+
|
| 193 |
+
pt.textBB = Drawing.bBox(sliceText.node());
|
| 194 |
+
pt.transform = toMoveInsideSlice(pt, {
|
| 195 |
+
fontSize: font.size,
|
| 196 |
+
isHeader: isHeader
|
| 197 |
+
});
|
| 198 |
+
pt.transform.fontSize = font.size;
|
| 199 |
+
|
| 200 |
+
if(hasTransition) {
|
| 201 |
+
sliceText.transition().attrTween('transform', function(pt2) {
|
| 202 |
+
var interp = makeUpdateTextInterpolator(pt2, onPathbar, getRefRect(), [width, height]);
|
| 203 |
+
return function(t) { return strTransform(interp(t)); };
|
| 204 |
+
});
|
| 205 |
+
} else {
|
| 206 |
+
sliceText.attr('transform', strTransform(pt));
|
| 207 |
+
}
|
| 208 |
+
});
|
| 209 |
+
|
| 210 |
+
return nextOfPrevEntry;
|
| 211 |
+
};
|
node_modules/plotly.js/src/traces/treemap/flip_tree.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = function flipTree(node, size, opts) {
|
| 4 |
+
var tmp;
|
| 5 |
+
|
| 6 |
+
if(opts.swapXY) {
|
| 7 |
+
// swap x0 and y0
|
| 8 |
+
tmp = node.x0;
|
| 9 |
+
node.x0 = node.y0;
|
| 10 |
+
node.y0 = tmp;
|
| 11 |
+
|
| 12 |
+
// swap x1 and y1
|
| 13 |
+
tmp = node.x1;
|
| 14 |
+
node.x1 = node.y1;
|
| 15 |
+
node.y1 = tmp;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
if(opts.flipX) {
|
| 19 |
+
tmp = node.x0;
|
| 20 |
+
node.x0 = size[0] - node.x1;
|
| 21 |
+
node.x1 = size[0] - tmp;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
if(opts.flipY) {
|
| 25 |
+
tmp = node.y0;
|
| 26 |
+
node.y0 = size[1] - node.y1;
|
| 27 |
+
node.y1 = size[1] - tmp;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
var children = node.children;
|
| 31 |
+
if(children) {
|
| 32 |
+
for(var i = 0; i < children.length; i++) {
|
| 33 |
+
flipTree(children[i], size, opts);
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
};
|
node_modules/plotly.js/src/traces/treemap/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
moduleType: 'trace',
|
| 5 |
+
name: 'treemap',
|
| 6 |
+
basePlotModule: require('./base_plot'),
|
| 7 |
+
categories: [],
|
| 8 |
+
animatable: true,
|
| 9 |
+
|
| 10 |
+
attributes: require('./attributes'),
|
| 11 |
+
layoutAttributes: require('./layout_attributes'),
|
| 12 |
+
supplyDefaults: require('./defaults'),
|
| 13 |
+
supplyLayoutDefaults: require('./layout_defaults'),
|
| 14 |
+
|
| 15 |
+
calc: require('./calc').calc,
|
| 16 |
+
crossTraceCalc: require('./calc').crossTraceCalc,
|
| 17 |
+
|
| 18 |
+
plot: require('./plot'),
|
| 19 |
+
style: require('./style').style,
|
| 20 |
+
|
| 21 |
+
colorbar: require('../scatter/marker_colorbar'),
|
| 22 |
+
|
| 23 |
+
meta: {
|
| 24 |
+
description: [
|
| 25 |
+
'Visualize hierarchal data from leaves (and/or outer branches) towards root',
|
| 26 |
+
'with rectangles. The treemap sectors are determined by the entries in',
|
| 27 |
+
'*labels* or *ids* and in *parents*.'
|
| 28 |
+
].join(' ')
|
| 29 |
+
}
|
| 30 |
+
};
|
node_modules/plotly.js/src/traces/treemap/layout_attributes.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
treemapcolorway: {
|
| 5 |
+
valType: 'colorlist',
|
| 6 |
+
editType: 'calc',
|
| 7 |
+
description: [
|
| 8 |
+
'Sets the default treemap slice colors. Defaults to the main',
|
| 9 |
+
'`colorway` used for trace colors. If you specify a new',
|
| 10 |
+
'list here it can still be extended with lighter and darker',
|
| 11 |
+
'colors, see `extendtreemapcolors`.'
|
| 12 |
+
].join(' ')
|
| 13 |
+
},
|
| 14 |
+
extendtreemapcolors: {
|
| 15 |
+
valType: 'boolean',
|
| 16 |
+
dflt: true,
|
| 17 |
+
editType: 'calc',
|
| 18 |
+
description: [
|
| 19 |
+
'If `true`, the treemap slice colors (whether given by `treemapcolorway` or',
|
| 20 |
+
'inherited from `colorway`) will be extended to three times its',
|
| 21 |
+
'original length by first repeating every color 20% lighter then',
|
| 22 |
+
'each color 20% darker. This is intended to reduce the likelihood',
|
| 23 |
+
'of reusing the same color when you have many slices, but you can',
|
| 24 |
+
'set `false` to disable.',
|
| 25 |
+
'Colors provided in the trace, using `marker.colors`, are never',
|
| 26 |
+
'extended.'
|
| 27 |
+
].join(' ')
|
| 28 |
+
}
|
| 29 |
+
};
|
node_modules/plotly.js/src/traces/treemap/layout_defaults.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var layoutAttributes = require('./layout_attributes');
|
| 5 |
+
|
| 6 |
+
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
|
| 7 |
+
function coerce(attr, dflt) {
|
| 8 |
+
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
|
| 9 |
+
}
|
| 10 |
+
coerce('treemapcolorway', layoutOut.colorway);
|
| 11 |
+
coerce('extendtreemapcolors');
|
| 12 |
+
};
|
node_modules/plotly.js/src/traces/treemap/partition.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3Hierarchy = require('d3-hierarchy');
|
| 4 |
+
var flipTree = require('./flip_tree');
|
| 5 |
+
|
| 6 |
+
module.exports = function partition(entry, size, opts) {
|
| 7 |
+
var flipX = opts.flipX;
|
| 8 |
+
var flipY = opts.flipY;
|
| 9 |
+
var swapXY = opts.packing === 'dice-slice';
|
| 10 |
+
|
| 11 |
+
var top = opts.pad[flipY ? 'bottom' : 'top'];
|
| 12 |
+
var left = opts.pad[flipX ? 'right' : 'left'];
|
| 13 |
+
var right = opts.pad[flipX ? 'left' : 'right'];
|
| 14 |
+
var bottom = opts.pad[flipY ? 'top' : 'bottom'];
|
| 15 |
+
|
| 16 |
+
var tmp;
|
| 17 |
+
if(swapXY) {
|
| 18 |
+
tmp = left;
|
| 19 |
+
left = top;
|
| 20 |
+
top = tmp;
|
| 21 |
+
|
| 22 |
+
tmp = right;
|
| 23 |
+
right = bottom;
|
| 24 |
+
bottom = tmp;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
var result = d3Hierarchy
|
| 28 |
+
.treemap()
|
| 29 |
+
.tile(getTilingMethod(opts.packing, opts.squarifyratio))
|
| 30 |
+
.paddingInner(opts.pad.inner)
|
| 31 |
+
.paddingLeft(left)
|
| 32 |
+
.paddingRight(right)
|
| 33 |
+
.paddingTop(top)
|
| 34 |
+
.paddingBottom(bottom)
|
| 35 |
+
.size(
|
| 36 |
+
swapXY ? [size[1], size[0]] : size
|
| 37 |
+
)(entry);
|
| 38 |
+
|
| 39 |
+
if(swapXY || flipX || flipY) {
|
| 40 |
+
flipTree(result, size, {
|
| 41 |
+
swapXY: swapXY,
|
| 42 |
+
flipX: flipX,
|
| 43 |
+
flipY: flipY
|
| 44 |
+
});
|
| 45 |
+
}
|
| 46 |
+
return result;
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
function getTilingMethod(key, squarifyratio) {
|
| 50 |
+
switch(key) {
|
| 51 |
+
case 'squarify':
|
| 52 |
+
return d3Hierarchy.treemapSquarify.ratio(squarifyratio);
|
| 53 |
+
case 'binary':
|
| 54 |
+
return d3Hierarchy.treemapBinary;
|
| 55 |
+
case 'dice':
|
| 56 |
+
return d3Hierarchy.treemapDice;
|
| 57 |
+
case 'slice':
|
| 58 |
+
return d3Hierarchy.treemapSlice;
|
| 59 |
+
default: // i.e. 'slice-dice' | 'dice-slice'
|
| 60 |
+
return d3Hierarchy.treemapSliceDice;
|
| 61 |
+
}
|
| 62 |
+
}
|
node_modules/plotly.js/src/traces/treemap/plot.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var draw = require('./draw');
|
| 4 |
+
var drawDescendants = require('./draw_descendants');
|
| 5 |
+
|
| 6 |
+
module.exports = function _plot(gd, cdmodule, transitionOpts, makeOnCompleteCallback) {
|
| 7 |
+
return draw(gd, cdmodule, transitionOpts, makeOnCompleteCallback, {
|
| 8 |
+
type: 'treemap',
|
| 9 |
+
drawDescendants: drawDescendants
|
| 10 |
+
});
|
| 11 |
+
};
|
node_modules/plotly.js/src/traces/treemap/plot_one.js
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var interpolate = require('d3-interpolate').interpolate;
|
| 5 |
+
|
| 6 |
+
var helpers = require('../sunburst/helpers');
|
| 7 |
+
|
| 8 |
+
var Lib = require('../../lib');
|
| 9 |
+
var TEXTPAD = require('../bar/constants').TEXTPAD;
|
| 10 |
+
var barPlot = require('../bar/plot');
|
| 11 |
+
var toMoveInsideBar = barPlot.toMoveInsideBar;
|
| 12 |
+
var uniformText = require('../bar/uniform_text');
|
| 13 |
+
var recordMinTextSize = uniformText.recordMinTextSize;
|
| 14 |
+
var constants = require('./constants');
|
| 15 |
+
var drawAncestors = require('./draw_ancestors');
|
| 16 |
+
|
| 17 |
+
function getKey(pt) {
|
| 18 |
+
return helpers.isHierarchyRoot(pt) ?
|
| 19 |
+
'' : // don't use the dummyId
|
| 20 |
+
helpers.getPtId(pt);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
module.exports = function plotOne(gd, cd, element, transitionOpts, drawDescendants) {
|
| 24 |
+
var fullLayout = gd._fullLayout;
|
| 25 |
+
var cd0 = cd[0];
|
| 26 |
+
var trace = cd0.trace;
|
| 27 |
+
var type = trace.type;
|
| 28 |
+
var isIcicle = type === 'icicle';
|
| 29 |
+
|
| 30 |
+
var hierarchy = cd0.hierarchy;
|
| 31 |
+
var entry = helpers.findEntryWithLevel(hierarchy, trace.level);
|
| 32 |
+
|
| 33 |
+
var gTrace = d3.select(element);
|
| 34 |
+
var selAncestors = gTrace.selectAll('g.pathbar');
|
| 35 |
+
var selDescendants = gTrace.selectAll('g.slice');
|
| 36 |
+
|
| 37 |
+
if(!entry) {
|
| 38 |
+
selAncestors.remove();
|
| 39 |
+
selDescendants.remove();
|
| 40 |
+
return;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
var isRoot = helpers.isHierarchyRoot(entry);
|
| 44 |
+
var hasTransition = !fullLayout.uniformtext.mode && helpers.hasTransition(transitionOpts);
|
| 45 |
+
|
| 46 |
+
var maxDepth = helpers.getMaxDepth(trace);
|
| 47 |
+
var hasVisibleDepth = function(pt) {
|
| 48 |
+
return pt.data.depth - entry.data.depth < maxDepth;
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
var gs = fullLayout._size;
|
| 52 |
+
var domain = trace.domain;
|
| 53 |
+
|
| 54 |
+
var vpw = gs.w * (domain.x[1] - domain.x[0]);
|
| 55 |
+
var vph = gs.h * (domain.y[1] - domain.y[0]);
|
| 56 |
+
var barW = vpw;
|
| 57 |
+
var barH = trace.pathbar.thickness;
|
| 58 |
+
var barPad = trace.marker.line.width + constants.gapWithPathbar;
|
| 59 |
+
var barDifY = !trace.pathbar.visible ? 0 :
|
| 60 |
+
trace.pathbar.side.indexOf('bottom') > -1 ? vph + barPad : -(barH + barPad);
|
| 61 |
+
|
| 62 |
+
var pathbarOrigin = {
|
| 63 |
+
x0: barW, // slide to the right
|
| 64 |
+
x1: barW,
|
| 65 |
+
y0: barDifY,
|
| 66 |
+
y1: barDifY + barH
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
var findClosestEdge = function(pt, ref, size) {
|
| 70 |
+
var e = trace.tiling.pad;
|
| 71 |
+
var isLeftOfRect = function(x) { return x - e <= ref.x0; };
|
| 72 |
+
var isRightOfRect = function(x) { return x + e >= ref.x1; };
|
| 73 |
+
var isBottomOfRect = function(y) { return y - e <= ref.y0; };
|
| 74 |
+
var isTopOfRect = function(y) { return y + e >= ref.y1; };
|
| 75 |
+
|
| 76 |
+
if(pt.x0 === ref.x0 && pt.x1 === ref.x1 && pt.y0 === ref.y0 && pt.y1 === ref.y1) {
|
| 77 |
+
return {
|
| 78 |
+
x0: pt.x0,
|
| 79 |
+
x1: pt.x1,
|
| 80 |
+
y0: pt.y0,
|
| 81 |
+
y1: pt.y1
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
return {
|
| 86 |
+
x0: isLeftOfRect(pt.x0 - e) ? 0 : isRightOfRect(pt.x0 - e) ? size[0] : pt.x0,
|
| 87 |
+
x1: isLeftOfRect(pt.x1 + e) ? 0 : isRightOfRect(pt.x1 + e) ? size[0] : pt.x1,
|
| 88 |
+
y0: isBottomOfRect(pt.y0 - e) ? 0 : isTopOfRect(pt.y0 - e) ? size[1] : pt.y0,
|
| 89 |
+
y1: isBottomOfRect(pt.y1 + e) ? 0 : isTopOfRect(pt.y1 + e) ? size[1] : pt.y1
|
| 90 |
+
};
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
// stash of 'previous' position data used by tweening functions
|
| 94 |
+
var prevEntry = null;
|
| 95 |
+
var prevLookupPathbar = {};
|
| 96 |
+
var prevLookupSlices = {};
|
| 97 |
+
var nextOfPrevEntry = null;
|
| 98 |
+
var getPrev = function(pt, onPathbar) {
|
| 99 |
+
return onPathbar ?
|
| 100 |
+
prevLookupPathbar[getKey(pt)] :
|
| 101 |
+
prevLookupSlices[getKey(pt)];
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
var getOrigin = function(pt, onPathbar, refRect, size) {
|
| 105 |
+
if(onPathbar) {
|
| 106 |
+
return prevLookupPathbar[getKey(hierarchy)] || pathbarOrigin;
|
| 107 |
+
} else {
|
| 108 |
+
var ref = prevLookupSlices[trace.level] || refRect;
|
| 109 |
+
|
| 110 |
+
if(hasVisibleDepth(pt)) { // case of an empty object - happens when maxdepth is set
|
| 111 |
+
return findClosestEdge(pt, ref, size);
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
return {};
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
// N.B. handle multiple-root special case
|
| 118 |
+
if(cd0.hasMultipleRoots && isRoot) {
|
| 119 |
+
maxDepth++;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
trace._maxDepth = maxDepth;
|
| 123 |
+
trace._backgroundColor = fullLayout.paper_bgcolor;
|
| 124 |
+
trace._entryDepth = entry.data.depth;
|
| 125 |
+
trace._atRootLevel = isRoot;
|
| 126 |
+
|
| 127 |
+
var cenX = -vpw / 2 + gs.l + gs.w * (domain.x[1] + domain.x[0]) / 2;
|
| 128 |
+
var cenY = -vph / 2 + gs.t + gs.h * (1 - (domain.y[1] + domain.y[0]) / 2);
|
| 129 |
+
|
| 130 |
+
var viewMapX = function(x) { return cenX + x; };
|
| 131 |
+
var viewMapY = function(y) { return cenY + y; };
|
| 132 |
+
|
| 133 |
+
var barY0 = viewMapY(0);
|
| 134 |
+
var barX0 = viewMapX(0);
|
| 135 |
+
|
| 136 |
+
var viewBarX = function(x) { return barX0 + x; };
|
| 137 |
+
var viewBarY = function(y) { return barY0 + y; };
|
| 138 |
+
|
| 139 |
+
function pos(x, y) {
|
| 140 |
+
return x + ',' + y;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
var xStart = viewBarX(0);
|
| 144 |
+
var limitX0 = function(p) { p.x = Math.max(xStart, p.x); };
|
| 145 |
+
|
| 146 |
+
var edgeshape = trace.pathbar.edgeshape;
|
| 147 |
+
|
| 148 |
+
// pathbar(directory) path generation fn
|
| 149 |
+
var pathAncestor = function(d) {
|
| 150 |
+
var _x0 = viewBarX(Math.max(Math.min(d.x0, d.x0), 0));
|
| 151 |
+
var _x1 = viewBarX(Math.min(Math.max(d.x1, d.x1), barW));
|
| 152 |
+
var _y0 = viewBarY(d.y0);
|
| 153 |
+
var _y1 = viewBarY(d.y1);
|
| 154 |
+
|
| 155 |
+
var halfH = barH / 2;
|
| 156 |
+
|
| 157 |
+
var pL = {};
|
| 158 |
+
var pR = {};
|
| 159 |
+
|
| 160 |
+
pL.x = _x0;
|
| 161 |
+
pR.x = _x1;
|
| 162 |
+
|
| 163 |
+
pL.y = pR.y = (_y0 + _y1) / 2;
|
| 164 |
+
|
| 165 |
+
var pA = {x: _x0, y: _y0};
|
| 166 |
+
var pB = {x: _x1, y: _y0};
|
| 167 |
+
var pC = {x: _x1, y: _y1};
|
| 168 |
+
var pD = {x: _x0, y: _y1};
|
| 169 |
+
|
| 170 |
+
if(edgeshape === '>') {
|
| 171 |
+
pA.x -= halfH;
|
| 172 |
+
pB.x -= halfH;
|
| 173 |
+
pC.x -= halfH;
|
| 174 |
+
pD.x -= halfH;
|
| 175 |
+
} else if(edgeshape === '/') {
|
| 176 |
+
pC.x -= halfH;
|
| 177 |
+
pD.x -= halfH;
|
| 178 |
+
pL.x -= halfH / 2;
|
| 179 |
+
pR.x -= halfH / 2;
|
| 180 |
+
} else if(edgeshape === '\\') {
|
| 181 |
+
pA.x -= halfH;
|
| 182 |
+
pB.x -= halfH;
|
| 183 |
+
pL.x -= halfH / 2;
|
| 184 |
+
pR.x -= halfH / 2;
|
| 185 |
+
} else if(edgeshape === '<') {
|
| 186 |
+
pL.x -= halfH;
|
| 187 |
+
pR.x -= halfH;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
limitX0(pA);
|
| 191 |
+
limitX0(pD);
|
| 192 |
+
limitX0(pL);
|
| 193 |
+
|
| 194 |
+
limitX0(pB);
|
| 195 |
+
limitX0(pC);
|
| 196 |
+
limitX0(pR);
|
| 197 |
+
|
| 198 |
+
return (
|
| 199 |
+
'M' + pos(pA.x, pA.y) +
|
| 200 |
+
'L' + pos(pB.x, pB.y) +
|
| 201 |
+
'L' + pos(pR.x, pR.y) +
|
| 202 |
+
'L' + pos(pC.x, pC.y) +
|
| 203 |
+
'L' + pos(pD.x, pD.y) +
|
| 204 |
+
'L' + pos(pL.x, pL.y) +
|
| 205 |
+
'Z'
|
| 206 |
+
);
|
| 207 |
+
};
|
| 208 |
+
|
| 209 |
+
// Note that `pad` is just an integer for `icicle`` traces where
|
| 210 |
+
// `pad` is a hashmap for treemap: pad.t, pad.b, pad.l, and pad.r
|
| 211 |
+
var pad = trace[isIcicle ? 'tiling' : 'marker'].pad;
|
| 212 |
+
|
| 213 |
+
var hasFlag = function(f) { return trace.textposition.indexOf(f) !== -1; };
|
| 214 |
+
|
| 215 |
+
var hasTop = hasFlag('top');
|
| 216 |
+
var hasLeft = hasFlag('left');
|
| 217 |
+
var hasRight = hasFlag('right');
|
| 218 |
+
var hasBottom = hasFlag('bottom');
|
| 219 |
+
|
| 220 |
+
// slice path generation fn
|
| 221 |
+
var pathDescendant = function(d) {
|
| 222 |
+
var _x0 = viewMapX(d.x0);
|
| 223 |
+
var _x1 = viewMapX(d.x1);
|
| 224 |
+
var _y0 = viewMapY(d.y0);
|
| 225 |
+
var _y1 = viewMapY(d.y1);
|
| 226 |
+
|
| 227 |
+
var dx = _x1 - _x0;
|
| 228 |
+
var dy = _y1 - _y0;
|
| 229 |
+
if(!dx || !dy) return '';
|
| 230 |
+
|
| 231 |
+
var cornerradius = trace.marker.cornerradius || 0;
|
| 232 |
+
var r = Math.min(cornerradius, dx / 2, dy / 2);
|
| 233 |
+
if(
|
| 234 |
+
r &&
|
| 235 |
+
d.data &&
|
| 236 |
+
d.data.data &&
|
| 237 |
+
d.data.data.label
|
| 238 |
+
) {
|
| 239 |
+
if(hasTop) r = Math.min(r, pad.t);
|
| 240 |
+
if(hasLeft) r = Math.min(r, pad.l);
|
| 241 |
+
if(hasRight) r = Math.min(r, pad.r);
|
| 242 |
+
if(hasBottom) r = Math.min(r, pad.b);
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
var arc = function(rx, ry) { return r ? 'a' + pos(r, r) + ' 0 0 1 ' + pos(rx, ry) : ''; };
|
| 246 |
+
|
| 247 |
+
return (
|
| 248 |
+
'M' + pos(_x0, _y0 + r) +
|
| 249 |
+
arc(r, -r) +
|
| 250 |
+
'L' + pos(_x1 - r, _y0) +
|
| 251 |
+
arc(r, r) +
|
| 252 |
+
'L' + pos(_x1, _y1 - r) +
|
| 253 |
+
arc(-r, r) +
|
| 254 |
+
'L' + pos(_x0 + r, _y1) +
|
| 255 |
+
arc(-r, -r) + 'Z'
|
| 256 |
+
);
|
| 257 |
+
};
|
| 258 |
+
|
| 259 |
+
var toMoveInsideSlice = function(pt, opts) {
|
| 260 |
+
var x0 = pt.x0;
|
| 261 |
+
var x1 = pt.x1;
|
| 262 |
+
var y0 = pt.y0;
|
| 263 |
+
var y1 = pt.y1;
|
| 264 |
+
var textBB = pt.textBB;
|
| 265 |
+
|
| 266 |
+
var _hasTop = hasTop || (opts.isHeader && !hasBottom);
|
| 267 |
+
|
| 268 |
+
var anchor =
|
| 269 |
+
_hasTop ? 'start' :
|
| 270 |
+
hasBottom ? 'end' : 'middle';
|
| 271 |
+
|
| 272 |
+
var _hasRight = hasFlag('right');
|
| 273 |
+
var _hasLeft = hasFlag('left') || opts.onPathbar;
|
| 274 |
+
|
| 275 |
+
var leftToRight =
|
| 276 |
+
_hasLeft ? -1 :
|
| 277 |
+
_hasRight ? 1 : 0;
|
| 278 |
+
|
| 279 |
+
if(opts.isHeader) {
|
| 280 |
+
x0 += (isIcicle ? pad : pad.l) - TEXTPAD;
|
| 281 |
+
x1 -= (isIcicle ? pad : pad.r) - TEXTPAD;
|
| 282 |
+
if(x0 >= x1) {
|
| 283 |
+
var mid = (x0 + x1) / 2;
|
| 284 |
+
x0 = mid;
|
| 285 |
+
x1 = mid;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
// limit the drawing area for headers
|
| 289 |
+
var limY;
|
| 290 |
+
if(hasBottom) {
|
| 291 |
+
limY = y1 - (isIcicle ? pad : pad.b);
|
| 292 |
+
if(y0 < limY && limY < y1) y0 = limY;
|
| 293 |
+
} else {
|
| 294 |
+
limY = y0 + (isIcicle ? pad : pad.t);
|
| 295 |
+
if(y0 < limY && limY < y1) y1 = limY;
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
// position the text relative to the slice
|
| 300 |
+
var transform = toMoveInsideBar(x0, x1, y0, y1, textBB, {
|
| 301 |
+
isHorizontal: false,
|
| 302 |
+
constrained: true,
|
| 303 |
+
angle: 0,
|
| 304 |
+
anchor: anchor,
|
| 305 |
+
leftToRight: leftToRight
|
| 306 |
+
});
|
| 307 |
+
transform.fontSize = opts.fontSize;
|
| 308 |
+
|
| 309 |
+
transform.targetX = viewMapX(transform.targetX);
|
| 310 |
+
transform.targetY = viewMapY(transform.targetY);
|
| 311 |
+
|
| 312 |
+
if(isNaN(transform.targetX) || isNaN(transform.targetY)) {
|
| 313 |
+
return {};
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
if(x0 !== x1 && y0 !== y1) {
|
| 317 |
+
recordMinTextSize(trace.type, transform, fullLayout);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
return {
|
| 321 |
+
scale: transform.scale,
|
| 322 |
+
rotate: transform.rotate,
|
| 323 |
+
textX: transform.textX,
|
| 324 |
+
textY: transform.textY,
|
| 325 |
+
anchorX: transform.anchorX,
|
| 326 |
+
anchorY: transform.anchorY,
|
| 327 |
+
targetX: transform.targetX,
|
| 328 |
+
targetY: transform.targetY
|
| 329 |
+
};
|
| 330 |
+
};
|
| 331 |
+
|
| 332 |
+
var interpFromParent = function(pt, onPathbar) {
|
| 333 |
+
var parentPrev;
|
| 334 |
+
var i = 0;
|
| 335 |
+
var Q = pt;
|
| 336 |
+
while(!parentPrev && i < maxDepth) { // loop to find a parent/grandParent on the previous graph
|
| 337 |
+
i++;
|
| 338 |
+
Q = Q.parent;
|
| 339 |
+
if(Q) {
|
| 340 |
+
parentPrev = getPrev(Q, onPathbar);
|
| 341 |
+
} else i = maxDepth;
|
| 342 |
+
}
|
| 343 |
+
return parentPrev || {};
|
| 344 |
+
};
|
| 345 |
+
|
| 346 |
+
var makeExitSliceInterpolator = function(pt, onPathbar, refRect, size) {
|
| 347 |
+
var prev = getPrev(pt, onPathbar);
|
| 348 |
+
var next;
|
| 349 |
+
|
| 350 |
+
if(onPathbar) {
|
| 351 |
+
next = pathbarOrigin;
|
| 352 |
+
} else {
|
| 353 |
+
var entryPrev = getPrev(entry, onPathbar);
|
| 354 |
+
if(entryPrev) {
|
| 355 |
+
// 'entryPrev' is here has the previous coordinates of the entry
|
| 356 |
+
// node, which corresponds to the last "clicked" node when zooming in
|
| 357 |
+
next = findClosestEdge(pt, entryPrev, size);
|
| 358 |
+
} else {
|
| 359 |
+
// this happens when maxdepth is set, when leaves must
|
| 360 |
+
// be removed and the entry is new (i.e. does not have a 'prev' object)
|
| 361 |
+
next = {};
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
return interpolate(prev, next);
|
| 366 |
+
};
|
| 367 |
+
|
| 368 |
+
var makeUpdateSliceInterpolator = function(pt, onPathbar, refRect, size, opts) {
|
| 369 |
+
var prev0 = getPrev(pt, onPathbar);
|
| 370 |
+
var prev;
|
| 371 |
+
|
| 372 |
+
if(prev0) {
|
| 373 |
+
// if pt already on graph, this is easy
|
| 374 |
+
prev = prev0;
|
| 375 |
+
} else {
|
| 376 |
+
// for new pts:
|
| 377 |
+
if(onPathbar) {
|
| 378 |
+
prev = pathbarOrigin;
|
| 379 |
+
} else {
|
| 380 |
+
if(prevEntry) {
|
| 381 |
+
// if trace was visible before
|
| 382 |
+
if(pt.parent) {
|
| 383 |
+
var ref = nextOfPrevEntry || refRect;
|
| 384 |
+
|
| 385 |
+
if(ref && !onPathbar) {
|
| 386 |
+
prev = findClosestEdge(pt, ref, size);
|
| 387 |
+
} else {
|
| 388 |
+
// if new leaf (when maxdepth is set),
|
| 389 |
+
// grow it from its parent node
|
| 390 |
+
prev = {};
|
| 391 |
+
Lib.extendFlat(prev, interpFromParent(pt, onPathbar));
|
| 392 |
+
}
|
| 393 |
+
} else {
|
| 394 |
+
prev = Lib.extendFlat({}, pt);
|
| 395 |
+
if(isIcicle) {
|
| 396 |
+
if(opts.orientation === 'h') {
|
| 397 |
+
if(opts.flipX) prev.x0 = pt.x1;
|
| 398 |
+
else prev.x1 = 0;
|
| 399 |
+
} else {
|
| 400 |
+
if(opts.flipY) prev.y0 = pt.y1;
|
| 401 |
+
else prev.y1 = 0;
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
} else {
|
| 406 |
+
prev = {};
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
return interpolate(prev, {
|
| 412 |
+
x0: pt.x0,
|
| 413 |
+
x1: pt.x1,
|
| 414 |
+
y0: pt.y0,
|
| 415 |
+
y1: pt.y1
|
| 416 |
+
});
|
| 417 |
+
};
|
| 418 |
+
|
| 419 |
+
var makeUpdateTextInterpolator = function(pt, onPathbar, refRect, size) {
|
| 420 |
+
var prev0 = getPrev(pt, onPathbar);
|
| 421 |
+
var prev = {};
|
| 422 |
+
var origin = getOrigin(pt, onPathbar, refRect, size);
|
| 423 |
+
|
| 424 |
+
Lib.extendFlat(prev, {
|
| 425 |
+
transform: toMoveInsideSlice({
|
| 426 |
+
x0: origin.x0,
|
| 427 |
+
x1: origin.x1,
|
| 428 |
+
y0: origin.y0,
|
| 429 |
+
y1: origin.y1,
|
| 430 |
+
textBB: pt.textBB,
|
| 431 |
+
_text: pt._text
|
| 432 |
+
}, {
|
| 433 |
+
isHeader: helpers.isHeader(pt, trace)
|
| 434 |
+
})
|
| 435 |
+
});
|
| 436 |
+
|
| 437 |
+
if(prev0) {
|
| 438 |
+
// if pt already on graph, this is easy
|
| 439 |
+
prev = prev0;
|
| 440 |
+
} else {
|
| 441 |
+
// for new pts:
|
| 442 |
+
if(pt.parent) {
|
| 443 |
+
Lib.extendFlat(prev, interpFromParent(pt, onPathbar));
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
var transform = pt.transform;
|
| 448 |
+
if(pt.x0 !== pt.x1 && pt.y0 !== pt.y1) {
|
| 449 |
+
recordMinTextSize(trace.type, transform, fullLayout);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
return interpolate(prev, {
|
| 453 |
+
transform: {
|
| 454 |
+
scale: transform.scale,
|
| 455 |
+
rotate: transform.rotate,
|
| 456 |
+
textX: transform.textX,
|
| 457 |
+
textY: transform.textY,
|
| 458 |
+
anchorX: transform.anchorX,
|
| 459 |
+
anchorY: transform.anchorY,
|
| 460 |
+
targetX: transform.targetX,
|
| 461 |
+
targetY: transform.targetY
|
| 462 |
+
}
|
| 463 |
+
});
|
| 464 |
+
};
|
| 465 |
+
|
| 466 |
+
var handleSlicesExit = function(slices, onPathbar, refRect, size, pathSlice) {
|
| 467 |
+
var width = size[0];
|
| 468 |
+
var height = size[1];
|
| 469 |
+
|
| 470 |
+
if(hasTransition) {
|
| 471 |
+
slices.exit().transition()
|
| 472 |
+
.each(function() {
|
| 473 |
+
var sliceTop = d3.select(this);
|
| 474 |
+
|
| 475 |
+
var slicePath = sliceTop.select('path.surface');
|
| 476 |
+
slicePath.transition().attrTween('d', function(pt2) {
|
| 477 |
+
var interp = makeExitSliceInterpolator(pt2, onPathbar, refRect, [width, height]);
|
| 478 |
+
return function(t) { return pathSlice(interp(t)); };
|
| 479 |
+
});
|
| 480 |
+
|
| 481 |
+
var sliceTextGroup = sliceTop.select('g.slicetext');
|
| 482 |
+
sliceTextGroup.attr('opacity', 0);
|
| 483 |
+
})
|
| 484 |
+
.remove();
|
| 485 |
+
} else {
|
| 486 |
+
slices.exit().remove();
|
| 487 |
+
}
|
| 488 |
+
};
|
| 489 |
+
|
| 490 |
+
var strTransform = function(d) {
|
| 491 |
+
var transform = d.transform;
|
| 492 |
+
|
| 493 |
+
if(d.x0 !== d.x1 && d.y0 !== d.y1) {
|
| 494 |
+
recordMinTextSize(trace.type, transform, fullLayout);
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
return Lib.getTextTransform({
|
| 498 |
+
textX: transform.textX,
|
| 499 |
+
textY: transform.textY,
|
| 500 |
+
anchorX: transform.anchorX,
|
| 501 |
+
anchorY: transform.anchorY,
|
| 502 |
+
targetX: transform.targetX,
|
| 503 |
+
targetY: transform.targetY,
|
| 504 |
+
scale: transform.scale,
|
| 505 |
+
rotate: transform.rotate
|
| 506 |
+
});
|
| 507 |
+
};
|
| 508 |
+
|
| 509 |
+
if(hasTransition) {
|
| 510 |
+
// Important: do this before binding new sliceData!
|
| 511 |
+
|
| 512 |
+
selAncestors.each(function(pt) {
|
| 513 |
+
prevLookupPathbar[getKey(pt)] = {
|
| 514 |
+
x0: pt.x0,
|
| 515 |
+
x1: pt.x1,
|
| 516 |
+
y0: pt.y0,
|
| 517 |
+
y1: pt.y1
|
| 518 |
+
};
|
| 519 |
+
|
| 520 |
+
if(pt.transform) {
|
| 521 |
+
prevLookupPathbar[getKey(pt)].transform = {
|
| 522 |
+
textX: pt.transform.textX,
|
| 523 |
+
textY: pt.transform.textY,
|
| 524 |
+
anchorX: pt.transform.anchorX,
|
| 525 |
+
anchorY: pt.transform.anchorY,
|
| 526 |
+
targetX: pt.transform.targetX,
|
| 527 |
+
targetY: pt.transform.targetY,
|
| 528 |
+
scale: pt.transform.scale,
|
| 529 |
+
rotate: pt.transform.rotate
|
| 530 |
+
};
|
| 531 |
+
}
|
| 532 |
+
});
|
| 533 |
+
|
| 534 |
+
selDescendants.each(function(pt) {
|
| 535 |
+
prevLookupSlices[getKey(pt)] = {
|
| 536 |
+
x0: pt.x0,
|
| 537 |
+
x1: pt.x1,
|
| 538 |
+
y0: pt.y0,
|
| 539 |
+
y1: pt.y1
|
| 540 |
+
};
|
| 541 |
+
|
| 542 |
+
if(pt.transform) {
|
| 543 |
+
prevLookupSlices[getKey(pt)].transform = {
|
| 544 |
+
textX: pt.transform.textX,
|
| 545 |
+
textY: pt.transform.textY,
|
| 546 |
+
anchorX: pt.transform.anchorX,
|
| 547 |
+
anchorY: pt.transform.anchorY,
|
| 548 |
+
targetX: pt.transform.targetX,
|
| 549 |
+
targetY: pt.transform.targetY,
|
| 550 |
+
scale: pt.transform.scale,
|
| 551 |
+
rotate: pt.transform.rotate
|
| 552 |
+
};
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
if(!prevEntry && helpers.isEntry(pt)) {
|
| 556 |
+
prevEntry = pt;
|
| 557 |
+
}
|
| 558 |
+
});
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
nextOfPrevEntry = drawDescendants(gd, cd, entry, selDescendants, {
|
| 562 |
+
width: vpw,
|
| 563 |
+
height: vph,
|
| 564 |
+
|
| 565 |
+
viewX: viewMapX,
|
| 566 |
+
viewY: viewMapY,
|
| 567 |
+
|
| 568 |
+
pathSlice: pathDescendant,
|
| 569 |
+
toMoveInsideSlice: toMoveInsideSlice,
|
| 570 |
+
|
| 571 |
+
prevEntry: prevEntry,
|
| 572 |
+
makeUpdateSliceInterpolator: makeUpdateSliceInterpolator,
|
| 573 |
+
makeUpdateTextInterpolator: makeUpdateTextInterpolator,
|
| 574 |
+
|
| 575 |
+
handleSlicesExit: handleSlicesExit,
|
| 576 |
+
hasTransition: hasTransition,
|
| 577 |
+
strTransform: strTransform
|
| 578 |
+
});
|
| 579 |
+
|
| 580 |
+
if(trace.pathbar.visible) {
|
| 581 |
+
drawAncestors(gd, cd, entry, selAncestors, {
|
| 582 |
+
barDifY: barDifY,
|
| 583 |
+
width: barW,
|
| 584 |
+
height: barH,
|
| 585 |
+
|
| 586 |
+
viewX: viewBarX,
|
| 587 |
+
viewY: viewBarY,
|
| 588 |
+
|
| 589 |
+
pathSlice: pathAncestor,
|
| 590 |
+
toMoveInsideSlice: toMoveInsideSlice,
|
| 591 |
+
|
| 592 |
+
makeUpdateSliceInterpolator: makeUpdateSliceInterpolator,
|
| 593 |
+
makeUpdateTextInterpolator: makeUpdateTextInterpolator,
|
| 594 |
+
|
| 595 |
+
handleSlicesExit: handleSlicesExit,
|
| 596 |
+
hasTransition: hasTransition,
|
| 597 |
+
strTransform: strTransform
|
| 598 |
+
});
|
| 599 |
+
} else {
|
| 600 |
+
selAncestors.remove();
|
| 601 |
+
}
|
| 602 |
+
};
|
node_modules/plotly.js/src/traces/treemap/style.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Color = require('../../components/color');
|
| 5 |
+
var Lib = require('../../lib');
|
| 6 |
+
var helpers = require('../sunburst/helpers');
|
| 7 |
+
var resizeText = require('../bar/uniform_text').resizeText;
|
| 8 |
+
var fillOne = require('../sunburst/fill_one');
|
| 9 |
+
|
| 10 |
+
function style(gd) {
|
| 11 |
+
var s = gd._fullLayout._treemaplayer.selectAll('.trace');
|
| 12 |
+
resizeText(gd, s, 'treemap');
|
| 13 |
+
|
| 14 |
+
s.each(function(cd) {
|
| 15 |
+
var gTrace = d3.select(this);
|
| 16 |
+
var cd0 = cd[0];
|
| 17 |
+
var trace = cd0.trace;
|
| 18 |
+
|
| 19 |
+
gTrace.style('opacity', trace.opacity);
|
| 20 |
+
|
| 21 |
+
gTrace.selectAll('path.surface').each(function(pt) {
|
| 22 |
+
d3.select(this).call(styleOne, pt, trace, gd, {
|
| 23 |
+
hovered: false
|
| 24 |
+
});
|
| 25 |
+
});
|
| 26 |
+
});
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function styleOne(s, pt, trace, gd, opts) {
|
| 30 |
+
var hovered = (opts || {}).hovered;
|
| 31 |
+
var cdi = pt.data.data;
|
| 32 |
+
var ptNumber = cdi.i;
|
| 33 |
+
var lineColor;
|
| 34 |
+
var lineWidth;
|
| 35 |
+
var fillColor = cdi.color;
|
| 36 |
+
var isRoot = helpers.isHierarchyRoot(pt);
|
| 37 |
+
var opacity = 1;
|
| 38 |
+
|
| 39 |
+
if(hovered) {
|
| 40 |
+
lineColor = trace._hovered.marker.line.color;
|
| 41 |
+
lineWidth = trace._hovered.marker.line.width;
|
| 42 |
+
} else {
|
| 43 |
+
if(isRoot && fillColor === trace.root.color) {
|
| 44 |
+
opacity = 100;
|
| 45 |
+
lineColor = 'rgba(0,0,0,0)';
|
| 46 |
+
lineWidth = 0;
|
| 47 |
+
} else {
|
| 48 |
+
lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine;
|
| 49 |
+
lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0;
|
| 50 |
+
|
| 51 |
+
if(!trace._hasColorscale && !pt.onPathbar) {
|
| 52 |
+
var depthfade = trace.marker.depthfade;
|
| 53 |
+
if(depthfade) {
|
| 54 |
+
var fadedColor = Color.combine(Color.addOpacity(trace._backgroundColor, 0.75), fillColor);
|
| 55 |
+
var n;
|
| 56 |
+
|
| 57 |
+
if(depthfade === true) {
|
| 58 |
+
var maxDepth = helpers.getMaxDepth(trace);
|
| 59 |
+
if(isFinite(maxDepth)) {
|
| 60 |
+
if(helpers.isLeaf(pt)) {
|
| 61 |
+
n = 0;
|
| 62 |
+
} else {
|
| 63 |
+
n = (trace._maxVisibleLayers) - (pt.data.depth - trace._entryDepth);
|
| 64 |
+
}
|
| 65 |
+
} else {
|
| 66 |
+
n = pt.data.height + 1;
|
| 67 |
+
}
|
| 68 |
+
} else { // i.e. case of depthfade === 'reversed'
|
| 69 |
+
n = pt.data.depth - trace._entryDepth;
|
| 70 |
+
if(!trace._atRootLevel) n++;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
if(n > 0) {
|
| 74 |
+
for(var i = 0; i < n; i++) {
|
| 75 |
+
var ratio = 0.5 * i / n;
|
| 76 |
+
fillColor = Color.combine(Color.addOpacity(fadedColor, ratio), fillColor);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
s.call(fillOne, pt, trace, gd, fillColor)
|
| 85 |
+
.style('stroke-width', lineWidth)
|
| 86 |
+
.call(Color.stroke, lineColor)
|
| 87 |
+
.style('opacity', opacity);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
module.exports = {
|
| 91 |
+
style: style,
|
| 92 |
+
styleOne: styleOne
|
| 93 |
+
};
|
node_modules/plotly.js/src/traces/violin/attributes.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var boxAttrs = require('../box/attributes');
|
| 4 |
+
var extendFlat = require('../../lib/extend').extendFlat;
|
| 5 |
+
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
|
| 6 |
+
|
| 7 |
+
module.exports = {
|
| 8 |
+
y: boxAttrs.y,
|
| 9 |
+
x: boxAttrs.x,
|
| 10 |
+
x0: boxAttrs.x0,
|
| 11 |
+
y0: boxAttrs.y0,
|
| 12 |
+
|
| 13 |
+
xhoverformat: axisHoverFormat('x'),
|
| 14 |
+
yhoverformat: axisHoverFormat('y'),
|
| 15 |
+
|
| 16 |
+
name: extendFlat({}, boxAttrs.name, {
|
| 17 |
+
description: [
|
| 18 |
+
'Sets the trace name.',
|
| 19 |
+
'The trace name appears as the legend item and on hover.',
|
| 20 |
+
'For violin traces, the name will also be used for the position',
|
| 21 |
+
'coordinate, if `x` and `x0` (`y` and `y0` if horizontal) are',
|
| 22 |
+
'missing and the position axis is categorical.',
|
| 23 |
+
'Note that the trace name is also used as a default value',
|
| 24 |
+
'for attribute `scalegroup` (please see its description for details).'
|
| 25 |
+
].join(' ')
|
| 26 |
+
}),
|
| 27 |
+
orientation: extendFlat({}, boxAttrs.orientation, {
|
| 28 |
+
description: [
|
| 29 |
+
'Sets the orientation of the violin(s).',
|
| 30 |
+
'If *v* (*h*), the distribution is visualized along',
|
| 31 |
+
'the vertical (horizontal).'
|
| 32 |
+
].join(' ')
|
| 33 |
+
}),
|
| 34 |
+
|
| 35 |
+
bandwidth: {
|
| 36 |
+
valType: 'number',
|
| 37 |
+
min: 0,
|
| 38 |
+
editType: 'calc',
|
| 39 |
+
description: [
|
| 40 |
+
'Sets the bandwidth used to compute the kernel density estimate.',
|
| 41 |
+
'By default, the bandwidth is determined by Silverman\'s rule of thumb.'
|
| 42 |
+
].join(' ')
|
| 43 |
+
},
|
| 44 |
+
|
| 45 |
+
scalegroup: {
|
| 46 |
+
valType: 'string',
|
| 47 |
+
dflt: '',
|
| 48 |
+
editType: 'calc',
|
| 49 |
+
description: [
|
| 50 |
+
'If there are multiple violins that should be sized according to',
|
| 51 |
+
'to some metric (see `scalemode`), link them by providing a non-empty group id here',
|
| 52 |
+
'shared by every trace in the same group.',
|
| 53 |
+
'If a violin\'s `width` is undefined, `scalegroup` will default to the trace\'s name.',
|
| 54 |
+
'In this case, violins with the same names will be linked together'
|
| 55 |
+
].join(' ')
|
| 56 |
+
},
|
| 57 |
+
scalemode: {
|
| 58 |
+
valType: 'enumerated',
|
| 59 |
+
values: ['width', 'count'],
|
| 60 |
+
dflt: 'width',
|
| 61 |
+
editType: 'calc',
|
| 62 |
+
description: [
|
| 63 |
+
'Sets the metric by which the width of each violin is determined.',
|
| 64 |
+
'*width* means each violin has the same (max) width',
|
| 65 |
+
'*count* means the violins are scaled by the number of sample points making',
|
| 66 |
+
'up each violin.'
|
| 67 |
+
].join(' ')
|
| 68 |
+
},
|
| 69 |
+
|
| 70 |
+
spanmode: {
|
| 71 |
+
valType: 'enumerated',
|
| 72 |
+
values: ['soft', 'hard', 'manual'],
|
| 73 |
+
dflt: 'soft',
|
| 74 |
+
editType: 'calc',
|
| 75 |
+
description: [
|
| 76 |
+
'Sets the method by which the span in data space where the density function will be computed.',
|
| 77 |
+
'*soft* means the span goes from the sample\'s minimum value minus two bandwidths',
|
| 78 |
+
'to the sample\'s maximum value plus two bandwidths.',
|
| 79 |
+
'*hard* means the span goes from the sample\'s minimum to its maximum value.',
|
| 80 |
+
'For custom span settings, use mode *manual* and fill in the `span` attribute.'
|
| 81 |
+
].join(' ')
|
| 82 |
+
},
|
| 83 |
+
span: {
|
| 84 |
+
valType: 'info_array',
|
| 85 |
+
items: [
|
| 86 |
+
{valType: 'any', editType: 'calc'},
|
| 87 |
+
{valType: 'any', editType: 'calc'}
|
| 88 |
+
],
|
| 89 |
+
editType: 'calc',
|
| 90 |
+
description: [
|
| 91 |
+
'Sets the span in data space for which the density function will be computed.',
|
| 92 |
+
'Has an effect only when `spanmode` is set to *manual*.'
|
| 93 |
+
].join(' ')
|
| 94 |
+
},
|
| 95 |
+
|
| 96 |
+
line: {
|
| 97 |
+
color: {
|
| 98 |
+
valType: 'color',
|
| 99 |
+
editType: 'style',
|
| 100 |
+
description: 'Sets the color of line bounding the violin(s).'
|
| 101 |
+
},
|
| 102 |
+
width: {
|
| 103 |
+
valType: 'number',
|
| 104 |
+
min: 0,
|
| 105 |
+
dflt: 2,
|
| 106 |
+
editType: 'style',
|
| 107 |
+
description: 'Sets the width (in px) of line bounding the violin(s).'
|
| 108 |
+
},
|
| 109 |
+
editType: 'plot'
|
| 110 |
+
},
|
| 111 |
+
fillcolor: boxAttrs.fillcolor,
|
| 112 |
+
|
| 113 |
+
points: extendFlat({}, boxAttrs.boxpoints, {
|
| 114 |
+
description: [
|
| 115 |
+
'If *outliers*, only the sample points lying outside the whiskers',
|
| 116 |
+
'are shown',
|
| 117 |
+
'If *suspectedoutliers*, the outlier points are shown and',
|
| 118 |
+
'points either less than 4*Q1-3*Q3 or greater than 4*Q3-3*Q1',
|
| 119 |
+
'are highlighted (see `outliercolor`)',
|
| 120 |
+
'If *all*, all sample points are shown',
|
| 121 |
+
'If *false*, only the violins are shown with no sample points.',
|
| 122 |
+
'Defaults to *suspectedoutliers* when `marker.outliercolor` or',
|
| 123 |
+
'`marker.line.outliercolor` is set,',
|
| 124 |
+
'otherwise defaults to *outliers*.'
|
| 125 |
+
].join(' ')
|
| 126 |
+
}),
|
| 127 |
+
jitter: extendFlat({}, boxAttrs.jitter, {
|
| 128 |
+
description: [
|
| 129 |
+
'Sets the amount of jitter in the sample points drawn.',
|
| 130 |
+
'If *0*, the sample points align along the distribution axis.',
|
| 131 |
+
'If *1*, the sample points are drawn in a random jitter of width',
|
| 132 |
+
'equal to the width of the violins.'
|
| 133 |
+
].join(' ')
|
| 134 |
+
}),
|
| 135 |
+
pointpos: extendFlat({}, boxAttrs.pointpos, {
|
| 136 |
+
description: [
|
| 137 |
+
'Sets the position of the sample points in relation to the violins.',
|
| 138 |
+
'If *0*, the sample points are places over the center of the violins.',
|
| 139 |
+
'Positive (negative) values correspond to positions to the',
|
| 140 |
+
'right (left) for vertical violins and above (below) for horizontal violins.'
|
| 141 |
+
].join(' ')
|
| 142 |
+
}),
|
| 143 |
+
|
| 144 |
+
width: extendFlat({}, boxAttrs.width, {
|
| 145 |
+
description: [
|
| 146 |
+
'Sets the width of the violin in data coordinates.',
|
| 147 |
+
'If *0* (default value) the width is automatically selected based on the positions',
|
| 148 |
+
'of other violin traces in the same subplot.',
|
| 149 |
+
].join(' ')
|
| 150 |
+
}),
|
| 151 |
+
|
| 152 |
+
marker: boxAttrs.marker,
|
| 153 |
+
text: boxAttrs.text,
|
| 154 |
+
hovertext: boxAttrs.hovertext,
|
| 155 |
+
hovertemplate: boxAttrs.hovertemplate,
|
| 156 |
+
|
| 157 |
+
quartilemethod: boxAttrs.quartilemethod,
|
| 158 |
+
|
| 159 |
+
box: {
|
| 160 |
+
visible: {
|
| 161 |
+
valType: 'boolean',
|
| 162 |
+
dflt: false,
|
| 163 |
+
editType: 'plot',
|
| 164 |
+
description: [
|
| 165 |
+
'Determines if an miniature box plot is drawn inside the violins. '
|
| 166 |
+
].join(' ')
|
| 167 |
+
},
|
| 168 |
+
width: {
|
| 169 |
+
valType: 'number',
|
| 170 |
+
min: 0,
|
| 171 |
+
max: 1,
|
| 172 |
+
dflt: 0.25,
|
| 173 |
+
editType: 'plot',
|
| 174 |
+
description: [
|
| 175 |
+
'Sets the width of the inner box plots relative to',
|
| 176 |
+
'the violins\' width.',
|
| 177 |
+
'For example, with 1, the inner box plots are as wide as the violins.'
|
| 178 |
+
].join(' ')
|
| 179 |
+
},
|
| 180 |
+
fillcolor: {
|
| 181 |
+
valType: 'color',
|
| 182 |
+
editType: 'style',
|
| 183 |
+
description: 'Sets the inner box plot fill color.'
|
| 184 |
+
},
|
| 185 |
+
line: {
|
| 186 |
+
color: {
|
| 187 |
+
valType: 'color',
|
| 188 |
+
editType: 'style',
|
| 189 |
+
description: 'Sets the inner box plot bounding line color.'
|
| 190 |
+
},
|
| 191 |
+
width: {
|
| 192 |
+
valType: 'number',
|
| 193 |
+
min: 0,
|
| 194 |
+
editType: 'style',
|
| 195 |
+
description: 'Sets the inner box plot bounding line width.'
|
| 196 |
+
},
|
| 197 |
+
editType: 'style'
|
| 198 |
+
},
|
| 199 |
+
editType: 'plot'
|
| 200 |
+
},
|
| 201 |
+
|
| 202 |
+
meanline: {
|
| 203 |
+
visible: {
|
| 204 |
+
valType: 'boolean',
|
| 205 |
+
dflt: false,
|
| 206 |
+
editType: 'plot',
|
| 207 |
+
description: [
|
| 208 |
+
'Determines if a line corresponding to the sample\'s mean is shown',
|
| 209 |
+
'inside the violins.',
|
| 210 |
+
'If `box.visible` is turned on, the mean line is drawn inside the inner box.',
|
| 211 |
+
'Otherwise, the mean line is drawn from one side of the violin to other.'
|
| 212 |
+
].join(' ')
|
| 213 |
+
},
|
| 214 |
+
color: {
|
| 215 |
+
valType: 'color',
|
| 216 |
+
editType: 'style',
|
| 217 |
+
description: 'Sets the mean line color.'
|
| 218 |
+
},
|
| 219 |
+
width: {
|
| 220 |
+
valType: 'number',
|
| 221 |
+
min: 0,
|
| 222 |
+
editType: 'style',
|
| 223 |
+
description: 'Sets the mean line width.'
|
| 224 |
+
},
|
| 225 |
+
editType: 'plot'
|
| 226 |
+
},
|
| 227 |
+
|
| 228 |
+
side: {
|
| 229 |
+
valType: 'enumerated',
|
| 230 |
+
values: ['both', 'positive', 'negative'],
|
| 231 |
+
dflt: 'both',
|
| 232 |
+
editType: 'calc',
|
| 233 |
+
description: [
|
| 234 |
+
'Determines on which side of the position value the density function making up',
|
| 235 |
+
'one half of a violin is plotted.',
|
| 236 |
+
'Useful when comparing two violin traces under *overlay* mode, where one trace',
|
| 237 |
+
'has `side` set to *positive* and the other to *negative*.'
|
| 238 |
+
].join(' ')
|
| 239 |
+
},
|
| 240 |
+
|
| 241 |
+
offsetgroup: boxAttrs.offsetgroup,
|
| 242 |
+
alignmentgroup: boxAttrs.alignmentgroup,
|
| 243 |
+
|
| 244 |
+
selected: boxAttrs.selected,
|
| 245 |
+
unselected: boxAttrs.unselected,
|
| 246 |
+
|
| 247 |
+
hoveron: {
|
| 248 |
+
valType: 'flaglist',
|
| 249 |
+
flags: ['violins', 'points', 'kde'],
|
| 250 |
+
dflt: 'violins+points+kde',
|
| 251 |
+
extras: ['all'],
|
| 252 |
+
editType: 'style',
|
| 253 |
+
description: [
|
| 254 |
+
'Do the hover effects highlight individual violins',
|
| 255 |
+
'or sample points or the kernel density estimate or any combination of them?'
|
| 256 |
+
].join(' ')
|
| 257 |
+
}
|
| 258 |
+
};
|
node_modules/plotly.js/src/traces/violin/calc.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var Axes = require('../../plots/cartesian/axes');
|
| 5 |
+
var boxCalc = require('../box/calc');
|
| 6 |
+
var helpers = require('./helpers');
|
| 7 |
+
var BADNUM = require('../../constants/numerical').BADNUM;
|
| 8 |
+
|
| 9 |
+
module.exports = function calc(gd, trace) {
|
| 10 |
+
var cd = boxCalc(gd, trace);
|
| 11 |
+
|
| 12 |
+
if(cd[0].t.empty) return cd;
|
| 13 |
+
|
| 14 |
+
var fullLayout = gd._fullLayout;
|
| 15 |
+
var valAxis = Axes.getFromId(
|
| 16 |
+
gd,
|
| 17 |
+
trace[trace.orientation === 'h' ? 'xaxis' : 'yaxis']
|
| 18 |
+
);
|
| 19 |
+
|
| 20 |
+
var spanMin = Infinity;
|
| 21 |
+
var spanMax = -Infinity;
|
| 22 |
+
var maxKDE = 0;
|
| 23 |
+
var maxCount = 0;
|
| 24 |
+
|
| 25 |
+
for(var i = 0; i < cd.length; i++) {
|
| 26 |
+
var cdi = cd[i];
|
| 27 |
+
var vals = cdi.pts.map(helpers.extractVal);
|
| 28 |
+
|
| 29 |
+
var bandwidth = cdi.bandwidth = calcBandwidth(trace, cdi, vals);
|
| 30 |
+
var span = cdi.span = calcSpan(trace, cdi, valAxis, bandwidth);
|
| 31 |
+
|
| 32 |
+
if(cdi.min === cdi.max && bandwidth === 0) {
|
| 33 |
+
// if span is zero and bandwidth is zero, we want a violin with zero width
|
| 34 |
+
span = cdi.span = [cdi.min, cdi.max];
|
| 35 |
+
cdi.density = [{v: 1, t: span[0]}];
|
| 36 |
+
cdi.bandwidth = bandwidth;
|
| 37 |
+
maxKDE = Math.max(maxKDE, 1);
|
| 38 |
+
} else {
|
| 39 |
+
// step that well covers the bandwidth and is multiple of span distance
|
| 40 |
+
var dist = span[1] - span[0];
|
| 41 |
+
var n = Math.ceil(dist / (bandwidth / 3));
|
| 42 |
+
var step = dist / n;
|
| 43 |
+
|
| 44 |
+
if(!isFinite(step) || !isFinite(n)) {
|
| 45 |
+
Lib.error('Something went wrong with computing the violin span');
|
| 46 |
+
cd[0].t.empty = true;
|
| 47 |
+
return cd;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
var kde = helpers.makeKDE(cdi, trace, vals);
|
| 51 |
+
cdi.density = new Array(n);
|
| 52 |
+
|
| 53 |
+
for(var k = 0, t = span[0]; t < (span[1] + step / 2); k++, t += step) {
|
| 54 |
+
var v = kde(t);
|
| 55 |
+
cdi.density[k] = {v: v, t: t};
|
| 56 |
+
maxKDE = Math.max(maxKDE, v);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
maxCount = Math.max(maxCount, vals.length);
|
| 61 |
+
spanMin = Math.min(spanMin, span[0]);
|
| 62 |
+
spanMax = Math.max(spanMax, span[1]);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
var extremes = Axes.findExtremes(valAxis, [spanMin, spanMax], {padded: true});
|
| 66 |
+
trace._extremes[valAxis._id] = extremes;
|
| 67 |
+
|
| 68 |
+
if(trace.width) {
|
| 69 |
+
cd[0].t.maxKDE = maxKDE;
|
| 70 |
+
} else {
|
| 71 |
+
var violinScaleGroupStats = fullLayout._violinScaleGroupStats;
|
| 72 |
+
var scaleGroup = trace.scalegroup;
|
| 73 |
+
var groupStats = violinScaleGroupStats[scaleGroup];
|
| 74 |
+
|
| 75 |
+
if(groupStats) {
|
| 76 |
+
groupStats.maxKDE = Math.max(groupStats.maxKDE, maxKDE);
|
| 77 |
+
groupStats.maxCount = Math.max(groupStats.maxCount, maxCount);
|
| 78 |
+
} else {
|
| 79 |
+
violinScaleGroupStats[scaleGroup] = {
|
| 80 |
+
maxKDE: maxKDE,
|
| 81 |
+
maxCount: maxCount
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
cd[0].t.labels.kde = Lib._(gd, 'kde:');
|
| 87 |
+
|
| 88 |
+
return cd;
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
// Default to Silveman's rule of thumb
|
| 92 |
+
// - https://stats.stackexchange.com/a/6671
|
| 93 |
+
// - https://en.wikipedia.org/wiki/Kernel_density_estimation#A_rule-of-thumb_bandwidth_estimator
|
| 94 |
+
// - https://github.com/statsmodels/statsmodels/blob/master/statsmodels/nonparametric/bandwidths.py
|
| 95 |
+
function silvermanRule(len, ssd, iqr) {
|
| 96 |
+
var a = Math.min(ssd, iqr / 1.349);
|
| 97 |
+
return 1.059 * a * Math.pow(len, -0.2);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
function calcBandwidth(trace, cdi, vals) {
|
| 101 |
+
var span = cdi.max - cdi.min;
|
| 102 |
+
|
| 103 |
+
// If span is zero
|
| 104 |
+
if(!span) {
|
| 105 |
+
if(trace.bandwidth) {
|
| 106 |
+
return trace.bandwidth;
|
| 107 |
+
} else {
|
| 108 |
+
// if span is zero and no bandwidth is specified
|
| 109 |
+
// it returns zero bandwidth which is a special case
|
| 110 |
+
return 0;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// Limit how small the bandwidth can be.
|
| 115 |
+
//
|
| 116 |
+
// Silverman's rule of thumb can be "very" small
|
| 117 |
+
// when IQR does a poor job at describing the spread
|
| 118 |
+
// of the distribution.
|
| 119 |
+
// We also want to limit custom bandwidths
|
| 120 |
+
// to not blow up kde computations.
|
| 121 |
+
|
| 122 |
+
if(trace.bandwidth) {
|
| 123 |
+
return Math.max(trace.bandwidth, span / 1e4);
|
| 124 |
+
} else {
|
| 125 |
+
var len = vals.length;
|
| 126 |
+
var ssd = Lib.stdev(vals, len - 1, cdi.mean);
|
| 127 |
+
return Math.max(
|
| 128 |
+
silvermanRule(len, ssd, cdi.q3 - cdi.q1),
|
| 129 |
+
span / 100
|
| 130 |
+
);
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function calcSpan(trace, cdi, valAxis, bandwidth) {
|
| 135 |
+
var spanmode = trace.spanmode;
|
| 136 |
+
var spanIn = trace.span || [];
|
| 137 |
+
var spanTight = [cdi.min, cdi.max];
|
| 138 |
+
var spanLoose = [cdi.min - 2 * bandwidth, cdi.max + 2 * bandwidth];
|
| 139 |
+
var spanOut;
|
| 140 |
+
|
| 141 |
+
function calcSpanItem(index) {
|
| 142 |
+
var s = spanIn[index];
|
| 143 |
+
var sc = valAxis.type === 'multicategory' ?
|
| 144 |
+
valAxis.r2c(s) :
|
| 145 |
+
valAxis.d2c(s, 0, trace[cdi.valLetter + 'calendar']);
|
| 146 |
+
return sc === BADNUM ? spanLoose[index] : sc;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
if(spanmode === 'soft') {
|
| 150 |
+
spanOut = spanLoose;
|
| 151 |
+
} else if(spanmode === 'hard') {
|
| 152 |
+
spanOut = spanTight;
|
| 153 |
+
} else {
|
| 154 |
+
spanOut = [calcSpanItem(0), calcSpanItem(1)];
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
// to reuse the equal-range-item block
|
| 158 |
+
var dummyAx = {
|
| 159 |
+
type: 'linear',
|
| 160 |
+
range: spanOut
|
| 161 |
+
};
|
| 162 |
+
Axes.setConvert(dummyAx);
|
| 163 |
+
dummyAx.cleanRange();
|
| 164 |
+
|
| 165 |
+
return spanOut;
|
| 166 |
+
}
|
node_modules/plotly.js/src/traces/violin/cross_trace_calc.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var setPositionOffset = require('../box/cross_trace_calc').setPositionOffset;
|
| 4 |
+
var orientations = ['v', 'h'];
|
| 5 |
+
|
| 6 |
+
module.exports = function crossTraceCalc(gd, plotinfo) {
|
| 7 |
+
var calcdata = gd.calcdata;
|
| 8 |
+
var xa = plotinfo.xaxis;
|
| 9 |
+
var ya = plotinfo.yaxis;
|
| 10 |
+
|
| 11 |
+
for(var i = 0; i < orientations.length; i++) {
|
| 12 |
+
var orientation = orientations[i];
|
| 13 |
+
var posAxis = orientation === 'h' ? ya : xa;
|
| 14 |
+
var violinList = [];
|
| 15 |
+
|
| 16 |
+
for(var j = 0; j < calcdata.length; j++) {
|
| 17 |
+
var cd = calcdata[j];
|
| 18 |
+
var t = cd[0].t;
|
| 19 |
+
var trace = cd[0].trace;
|
| 20 |
+
|
| 21 |
+
if(trace.visible === true && trace.type === 'violin' &&
|
| 22 |
+
!t.empty &&
|
| 23 |
+
trace.orientation === orientation &&
|
| 24 |
+
trace.xaxis === xa._id &&
|
| 25 |
+
trace.yaxis === ya._id
|
| 26 |
+
) {
|
| 27 |
+
violinList.push(j);
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
setPositionOffset('violin', gd, violinList, posAxis);
|
| 32 |
+
}
|
| 33 |
+
};
|
node_modules/plotly.js/src/traces/violin/defaults.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var Color = require('../../components/color');
|
| 5 |
+
|
| 6 |
+
var boxDefaults = require('../box/defaults');
|
| 7 |
+
var attributes = require('./attributes');
|
| 8 |
+
|
| 9 |
+
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
|
| 10 |
+
function coerce(attr, dflt) {
|
| 11 |
+
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
|
| 12 |
+
}
|
| 13 |
+
function coerce2(attr, dflt) {
|
| 14 |
+
return Lib.coerce2(traceIn, traceOut, attributes, attr, dflt);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
boxDefaults.handleSampleDefaults(traceIn, traceOut, coerce, layout);
|
| 18 |
+
if(traceOut.visible === false) return;
|
| 19 |
+
|
| 20 |
+
coerce('bandwidth');
|
| 21 |
+
coerce('side');
|
| 22 |
+
|
| 23 |
+
var width = coerce('width');
|
| 24 |
+
if(!width) {
|
| 25 |
+
coerce('scalegroup', traceOut.name);
|
| 26 |
+
coerce('scalemode');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
var span = coerce('span');
|
| 30 |
+
var spanmodeDflt;
|
| 31 |
+
if(Array.isArray(span)) spanmodeDflt = 'manual';
|
| 32 |
+
coerce('spanmode', spanmodeDflt);
|
| 33 |
+
|
| 34 |
+
var lineColor = coerce('line.color', (traceIn.marker || {}).color || defaultColor);
|
| 35 |
+
var lineWidth = coerce('line.width');
|
| 36 |
+
var fillColor = coerce('fillcolor', Color.addOpacity(traceOut.line.color, 0.5));
|
| 37 |
+
|
| 38 |
+
boxDefaults.handlePointsDefaults(traceIn, traceOut, coerce, {prefix: ''});
|
| 39 |
+
|
| 40 |
+
var boxWidth = coerce2('box.width');
|
| 41 |
+
var boxFillColor = coerce2('box.fillcolor', fillColor);
|
| 42 |
+
var boxLineColor = coerce2('box.line.color', lineColor);
|
| 43 |
+
var boxLineWidth = coerce2('box.line.width', lineWidth);
|
| 44 |
+
var boxVisible = coerce('box.visible', Boolean(boxWidth || boxFillColor || boxLineColor || boxLineWidth));
|
| 45 |
+
if(!boxVisible) traceOut.box = {visible: false};
|
| 46 |
+
|
| 47 |
+
var meanLineColor = coerce2('meanline.color', lineColor);
|
| 48 |
+
var meanLineWidth = coerce2('meanline.width', lineWidth);
|
| 49 |
+
var meanLineVisible = coerce('meanline.visible', Boolean(meanLineColor || meanLineWidth));
|
| 50 |
+
if(!meanLineVisible) traceOut.meanline = {visible: false};
|
| 51 |
+
|
| 52 |
+
coerce('quartilemethod');
|
| 53 |
+
};
|
node_modules/plotly.js/src/traces/violin/helpers.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
|
| 5 |
+
// Maybe add kernels more down the road,
|
| 6 |
+
// but note that the default `spanmode: 'soft'` bounds might have
|
| 7 |
+
// to become kernel-dependent
|
| 8 |
+
var kernels = {
|
| 9 |
+
gaussian: function(v) {
|
| 10 |
+
return (1 / Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * v * v);
|
| 11 |
+
}
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
exports.makeKDE = function(calcItem, trace, vals) {
|
| 15 |
+
var len = vals.length;
|
| 16 |
+
var kernel = kernels.gaussian;
|
| 17 |
+
var bandwidth = calcItem.bandwidth;
|
| 18 |
+
var factor = 1 / (len * bandwidth);
|
| 19 |
+
|
| 20 |
+
// don't use Lib.aggNums to skip isNumeric checks
|
| 21 |
+
return function(x) {
|
| 22 |
+
var sum = 0;
|
| 23 |
+
for(var i = 0; i < len; i++) {
|
| 24 |
+
sum += kernel((x - vals[i]) / bandwidth);
|
| 25 |
+
}
|
| 26 |
+
return factor * sum;
|
| 27 |
+
};
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
exports.getPositionOnKdePath = function(calcItem, trace, valuePx) {
|
| 31 |
+
var posLetter, valLetter;
|
| 32 |
+
|
| 33 |
+
if(trace.orientation === 'h') {
|
| 34 |
+
posLetter = 'y';
|
| 35 |
+
valLetter = 'x';
|
| 36 |
+
} else {
|
| 37 |
+
posLetter = 'x';
|
| 38 |
+
valLetter = 'y';
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
var pointOnPath = Lib.findPointOnPath(
|
| 42 |
+
calcItem.path,
|
| 43 |
+
valuePx,
|
| 44 |
+
valLetter,
|
| 45 |
+
{pathLength: calcItem.pathLength}
|
| 46 |
+
);
|
| 47 |
+
|
| 48 |
+
var posCenterPx = calcItem.posCenterPx;
|
| 49 |
+
var posOnPath0 = pointOnPath[posLetter];
|
| 50 |
+
var posOnPath1 = trace.side === 'both' ?
|
| 51 |
+
2 * posCenterPx - posOnPath0 :
|
| 52 |
+
posCenterPx;
|
| 53 |
+
|
| 54 |
+
return [posOnPath0, posOnPath1];
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
exports.getKdeValue = function(calcItem, trace, valueDist) {
|
| 58 |
+
var vals = calcItem.pts.map(exports.extractVal);
|
| 59 |
+
var kde = exports.makeKDE(calcItem, trace, vals);
|
| 60 |
+
return kde(valueDist) / calcItem.posDensityScale;
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
exports.extractVal = function(o) { return o.v; };
|
node_modules/plotly.js/src/traces/violin/hover.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Color = require('../../components/color');
|
| 4 |
+
var Lib = require('../../lib');
|
| 5 |
+
var Axes = require('../../plots/cartesian/axes');
|
| 6 |
+
var boxHoverPoints = require('../box/hover');
|
| 7 |
+
var helpers = require('./helpers');
|
| 8 |
+
|
| 9 |
+
module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) {
|
| 10 |
+
if(!opts) opts = {};
|
| 11 |
+
var hoverLayer = opts.hoverLayer;
|
| 12 |
+
|
| 13 |
+
var cd = pointData.cd;
|
| 14 |
+
var trace = cd[0].trace;
|
| 15 |
+
var hoveron = trace.hoveron;
|
| 16 |
+
var hasHoveronViolins = hoveron.indexOf('violins') !== -1;
|
| 17 |
+
var hasHoveronKDE = hoveron.indexOf('kde') !== -1;
|
| 18 |
+
var closeData = [];
|
| 19 |
+
var closePtData;
|
| 20 |
+
var violinLineAttrs;
|
| 21 |
+
|
| 22 |
+
if(hasHoveronViolins || hasHoveronKDE) {
|
| 23 |
+
var closeBoxData = boxHoverPoints.hoverOnBoxes(pointData, xval, yval, hovermode);
|
| 24 |
+
|
| 25 |
+
if(hasHoveronKDE && closeBoxData.length > 0) {
|
| 26 |
+
var xa = pointData.xa;
|
| 27 |
+
var ya = pointData.ya;
|
| 28 |
+
var pLetter, vLetter, pAxis, vAxis, vVal;
|
| 29 |
+
|
| 30 |
+
if(trace.orientation === 'h') {
|
| 31 |
+
vVal = xval;
|
| 32 |
+
pLetter = 'y';
|
| 33 |
+
pAxis = ya;
|
| 34 |
+
vLetter = 'x';
|
| 35 |
+
vAxis = xa;
|
| 36 |
+
} else {
|
| 37 |
+
vVal = yval;
|
| 38 |
+
pLetter = 'x';
|
| 39 |
+
pAxis = xa;
|
| 40 |
+
vLetter = 'y';
|
| 41 |
+
vAxis = ya;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
var di = cd[pointData.index];
|
| 45 |
+
|
| 46 |
+
if(vVal >= di.span[0] && vVal <= di.span[1]) {
|
| 47 |
+
var kdePointData = Lib.extendFlat({}, pointData);
|
| 48 |
+
var vValPx = vAxis.c2p(vVal, true);
|
| 49 |
+
var kdeVal = helpers.getKdeValue(di, trace, vVal);
|
| 50 |
+
var pOnPath = helpers.getPositionOnKdePath(di, trace, vValPx);
|
| 51 |
+
var paOffset = pAxis._offset;
|
| 52 |
+
var paLength = pAxis._length;
|
| 53 |
+
|
| 54 |
+
kdePointData[pLetter + '0'] = pOnPath[0];
|
| 55 |
+
kdePointData[pLetter + '1'] = pOnPath[1];
|
| 56 |
+
kdePointData[vLetter + '0'] = kdePointData[vLetter + '1'] = vValPx;
|
| 57 |
+
kdePointData[vLetter + 'Label'] = vLetter + ': ' + Axes.hoverLabelText(vAxis, vVal, trace[vLetter + 'hoverformat']) + ', ' + cd[0].t.labels.kde + ' ' + kdeVal.toFixed(3);
|
| 58 |
+
|
| 59 |
+
// move the spike to the KDE point
|
| 60 |
+
var medId = 0;
|
| 61 |
+
for(var k = 0; k < closeBoxData.length; k++) {
|
| 62 |
+
if(closeBoxData[k].attr === 'med') {
|
| 63 |
+
medId = k;
|
| 64 |
+
break;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
kdePointData.spikeDistance = closeBoxData[medId].spikeDistance;
|
| 69 |
+
var spikePosAttr = pLetter + 'Spike';
|
| 70 |
+
kdePointData[spikePosAttr] = closeBoxData[medId][spikePosAttr];
|
| 71 |
+
closeBoxData[medId].spikeDistance = undefined;
|
| 72 |
+
closeBoxData[medId][spikePosAttr] = undefined;
|
| 73 |
+
|
| 74 |
+
// no hovertemplate support yet
|
| 75 |
+
kdePointData.hovertemplate = false;
|
| 76 |
+
|
| 77 |
+
closeData.push(kdePointData);
|
| 78 |
+
|
| 79 |
+
violinLineAttrs = {};
|
| 80 |
+
violinLineAttrs[pLetter + '1'] = Lib.constrain(paOffset + pOnPath[0], paOffset, paOffset + paLength);
|
| 81 |
+
violinLineAttrs[pLetter + '2'] = Lib.constrain(paOffset + pOnPath[1], paOffset, paOffset + paLength);
|
| 82 |
+
violinLineAttrs[vLetter + '1'] = violinLineAttrs[vLetter + '2'] = vAxis._offset + vValPx;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if(hasHoveronViolins) {
|
| 87 |
+
closeData = closeData.concat(closeBoxData);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if(hoveron.indexOf('points') !== -1) {
|
| 92 |
+
closePtData = boxHoverPoints.hoverOnPoints(pointData, xval, yval);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// update violin line (if any)
|
| 96 |
+
var violinLine = hoverLayer.selectAll('.violinline-' + trace.uid)
|
| 97 |
+
.data(violinLineAttrs ? [0] : []);
|
| 98 |
+
violinLine.enter().append('line')
|
| 99 |
+
.classed('violinline-' + trace.uid, true)
|
| 100 |
+
.attr('stroke-width', 1.5);
|
| 101 |
+
violinLine.exit().remove();
|
| 102 |
+
violinLine.attr(violinLineAttrs).call(Color.stroke, pointData.color);
|
| 103 |
+
|
| 104 |
+
// same combine logic as box hoverPoints
|
| 105 |
+
if(hovermode === 'closest') {
|
| 106 |
+
if(closePtData) return [closePtData];
|
| 107 |
+
return closeData;
|
| 108 |
+
}
|
| 109 |
+
if(closePtData) {
|
| 110 |
+
closeData.push(closePtData);
|
| 111 |
+
return closeData;
|
| 112 |
+
}
|
| 113 |
+
return closeData;
|
| 114 |
+
};
|
node_modules/plotly.js/src/traces/violin/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
attributes: require('./attributes'),
|
| 5 |
+
layoutAttributes: require('./layout_attributes'),
|
| 6 |
+
supplyDefaults: require('./defaults'),
|
| 7 |
+
crossTraceDefaults: require('../box/defaults').crossTraceDefaults,
|
| 8 |
+
supplyLayoutDefaults: require('./layout_defaults'),
|
| 9 |
+
calc: require('./calc'),
|
| 10 |
+
crossTraceCalc: require('./cross_trace_calc'),
|
| 11 |
+
plot: require('./plot'),
|
| 12 |
+
style: require('./style'),
|
| 13 |
+
styleOnSelect: require('../scatter/style').styleOnSelect,
|
| 14 |
+
hoverPoints: require('./hover'),
|
| 15 |
+
selectPoints: require('../box/select'),
|
| 16 |
+
|
| 17 |
+
moduleType: 'trace',
|
| 18 |
+
name: 'violin',
|
| 19 |
+
basePlotModule: require('../../plots/cartesian'),
|
| 20 |
+
categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'violinLayout', 'zoomScale'],
|
| 21 |
+
meta: {
|
| 22 |
+
description: [
|
| 23 |
+
'In vertical (horizontal) violin plots,',
|
| 24 |
+
'statistics are computed using `y` (`x`) values.',
|
| 25 |
+
'By supplying an `x` (`y`) array, one violin per distinct x (y) value',
|
| 26 |
+
'is drawn',
|
| 27 |
+
'If no `x` (`y`) {array} is provided, a single violin is drawn.',
|
| 28 |
+
'That violin position is then positioned with',
|
| 29 |
+
'with `name` or with `x0` (`y0`) if provided.'
|
| 30 |
+
].join(' ')
|
| 31 |
+
}
|
| 32 |
+
};
|
node_modules/plotly.js/src/traces/violin/layout_attributes.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var boxLayoutAttrs = require('../box/layout_attributes');
|
| 4 |
+
var extendFlat = require('../../lib').extendFlat;
|
| 5 |
+
|
| 6 |
+
module.exports = {
|
| 7 |
+
violinmode: extendFlat({}, boxLayoutAttrs.boxmode, {
|
| 8 |
+
description: [
|
| 9 |
+
'Determines how violins at the same location coordinate',
|
| 10 |
+
'are displayed on the graph.',
|
| 11 |
+
'If *group*, the violins are plotted next to one another',
|
| 12 |
+
'centered around the shared location.',
|
| 13 |
+
'If *overlay*, the violins are plotted over one another,',
|
| 14 |
+
'you might need to set *opacity* to see them multiple violins.',
|
| 15 |
+
'Has no effect on traces that have *width* set.'
|
| 16 |
+
].join(' ')
|
| 17 |
+
}),
|
| 18 |
+
violingap: extendFlat({}, boxLayoutAttrs.boxgap, {
|
| 19 |
+
description: [
|
| 20 |
+
'Sets the gap (in plot fraction) between violins of',
|
| 21 |
+
'adjacent location coordinates.',
|
| 22 |
+
'Has no effect on traces that have *width* set.'
|
| 23 |
+
].join(' ')
|
| 24 |
+
}),
|
| 25 |
+
violingroupgap: extendFlat({}, boxLayoutAttrs.boxgroupgap, {
|
| 26 |
+
description: [
|
| 27 |
+
'Sets the gap (in plot fraction) between violins of',
|
| 28 |
+
'the same location coordinate.',
|
| 29 |
+
'Has no effect on traces that have *width* set.'
|
| 30 |
+
].join(' ')
|
| 31 |
+
})
|
| 32 |
+
};
|
node_modules/plotly.js/src/traces/violin/layout_defaults.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var layoutAttributes = require('./layout_attributes');
|
| 5 |
+
var boxLayoutDefaults = require('../box/layout_defaults');
|
| 6 |
+
|
| 7 |
+
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
|
| 8 |
+
function coerce(attr, dflt) {
|
| 9 |
+
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
|
| 10 |
+
}
|
| 11 |
+
boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin');
|
| 12 |
+
};
|
node_modules/plotly.js/src/traces/violin/plot.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Lib = require('../../lib');
|
| 5 |
+
var Drawing = require('../../components/drawing');
|
| 6 |
+
|
| 7 |
+
var boxPlot = require('../box/plot');
|
| 8 |
+
var linePoints = require('../scatter/line_points');
|
| 9 |
+
var helpers = require('./helpers');
|
| 10 |
+
|
| 11 |
+
module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
|
| 12 |
+
var isStatic = gd._context.staticPlot;
|
| 13 |
+
var fullLayout = gd._fullLayout;
|
| 14 |
+
var xa = plotinfo.xaxis;
|
| 15 |
+
var ya = plotinfo.yaxis;
|
| 16 |
+
|
| 17 |
+
function makePath(pts, trace) {
|
| 18 |
+
var segments = linePoints(pts, {
|
| 19 |
+
xaxis: xa,
|
| 20 |
+
yaxis: ya,
|
| 21 |
+
trace: trace,
|
| 22 |
+
connectGaps: true,
|
| 23 |
+
baseTolerance: 0.75,
|
| 24 |
+
shape: 'spline',
|
| 25 |
+
simplify: true,
|
| 26 |
+
linearized: true
|
| 27 |
+
});
|
| 28 |
+
return Drawing.smoothopen(segments[0], 1);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
Lib.makeTraceGroups(violinLayer, cdViolins, 'trace violins').each(function(cd) {
|
| 32 |
+
var plotGroup = d3.select(this);
|
| 33 |
+
var cd0 = cd[0];
|
| 34 |
+
var t = cd0.t;
|
| 35 |
+
var trace = cd0.trace;
|
| 36 |
+
|
| 37 |
+
if(trace.visible !== true || t.empty) {
|
| 38 |
+
plotGroup.remove();
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
var bPos = t.bPos;
|
| 43 |
+
var bdPos = t.bdPos;
|
| 44 |
+
var valAxis = plotinfo[t.valLetter + 'axis'];
|
| 45 |
+
var posAxis = plotinfo[t.posLetter + 'axis'];
|
| 46 |
+
var hasBothSides = trace.side === 'both';
|
| 47 |
+
var hasPositiveSide = hasBothSides || trace.side === 'positive';
|
| 48 |
+
var hasNegativeSide = hasBothSides || trace.side === 'negative';
|
| 49 |
+
|
| 50 |
+
var violins = plotGroup.selectAll('path.violin').data(Lib.identity);
|
| 51 |
+
|
| 52 |
+
violins.enter().append('path')
|
| 53 |
+
.style('vector-effect', isStatic ? 'none' : 'non-scaling-stroke')
|
| 54 |
+
.attr('class', 'violin');
|
| 55 |
+
|
| 56 |
+
violins.exit().remove();
|
| 57 |
+
|
| 58 |
+
violins.each(function(d) {
|
| 59 |
+
var pathSel = d3.select(this);
|
| 60 |
+
var density = d.density;
|
| 61 |
+
var len = density.length;
|
| 62 |
+
var posCenter = posAxis.c2l(d.pos + bPos, true);
|
| 63 |
+
var posCenterPx = posAxis.l2p(posCenter);
|
| 64 |
+
|
| 65 |
+
var scale;
|
| 66 |
+
if(trace.width) {
|
| 67 |
+
scale = t.maxKDE / bdPos;
|
| 68 |
+
} else {
|
| 69 |
+
var groupStats = fullLayout._violinScaleGroupStats[trace.scalegroup];
|
| 70 |
+
scale = trace.scalemode === 'count' ?
|
| 71 |
+
(groupStats.maxKDE / bdPos) * (groupStats.maxCount / d.pts.length) :
|
| 72 |
+
groupStats.maxKDE / bdPos;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
var pathPos, pathNeg, path;
|
| 76 |
+
var i, k, pts, pt;
|
| 77 |
+
|
| 78 |
+
if(hasPositiveSide) {
|
| 79 |
+
pts = new Array(len);
|
| 80 |
+
for(i = 0; i < len; i++) {
|
| 81 |
+
pt = pts[i] = {};
|
| 82 |
+
pt[t.posLetter] = posCenter + (density[i].v / scale);
|
| 83 |
+
pt[t.valLetter] = valAxis.c2l(density[i].t, true);
|
| 84 |
+
}
|
| 85 |
+
pathPos = makePath(pts, trace);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
if(hasNegativeSide) {
|
| 89 |
+
pts = new Array(len);
|
| 90 |
+
for(k = 0, i = len - 1; k < len; k++, i--) {
|
| 91 |
+
pt = pts[k] = {};
|
| 92 |
+
pt[t.posLetter] = posCenter - (density[i].v / scale);
|
| 93 |
+
pt[t.valLetter] = valAxis.c2l(density[i].t, true);
|
| 94 |
+
}
|
| 95 |
+
pathNeg = makePath(pts, trace);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if(hasBothSides) {
|
| 99 |
+
path = pathPos + 'L' + pathNeg.substr(1) + 'Z';
|
| 100 |
+
} else {
|
| 101 |
+
var startPt = [posCenterPx, valAxis.c2p(density[0].t)];
|
| 102 |
+
var endPt = [posCenterPx, valAxis.c2p(density[len - 1].t)];
|
| 103 |
+
|
| 104 |
+
if(trace.orientation === 'h') {
|
| 105 |
+
startPt.reverse();
|
| 106 |
+
endPt.reverse();
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
if(hasPositiveSide) {
|
| 110 |
+
path = 'M' + startPt + 'L' + pathPos.substr(1) + 'L' + endPt;
|
| 111 |
+
} else {
|
| 112 |
+
path = 'M' + endPt + 'L' + pathNeg.substr(1) + 'L' + startPt;
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
pathSel.attr('d', path);
|
| 116 |
+
|
| 117 |
+
// save a few things used in getPositionOnKdePath, getKdeValue
|
| 118 |
+
// on hover and for meanline draw block below
|
| 119 |
+
d.posCenterPx = posCenterPx;
|
| 120 |
+
d.posDensityScale = scale * bdPos;
|
| 121 |
+
d.path = pathSel.node();
|
| 122 |
+
d.pathLength = d.path.getTotalLength() / (hasBothSides ? 2 : 1);
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
var boxAttrs = trace.box;
|
| 126 |
+
var boxWidth = boxAttrs.width;
|
| 127 |
+
var boxLineWidth = (boxAttrs.line || {}).width;
|
| 128 |
+
var bdPosScaled;
|
| 129 |
+
var bPosPxOffset;
|
| 130 |
+
|
| 131 |
+
if(hasBothSides) {
|
| 132 |
+
bdPosScaled = bdPos * boxWidth;
|
| 133 |
+
bPosPxOffset = 0;
|
| 134 |
+
} else if(hasPositiveSide) {
|
| 135 |
+
bdPosScaled = [0, bdPos * boxWidth / 2];
|
| 136 |
+
bPosPxOffset = boxLineWidth * {x: 1, y: -1}[t.posLetter];
|
| 137 |
+
} else {
|
| 138 |
+
bdPosScaled = [bdPos * boxWidth / 2, 0];
|
| 139 |
+
bPosPxOffset = boxLineWidth * {x: -1, y: 1}[t.posLetter];
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// inner box
|
| 143 |
+
boxPlot.plotBoxAndWhiskers(plotGroup, {pos: posAxis, val: valAxis}, trace, {
|
| 144 |
+
bPos: bPos,
|
| 145 |
+
bdPos: bdPosScaled,
|
| 146 |
+
bPosPxOffset: bPosPxOffset
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
// meanline insider box
|
| 150 |
+
boxPlot.plotBoxMean(plotGroup, {pos: posAxis, val: valAxis}, trace, {
|
| 151 |
+
bPos: bPos,
|
| 152 |
+
bdPos: bdPosScaled,
|
| 153 |
+
bPosPxOffset: bPosPxOffset
|
| 154 |
+
});
|
| 155 |
+
|
| 156 |
+
var fn;
|
| 157 |
+
if(!trace.box.visible && trace.meanline.visible) {
|
| 158 |
+
fn = Lib.identity;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
// N.B. use different class name than boxPlot.plotBoxMean,
|
| 162 |
+
// to avoid selectAll conflict
|
| 163 |
+
var meanPaths = plotGroup.selectAll('path.meanline').data(fn || []);
|
| 164 |
+
meanPaths.enter().append('path')
|
| 165 |
+
.attr('class', 'meanline')
|
| 166 |
+
.style('fill', 'none')
|
| 167 |
+
.style('vector-effect', isStatic ? 'none' : 'non-scaling-stroke');
|
| 168 |
+
meanPaths.exit().remove();
|
| 169 |
+
meanPaths.each(function(d) {
|
| 170 |
+
var v = valAxis.c2p(d.mean, true);
|
| 171 |
+
var p = helpers.getPositionOnKdePath(d, trace, v);
|
| 172 |
+
|
| 173 |
+
d3.select(this).attr('d',
|
| 174 |
+
trace.orientation === 'h' ?
|
| 175 |
+
'M' + v + ',' + p[0] + 'V' + p[1] :
|
| 176 |
+
'M' + p[0] + ',' + v + 'H' + p[1]
|
| 177 |
+
);
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
boxPlot.plotPoints(plotGroup, {x: xa, y: ya}, trace, t);
|
| 181 |
+
});
|
| 182 |
+
};
|
node_modules/plotly.js/src/traces/violin/style.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Color = require('../../components/color');
|
| 5 |
+
var stylePoints = require('../scatter/style').stylePoints;
|
| 6 |
+
|
| 7 |
+
module.exports = function style(gd) {
|
| 8 |
+
var s = d3.select(gd).selectAll('g.trace.violins');
|
| 9 |
+
|
| 10 |
+
s.style('opacity', function(d) { return d[0].trace.opacity; });
|
| 11 |
+
|
| 12 |
+
s.each(function(d) {
|
| 13 |
+
var trace = d[0].trace;
|
| 14 |
+
var sel = d3.select(this);
|
| 15 |
+
var box = trace.box || {};
|
| 16 |
+
var boxLine = box.line || {};
|
| 17 |
+
var meanline = trace.meanline || {};
|
| 18 |
+
var meanLineWidth = meanline.width;
|
| 19 |
+
|
| 20 |
+
sel.selectAll('path.violin')
|
| 21 |
+
.style('stroke-width', trace.line.width + 'px')
|
| 22 |
+
.call(Color.stroke, trace.line.color)
|
| 23 |
+
.call(Color.fill, trace.fillcolor);
|
| 24 |
+
|
| 25 |
+
sel.selectAll('path.box')
|
| 26 |
+
.style('stroke-width', boxLine.width + 'px')
|
| 27 |
+
.call(Color.stroke, boxLine.color)
|
| 28 |
+
.call(Color.fill, box.fillcolor);
|
| 29 |
+
|
| 30 |
+
var meanLineStyle = {
|
| 31 |
+
'stroke-width': meanLineWidth + 'px',
|
| 32 |
+
'stroke-dasharray': (2 * meanLineWidth) + 'px,' + meanLineWidth + 'px'
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
sel.selectAll('path.mean')
|
| 36 |
+
.style(meanLineStyle)
|
| 37 |
+
.call(Color.stroke, meanline.color);
|
| 38 |
+
|
| 39 |
+
sel.selectAll('path.meanline')
|
| 40 |
+
.style(meanLineStyle)
|
| 41 |
+
.call(Color.stroke, meanline.color);
|
| 42 |
+
|
| 43 |
+
stylePoints(sel, trace, gd);
|
| 44 |
+
});
|
| 45 |
+
};
|
node_modules/plotly.js/src/traces/volume/attributes.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var colorScaleAttrs = require('../../components/colorscale/attributes');
|
| 4 |
+
var isosurfaceAttrs = require('../isosurface/attributes');
|
| 5 |
+
var surfaceAttrs = require('../surface/attributes');
|
| 6 |
+
var baseAttrs = require('../../plots/attributes');
|
| 7 |
+
|
| 8 |
+
var extendFlat = require('../../lib/extend').extendFlat;
|
| 9 |
+
var overrideAll = require('../../plot_api/edit_types').overrideAll;
|
| 10 |
+
|
| 11 |
+
var attrs = module.exports = overrideAll(extendFlat({
|
| 12 |
+
x: isosurfaceAttrs.x,
|
| 13 |
+
y: isosurfaceAttrs.y,
|
| 14 |
+
z: isosurfaceAttrs.z,
|
| 15 |
+
value: isosurfaceAttrs.value,
|
| 16 |
+
isomin: isosurfaceAttrs.isomin,
|
| 17 |
+
isomax: isosurfaceAttrs.isomax,
|
| 18 |
+
surface: isosurfaceAttrs.surface,
|
| 19 |
+
spaceframe: {
|
| 20 |
+
show: {
|
| 21 |
+
valType: 'boolean',
|
| 22 |
+
dflt: false,
|
| 23 |
+
description: [
|
| 24 |
+
'Displays/hides tetrahedron shapes between minimum and',
|
| 25 |
+
'maximum iso-values. Often useful when either caps or',
|
| 26 |
+
'surfaces are disabled or filled with values less than 1.'
|
| 27 |
+
].join(' ')
|
| 28 |
+
},
|
| 29 |
+
fill: {
|
| 30 |
+
valType: 'number',
|
| 31 |
+
min: 0,
|
| 32 |
+
max: 1,
|
| 33 |
+
dflt: 1,
|
| 34 |
+
description: [
|
| 35 |
+
'Sets the fill ratio of the `spaceframe` elements. The default fill value',
|
| 36 |
+
'is 1 meaning that they are entirely shaded. Applying a `fill` ratio less',
|
| 37 |
+
'than one would allow the creation of openings parallel to the edges.'
|
| 38 |
+
].join(' ')
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
|
| 42 |
+
slices: isosurfaceAttrs.slices,
|
| 43 |
+
caps: isosurfaceAttrs.caps,
|
| 44 |
+
text: isosurfaceAttrs.text,
|
| 45 |
+
hovertext: isosurfaceAttrs.hovertext,
|
| 46 |
+
xhoverformat: isosurfaceAttrs.xhoverformat,
|
| 47 |
+
yhoverformat: isosurfaceAttrs.yhoverformat,
|
| 48 |
+
zhoverformat: isosurfaceAttrs.zhoverformat,
|
| 49 |
+
valuehoverformat: isosurfaceAttrs.valuehoverformat,
|
| 50 |
+
hovertemplate: isosurfaceAttrs.hovertemplate
|
| 51 |
+
},
|
| 52 |
+
|
| 53 |
+
colorScaleAttrs('', {
|
| 54 |
+
colorAttr: '`value`',
|
| 55 |
+
showScaleDflt: true,
|
| 56 |
+
editTypeOverride: 'calc'
|
| 57 |
+
}), {
|
| 58 |
+
|
| 59 |
+
colorbar: isosurfaceAttrs.colorbar,
|
| 60 |
+
opacity: isosurfaceAttrs.opacity,
|
| 61 |
+
opacityscale: surfaceAttrs.opacityscale,
|
| 62 |
+
|
| 63 |
+
lightposition: isosurfaceAttrs.lightposition,
|
| 64 |
+
lighting: isosurfaceAttrs.lighting,
|
| 65 |
+
flatshading: isosurfaceAttrs.flatshading,
|
| 66 |
+
contour: isosurfaceAttrs.contour,
|
| 67 |
+
|
| 68 |
+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo),
|
| 69 |
+
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
|
| 70 |
+
}), 'calc', 'nested');
|
| 71 |
+
|
| 72 |
+
attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = 'calc+clearAxisTypes';
|
| 73 |
+
attrs.transforms = undefined;
|
node_modules/plotly.js/src/traces/volume/convert.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var createMesh = require('../../../stackgl_modules').gl_mesh3d;
|
| 4 |
+
|
| 5 |
+
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
|
| 6 |
+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
|
| 7 |
+
var str2RgbaArray = require('../../lib/str2rgbarray');
|
| 8 |
+
var extractOpts = require('../../components/colorscale').extractOpts;
|
| 9 |
+
var zip3 = require('../../plots/gl3d/zip3');
|
| 10 |
+
|
| 11 |
+
var findNearestOnAxis = require('../isosurface/convert').findNearestOnAxis;
|
| 12 |
+
var generateIsoMeshes = require('../isosurface/convert').generateIsoMeshes;
|
| 13 |
+
|
| 14 |
+
function VolumeTrace(scene, mesh, uid) {
|
| 15 |
+
this.scene = scene;
|
| 16 |
+
this.uid = uid;
|
| 17 |
+
this.mesh = mesh;
|
| 18 |
+
this.name = '';
|
| 19 |
+
this.data = null;
|
| 20 |
+
this.showContour = false;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
var proto = VolumeTrace.prototype;
|
| 24 |
+
|
| 25 |
+
proto.handlePick = function(selection) {
|
| 26 |
+
if(selection.object === this.mesh) {
|
| 27 |
+
var rawId = selection.data.index;
|
| 28 |
+
|
| 29 |
+
var x = this.data._meshX[rawId];
|
| 30 |
+
var y = this.data._meshY[rawId];
|
| 31 |
+
var z = this.data._meshZ[rawId];
|
| 32 |
+
|
| 33 |
+
var height = this.data._Ys.length;
|
| 34 |
+
var depth = this.data._Zs.length;
|
| 35 |
+
|
| 36 |
+
var i = findNearestOnAxis(x, this.data._Xs).id;
|
| 37 |
+
var j = findNearestOnAxis(y, this.data._Ys).id;
|
| 38 |
+
var k = findNearestOnAxis(z, this.data._Zs).id;
|
| 39 |
+
|
| 40 |
+
var selectIndex = selection.index = k + depth * j + depth * height * i;
|
| 41 |
+
|
| 42 |
+
selection.traceCoordinate = [
|
| 43 |
+
this.data._meshX[selectIndex],
|
| 44 |
+
this.data._meshY[selectIndex],
|
| 45 |
+
this.data._meshZ[selectIndex],
|
| 46 |
+
this.data._value[selectIndex]
|
| 47 |
+
];
|
| 48 |
+
|
| 49 |
+
var text = this.data.hovertext || this.data.text;
|
| 50 |
+
if(isArrayOrTypedArray(text) && text[selectIndex] !== undefined) {
|
| 51 |
+
selection.textLabel = text[selectIndex];
|
| 52 |
+
} else if(text) {
|
| 53 |
+
selection.textLabel = text;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
return true;
|
| 57 |
+
}
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
proto.update = function(data) {
|
| 61 |
+
var scene = this.scene;
|
| 62 |
+
var layout = scene.fullSceneLayout;
|
| 63 |
+
|
| 64 |
+
this.data = generateIsoMeshes(data);
|
| 65 |
+
|
| 66 |
+
// Unpack position data
|
| 67 |
+
function toDataCoords(axis, coord, scale, calendar) {
|
| 68 |
+
return coord.map(function(x) {
|
| 69 |
+
return axis.d2l(x, 0, calendar) * scale;
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
var positions = zip3(
|
| 74 |
+
toDataCoords(layout.xaxis, data._meshX, scene.dataScale[0], data.xcalendar),
|
| 75 |
+
toDataCoords(layout.yaxis, data._meshY, scene.dataScale[1], data.ycalendar),
|
| 76 |
+
toDataCoords(layout.zaxis, data._meshZ, scene.dataScale[2], data.zcalendar));
|
| 77 |
+
|
| 78 |
+
var cells = zip3(data._meshI, data._meshJ, data._meshK);
|
| 79 |
+
|
| 80 |
+
var config = {
|
| 81 |
+
positions: positions,
|
| 82 |
+
cells: cells,
|
| 83 |
+
lightPosition: [data.lightposition.x, data.lightposition.y, data.lightposition.z],
|
| 84 |
+
ambient: data.lighting.ambient,
|
| 85 |
+
diffuse: data.lighting.diffuse,
|
| 86 |
+
specular: data.lighting.specular,
|
| 87 |
+
roughness: data.lighting.roughness,
|
| 88 |
+
fresnel: data.lighting.fresnel,
|
| 89 |
+
vertexNormalsEpsilon: data.lighting.vertexnormalsepsilon,
|
| 90 |
+
faceNormalsEpsilon: data.lighting.facenormalsepsilon,
|
| 91 |
+
opacity: data.opacity,
|
| 92 |
+
opacityscale: data.opacityscale,
|
| 93 |
+
contourEnable: data.contour.show,
|
| 94 |
+
contourColor: str2RgbaArray(data.contour.color).slice(0, 3),
|
| 95 |
+
contourWidth: data.contour.width,
|
| 96 |
+
useFacetNormals: data.flatshading
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
var cOpts = extractOpts(data);
|
| 100 |
+
config.vertexIntensity = data._meshIntensity;
|
| 101 |
+
config.vertexIntensityBounds = [cOpts.min, cOpts.max];
|
| 102 |
+
config.colormap = parseColorScale(data);
|
| 103 |
+
|
| 104 |
+
// Update mesh
|
| 105 |
+
this.mesh.update(config);
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
proto.dispose = function() {
|
| 109 |
+
this.scene.glplot.remove(this.mesh);
|
| 110 |
+
this.mesh.dispose();
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
function createVolumeTrace(scene, data) {
|
| 114 |
+
var gl = scene.glplot.gl;
|
| 115 |
+
var mesh = createMesh({gl: gl});
|
| 116 |
+
var result = new VolumeTrace(scene, mesh, data.uid);
|
| 117 |
+
|
| 118 |
+
mesh._trace = result;
|
| 119 |
+
result.update(data);
|
| 120 |
+
scene.glplot.add(mesh);
|
| 121 |
+
return result;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
module.exports = createVolumeTrace;
|
node_modules/plotly.js/src/traces/volume/defaults.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var attributes = require('./attributes');
|
| 5 |
+
var supplyIsoDefaults = require('../isosurface/defaults').supplyIsoDefaults;
|
| 6 |
+
var opacityscaleDefaults = require('../surface/defaults').opacityscaleDefaults;
|
| 7 |
+
|
| 8 |
+
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
|
| 9 |
+
function coerce(attr, dflt) {
|
| 10 |
+
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce);
|
| 14 |
+
|
| 15 |
+
opacityscaleDefaults(traceIn, traceOut, layout, coerce);
|
| 16 |
+
};
|
node_modules/plotly.js/src/traces/volume/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
attributes: require('./attributes'),
|
| 5 |
+
supplyDefaults: require('./defaults'),
|
| 6 |
+
calc: require('../isosurface/calc'),
|
| 7 |
+
colorbar: {
|
| 8 |
+
min: 'cmin',
|
| 9 |
+
max: 'cmax'
|
| 10 |
+
},
|
| 11 |
+
plot: require('./convert'),
|
| 12 |
+
|
| 13 |
+
moduleType: 'trace',
|
| 14 |
+
name: 'volume',
|
| 15 |
+
basePlotModule: require('../../plots/gl3d'),
|
| 16 |
+
categories: ['gl3d', 'showLegend'],
|
| 17 |
+
meta: {
|
| 18 |
+
description: [
|
| 19 |
+
'Draws volume trace between iso-min and iso-max values with coordinates given by',
|
| 20 |
+
'four 1-dimensional arrays containing the `value`, `x`, `y` and `z` of every vertex',
|
| 21 |
+
'of a uniform or non-uniform 3-D grid. Horizontal or vertical slices, caps as well as',
|
| 22 |
+
'spaceframe between iso-min and iso-max values could also be drawn using this trace.'
|
| 23 |
+
].join(' ')
|
| 24 |
+
}
|
| 25 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/attributes.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var barAttrs = require('../bar/attributes');
|
| 4 |
+
var lineAttrs = require('../scatter/attributes').line;
|
| 5 |
+
var baseAttrs = require('../../plots/attributes');
|
| 6 |
+
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
|
| 7 |
+
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
|
| 8 |
+
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
|
| 9 |
+
var constants = require('./constants');
|
| 10 |
+
var extendFlat = require('../../lib/extend').extendFlat;
|
| 11 |
+
var Color = require('../../components/color');
|
| 12 |
+
|
| 13 |
+
function directionAttrs(dirTxt) {
|
| 14 |
+
return {
|
| 15 |
+
marker: {
|
| 16 |
+
color: extendFlat({}, barAttrs.marker.color, {
|
| 17 |
+
arrayOk: false,
|
| 18 |
+
editType: 'style',
|
| 19 |
+
description: 'Sets the marker color of all ' + dirTxt + ' values.'
|
| 20 |
+
}),
|
| 21 |
+
line: {
|
| 22 |
+
color: extendFlat({}, barAttrs.marker.line.color, {
|
| 23 |
+
arrayOk: false,
|
| 24 |
+
editType: 'style',
|
| 25 |
+
description: 'Sets the line color of all ' + dirTxt + ' values.'
|
| 26 |
+
}),
|
| 27 |
+
width: extendFlat({}, barAttrs.marker.line.width, {
|
| 28 |
+
arrayOk: false,
|
| 29 |
+
editType: 'style',
|
| 30 |
+
description: 'Sets the line width of all ' + dirTxt + ' values.'
|
| 31 |
+
}),
|
| 32 |
+
editType: 'style',
|
| 33 |
+
},
|
| 34 |
+
editType: 'style'
|
| 35 |
+
},
|
| 36 |
+
editType: 'style'
|
| 37 |
+
};
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
module.exports = {
|
| 41 |
+
measure: {
|
| 42 |
+
valType: 'data_array',
|
| 43 |
+
dflt: [],
|
| 44 |
+
editType: 'calc',
|
| 45 |
+
description: [
|
| 46 |
+
'An array containing types of values.',
|
| 47 |
+
'By default the values are considered as \'relative\'.',
|
| 48 |
+
'However; it is possible to use \'total\' to compute the sums.',
|
| 49 |
+
'Also \'absolute\' could be applied to reset the computed total',
|
| 50 |
+
'or to declare an initial value where needed.'
|
| 51 |
+
].join(' ')
|
| 52 |
+
},
|
| 53 |
+
|
| 54 |
+
base: {
|
| 55 |
+
valType: 'number',
|
| 56 |
+
dflt: null,
|
| 57 |
+
arrayOk: false,
|
| 58 |
+
editType: 'calc',
|
| 59 |
+
description: [
|
| 60 |
+
'Sets where the bar base is drawn (in position axis units).'
|
| 61 |
+
].join(' ')
|
| 62 |
+
},
|
| 63 |
+
|
| 64 |
+
x: barAttrs.x,
|
| 65 |
+
x0: barAttrs.x0,
|
| 66 |
+
dx: barAttrs.dx,
|
| 67 |
+
y: barAttrs.y,
|
| 68 |
+
y0: barAttrs.y0,
|
| 69 |
+
dy: barAttrs.dy,
|
| 70 |
+
|
| 71 |
+
xperiod: barAttrs.xperiod,
|
| 72 |
+
yperiod: barAttrs.yperiod,
|
| 73 |
+
xperiod0: barAttrs.xperiod0,
|
| 74 |
+
yperiod0: barAttrs.yperiod0,
|
| 75 |
+
xperiodalignment: barAttrs.xperiodalignment,
|
| 76 |
+
yperiodalignment: barAttrs.yperiodalignment,
|
| 77 |
+
xhoverformat: axisHoverFormat('x'),
|
| 78 |
+
yhoverformat: axisHoverFormat('y'),
|
| 79 |
+
|
| 80 |
+
hovertext: barAttrs.hovertext,
|
| 81 |
+
hovertemplate: hovertemplateAttrs({}, {
|
| 82 |
+
keys: constants.eventDataKeys
|
| 83 |
+
}),
|
| 84 |
+
|
| 85 |
+
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
|
| 86 |
+
flags: ['name', 'x', 'y', 'text', 'initial', 'delta', 'final']
|
| 87 |
+
}),
|
| 88 |
+
|
| 89 |
+
textinfo: {
|
| 90 |
+
valType: 'flaglist',
|
| 91 |
+
flags: ['label', 'text', 'initial', 'delta', 'final'],
|
| 92 |
+
extras: ['none'],
|
| 93 |
+
editType: 'plot',
|
| 94 |
+
arrayOk: false,
|
| 95 |
+
description: [
|
| 96 |
+
'Determines which trace information appear on the graph.',
|
| 97 |
+
'In the case of having multiple waterfalls, totals',
|
| 98 |
+
'are computed separately (per trace).'
|
| 99 |
+
].join(' ')
|
| 100 |
+
},
|
| 101 |
+
// TODO: incorporate `label` and `value` in the eventData
|
| 102 |
+
texttemplate: texttemplateAttrs({editType: 'plot'}, {
|
| 103 |
+
keys: constants.eventDataKeys.concat(['label'])
|
| 104 |
+
}),
|
| 105 |
+
text: barAttrs.text,
|
| 106 |
+
textposition: barAttrs.textposition,
|
| 107 |
+
insidetextanchor: barAttrs.insidetextanchor,
|
| 108 |
+
textangle: barAttrs.textangle,
|
| 109 |
+
textfont: barAttrs.textfont,
|
| 110 |
+
insidetextfont: barAttrs.insidetextfont,
|
| 111 |
+
outsidetextfont: barAttrs.outsidetextfont,
|
| 112 |
+
constraintext: barAttrs.constraintext,
|
| 113 |
+
|
| 114 |
+
cliponaxis: barAttrs.cliponaxis,
|
| 115 |
+
orientation: barAttrs.orientation,
|
| 116 |
+
|
| 117 |
+
offset: barAttrs.offset,
|
| 118 |
+
width: barAttrs.width,
|
| 119 |
+
|
| 120 |
+
increasing: directionAttrs('increasing'),
|
| 121 |
+
decreasing: directionAttrs('decreasing'),
|
| 122 |
+
totals: directionAttrs('intermediate sums and total'),
|
| 123 |
+
|
| 124 |
+
connector: {
|
| 125 |
+
line: {
|
| 126 |
+
color: extendFlat({}, lineAttrs.color, {dflt: Color.defaultLine}),
|
| 127 |
+
width: extendFlat({}, lineAttrs.width, {
|
| 128 |
+
editType: 'plot', // i.e. to adjust bars is mode: 'between'. See https://github.com/plotly/plotly.js/issues/3787
|
| 129 |
+
}),
|
| 130 |
+
dash: lineAttrs.dash,
|
| 131 |
+
editType: 'plot'
|
| 132 |
+
},
|
| 133 |
+
mode: {
|
| 134 |
+
valType: 'enumerated',
|
| 135 |
+
values: ['spanning', 'between'],
|
| 136 |
+
dflt: 'between',
|
| 137 |
+
editType: 'plot',
|
| 138 |
+
description: [
|
| 139 |
+
'Sets the shape of connector lines.'
|
| 140 |
+
].join(' ')
|
| 141 |
+
},
|
| 142 |
+
visible: {
|
| 143 |
+
valType: 'boolean',
|
| 144 |
+
dflt: true,
|
| 145 |
+
editType: 'plot',
|
| 146 |
+
description: [
|
| 147 |
+
'Determines if connector lines are drawn. '
|
| 148 |
+
].join(' ')
|
| 149 |
+
},
|
| 150 |
+
editType: 'plot'
|
| 151 |
+
},
|
| 152 |
+
|
| 153 |
+
offsetgroup: barAttrs.offsetgroup,
|
| 154 |
+
alignmentgroup: barAttrs.alignmentgroup
|
| 155 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/calc.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Axes = require('../../plots/cartesian/axes');
|
| 4 |
+
var alignPeriod = require('../../plots/cartesian/align_period');
|
| 5 |
+
var mergeArray = require('../../lib').mergeArray;
|
| 6 |
+
var calcSelection = require('../scatter/calc_selection');
|
| 7 |
+
var BADNUM = require('../../constants/numerical').BADNUM;
|
| 8 |
+
|
| 9 |
+
function isAbsolute(a) {
|
| 10 |
+
return (a === 'a' || a === 'absolute');
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
function isTotal(a) {
|
| 14 |
+
return (a === 't' || a === 'total');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
module.exports = function calc(gd, trace) {
|
| 18 |
+
var xa = Axes.getFromId(gd, trace.xaxis || 'x');
|
| 19 |
+
var ya = Axes.getFromId(gd, trace.yaxis || 'y');
|
| 20 |
+
var size, pos, origPos, pObj, hasPeriod, pLetter;
|
| 21 |
+
|
| 22 |
+
if(trace.orientation === 'h') {
|
| 23 |
+
size = xa.makeCalcdata(trace, 'x');
|
| 24 |
+
origPos = ya.makeCalcdata(trace, 'y');
|
| 25 |
+
pObj = alignPeriod(trace, ya, 'y', origPos);
|
| 26 |
+
hasPeriod = !!trace.yperiodalignment;
|
| 27 |
+
pLetter = 'y';
|
| 28 |
+
} else {
|
| 29 |
+
size = ya.makeCalcdata(trace, 'y');
|
| 30 |
+
origPos = xa.makeCalcdata(trace, 'x');
|
| 31 |
+
pObj = alignPeriod(trace, xa, 'x', origPos);
|
| 32 |
+
hasPeriod = !!trace.xperiodalignment;
|
| 33 |
+
pLetter = 'x';
|
| 34 |
+
}
|
| 35 |
+
pos = pObj.vals;
|
| 36 |
+
|
| 37 |
+
// create the "calculated data" to plot
|
| 38 |
+
var serieslen = Math.min(pos.length, size.length);
|
| 39 |
+
var cd = new Array(serieslen);
|
| 40 |
+
|
| 41 |
+
// set position and size (as well as for waterfall total size)
|
| 42 |
+
var previousSum = 0;
|
| 43 |
+
var newSize;
|
| 44 |
+
// trace-wide flags
|
| 45 |
+
var hasTotals = false;
|
| 46 |
+
|
| 47 |
+
for(var i = 0; i < serieslen; i++) {
|
| 48 |
+
var amount = size[i] || 0;
|
| 49 |
+
|
| 50 |
+
var connectToNext = false;
|
| 51 |
+
if(size[i] !== BADNUM || isTotal(trace.measure[i]) || isAbsolute(trace.measure[i])) {
|
| 52 |
+
if(i + 1 < serieslen && (size[i + 1] !== BADNUM || isTotal(trace.measure[i + 1]) || isAbsolute(trace.measure[i + 1]))) {
|
| 53 |
+
connectToNext = true;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
var cdi = cd[i] = {
|
| 58 |
+
i: i,
|
| 59 |
+
p: pos[i],
|
| 60 |
+
s: amount,
|
| 61 |
+
rawS: amount,
|
| 62 |
+
cNext: connectToNext
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
if(isAbsolute(trace.measure[i])) {
|
| 66 |
+
previousSum = cdi.s;
|
| 67 |
+
|
| 68 |
+
cdi.isSum = true;
|
| 69 |
+
cdi.dir = 'totals';
|
| 70 |
+
cdi.s = previousSum;
|
| 71 |
+
} else if(isTotal(trace.measure[i])) {
|
| 72 |
+
cdi.isSum = true;
|
| 73 |
+
cdi.dir = 'totals';
|
| 74 |
+
cdi.s = previousSum;
|
| 75 |
+
} else {
|
| 76 |
+
// default: relative
|
| 77 |
+
cdi.isSum = false;
|
| 78 |
+
cdi.dir = cdi.rawS < 0 ? 'decreasing' : 'increasing';
|
| 79 |
+
newSize = cdi.s;
|
| 80 |
+
cdi.s = previousSum + newSize;
|
| 81 |
+
previousSum += newSize;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if(cdi.dir === 'totals') {
|
| 85 |
+
hasTotals = true;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
if(hasPeriod) {
|
| 89 |
+
cd[i].orig_p = origPos[i]; // used by hover
|
| 90 |
+
cd[i][pLetter + 'End'] = pObj.ends[i];
|
| 91 |
+
cd[i][pLetter + 'Start'] = pObj.starts[i];
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
if(trace.ids) {
|
| 95 |
+
cdi.id = String(trace.ids[i]);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
cdi.v = (trace.base || 0) + previousSum;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
if(cd.length) cd[0].hasTotals = hasTotals;
|
| 102 |
+
|
| 103 |
+
mergeArray(trace.text, cd, 'tx');
|
| 104 |
+
mergeArray(trace.hovertext, cd, 'htx');
|
| 105 |
+
calcSelection(cd, trace);
|
| 106 |
+
|
| 107 |
+
return cd;
|
| 108 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/constants.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
eventDataKeys: [
|
| 5 |
+
'initial',
|
| 6 |
+
'delta',
|
| 7 |
+
'final'
|
| 8 |
+
]
|
| 9 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/cross_trace_calc.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var setGroupPositions = require('../bar/cross_trace_calc').setGroupPositions;
|
| 4 |
+
|
| 5 |
+
module.exports = function crossTraceCalc(gd, plotinfo) {
|
| 6 |
+
var fullLayout = gd._fullLayout;
|
| 7 |
+
var fullData = gd._fullData;
|
| 8 |
+
var calcdata = gd.calcdata;
|
| 9 |
+
var xa = plotinfo.xaxis;
|
| 10 |
+
var ya = plotinfo.yaxis;
|
| 11 |
+
var waterfalls = [];
|
| 12 |
+
var waterfallsVert = [];
|
| 13 |
+
var waterfallsHorz = [];
|
| 14 |
+
var cd, i;
|
| 15 |
+
|
| 16 |
+
for(i = 0; i < fullData.length; i++) {
|
| 17 |
+
var fullTrace = fullData[i];
|
| 18 |
+
|
| 19 |
+
if(
|
| 20 |
+
fullTrace.visible === true &&
|
| 21 |
+
fullTrace.xaxis === xa._id &&
|
| 22 |
+
fullTrace.yaxis === ya._id &&
|
| 23 |
+
fullTrace.type === 'waterfall'
|
| 24 |
+
) {
|
| 25 |
+
cd = calcdata[i];
|
| 26 |
+
|
| 27 |
+
if(fullTrace.orientation === 'h') {
|
| 28 |
+
waterfallsHorz.push(cd);
|
| 29 |
+
} else {
|
| 30 |
+
waterfallsVert.push(cd);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
waterfalls.push(cd);
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
var opts = {
|
| 38 |
+
mode: fullLayout.waterfallmode,
|
| 39 |
+
norm: fullLayout.waterfallnorm,
|
| 40 |
+
gap: fullLayout.waterfallgap,
|
| 41 |
+
groupgap: fullLayout.waterfallgroupgap
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
setGroupPositions(gd, xa, ya, waterfallsVert, opts);
|
| 45 |
+
setGroupPositions(gd, ya, xa, waterfallsHorz, opts);
|
| 46 |
+
|
| 47 |
+
for(i = 0; i < waterfalls.length; i++) {
|
| 48 |
+
cd = waterfalls[i];
|
| 49 |
+
|
| 50 |
+
for(var j = 0; j < cd.length; j++) {
|
| 51 |
+
var di = cd[j];
|
| 52 |
+
|
| 53 |
+
if(di.isSum === false) {
|
| 54 |
+
di.s0 += (j === 0) ? 0 : cd[j - 1].s;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
if(j + 1 < cd.length) {
|
| 58 |
+
cd[j].nextP0 = cd[j + 1].p0;
|
| 59 |
+
cd[j].nextS0 = cd[j + 1].s0;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/defaults.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
|
| 5 |
+
var handleGroupingDefaults = require('../scatter/grouping_defaults');
|
| 6 |
+
var handleText = require('../bar/defaults').handleText;
|
| 7 |
+
var handleXYDefaults = require('../scatter/xy_defaults');
|
| 8 |
+
var handlePeriodDefaults = require('../scatter/period_defaults');
|
| 9 |
+
var attributes = require('./attributes');
|
| 10 |
+
var Color = require('../../components/color');
|
| 11 |
+
var delta = require('../../constants/delta.js');
|
| 12 |
+
|
| 13 |
+
var INCREASING_COLOR = delta.INCREASING.COLOR;
|
| 14 |
+
var DECREASING_COLOR = delta.DECREASING.COLOR;
|
| 15 |
+
var TOTALS_COLOR = '#4499FF';
|
| 16 |
+
|
| 17 |
+
function handleDirection(coerce, direction, defaultColor) {
|
| 18 |
+
coerce(direction + '.marker.color', defaultColor);
|
| 19 |
+
coerce(direction + '.marker.line.color', Color.defaultLine);
|
| 20 |
+
coerce(direction + '.marker.line.width');
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
|
| 24 |
+
function coerce(attr, dflt) {
|
| 25 |
+
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
var len = handleXYDefaults(traceIn, traceOut, layout, coerce);
|
| 29 |
+
if(!len) {
|
| 30 |
+
traceOut.visible = false;
|
| 31 |
+
return;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
handlePeriodDefaults(traceIn, traceOut, layout, coerce);
|
| 35 |
+
coerce('xhoverformat');
|
| 36 |
+
coerce('yhoverformat');
|
| 37 |
+
|
| 38 |
+
coerce('measure');
|
| 39 |
+
|
| 40 |
+
coerce('orientation', (traceOut.x && !traceOut.y) ? 'h' : 'v');
|
| 41 |
+
coerce('base');
|
| 42 |
+
coerce('offset');
|
| 43 |
+
coerce('width');
|
| 44 |
+
|
| 45 |
+
coerce('text');
|
| 46 |
+
|
| 47 |
+
coerce('hovertext');
|
| 48 |
+
coerce('hovertemplate');
|
| 49 |
+
|
| 50 |
+
var textposition = coerce('textposition');
|
| 51 |
+
handleText(traceIn, traceOut, layout, coerce, textposition, {
|
| 52 |
+
moduleHasSelected: false,
|
| 53 |
+
moduleHasUnselected: false,
|
| 54 |
+
moduleHasConstrain: true,
|
| 55 |
+
moduleHasCliponaxis: true,
|
| 56 |
+
moduleHasTextangle: true,
|
| 57 |
+
moduleHasInsideanchor: true
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
if(traceOut.textposition !== 'none') {
|
| 62 |
+
coerce('texttemplate');
|
| 63 |
+
if(!traceOut.texttemplate) coerce('textinfo');
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
handleDirection(coerce, 'increasing', INCREASING_COLOR);
|
| 67 |
+
handleDirection(coerce, 'decreasing', DECREASING_COLOR);
|
| 68 |
+
handleDirection(coerce, 'totals', TOTALS_COLOR);
|
| 69 |
+
|
| 70 |
+
var connectorVisible = coerce('connector.visible');
|
| 71 |
+
if(connectorVisible) {
|
| 72 |
+
coerce('connector.mode');
|
| 73 |
+
var connectorLineWidth = coerce('connector.line.width');
|
| 74 |
+
if(connectorLineWidth) {
|
| 75 |
+
coerce('connector.line.color');
|
| 76 |
+
coerce('connector.line.dash');
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function crossTraceDefaults(fullData, fullLayout) {
|
| 82 |
+
var traceIn, traceOut;
|
| 83 |
+
|
| 84 |
+
function coerce(attr) {
|
| 85 |
+
return Lib.coerce(traceOut._input, traceOut, attributes, attr);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
if(fullLayout.waterfallmode === 'group') {
|
| 89 |
+
for(var i = 0; i < fullData.length; i++) {
|
| 90 |
+
traceOut = fullData[i];
|
| 91 |
+
traceIn = traceOut._input;
|
| 92 |
+
|
| 93 |
+
handleGroupingDefaults(traceIn, traceOut, fullLayout, coerce);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
module.exports = {
|
| 99 |
+
supplyDefaults: supplyDefaults,
|
| 100 |
+
crossTraceDefaults: crossTraceDefaults
|
| 101 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/event_data.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = function eventData(out, pt /* , trace, cd, pointNumber */) {
|
| 4 |
+
// standard cartesian event data
|
| 5 |
+
out.x = 'xVal' in pt ? pt.xVal : pt.x;
|
| 6 |
+
out.y = 'yVal' in pt ? pt.yVal : pt.y;
|
| 7 |
+
|
| 8 |
+
// for funnel
|
| 9 |
+
if('initial' in pt) out.initial = pt.initial;
|
| 10 |
+
if('delta' in pt) out.delta = pt.delta;
|
| 11 |
+
if('final' in pt) out.final = pt.final;
|
| 12 |
+
|
| 13 |
+
if(pt.xa) out.xaxis = pt.xa;
|
| 14 |
+
if(pt.ya) out.yaxis = pt.ya;
|
| 15 |
+
|
| 16 |
+
return out;
|
| 17 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/hover.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var hoverLabelText = require('../../plots/cartesian/axes').hoverLabelText;
|
| 4 |
+
var opacity = require('../../components/color').opacity;
|
| 5 |
+
var hoverOnBars = require('../bar/hover').hoverOnBars;
|
| 6 |
+
var delta = require('../../constants/delta.js');
|
| 7 |
+
|
| 8 |
+
var DIRSYMBOL = {
|
| 9 |
+
increasing: delta.INCREASING.SYMBOL,
|
| 10 |
+
decreasing: delta.DECREASING.SYMBOL
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) {
|
| 14 |
+
var point = hoverOnBars(pointData, xval, yval, hovermode, opts);
|
| 15 |
+
if(!point) return;
|
| 16 |
+
|
| 17 |
+
var cd = point.cd;
|
| 18 |
+
var trace = cd[0].trace;
|
| 19 |
+
var isHorizontal = (trace.orientation === 'h');
|
| 20 |
+
|
| 21 |
+
var vLetter = isHorizontal ? 'x' : 'y';
|
| 22 |
+
var vAxis = isHorizontal ? pointData.xa : pointData.ya;
|
| 23 |
+
|
| 24 |
+
function formatNumber(a) {
|
| 25 |
+
return hoverLabelText(vAxis, a, trace[vLetter + 'hoverformat']);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
// the closest data point
|
| 29 |
+
var index = point.index;
|
| 30 |
+
var di = cd[index];
|
| 31 |
+
|
| 32 |
+
var size = (di.isSum) ? di.b + di.s : di.rawS;
|
| 33 |
+
|
| 34 |
+
point.initial = di.b + di.s - size;
|
| 35 |
+
point.delta = size;
|
| 36 |
+
point.final = point.initial + point.delta;
|
| 37 |
+
|
| 38 |
+
var v = formatNumber(Math.abs(point.delta));
|
| 39 |
+
point.deltaLabel = size < 0 ? '(' + v + ')' : v;
|
| 40 |
+
point.finalLabel = formatNumber(point.final);
|
| 41 |
+
point.initialLabel = formatNumber(point.initial);
|
| 42 |
+
|
| 43 |
+
var hoverinfo = di.hi || trace.hoverinfo;
|
| 44 |
+
var text = [];
|
| 45 |
+
if(hoverinfo && hoverinfo !== 'none' && hoverinfo !== 'skip') {
|
| 46 |
+
var isAll = (hoverinfo === 'all');
|
| 47 |
+
var parts = hoverinfo.split('+');
|
| 48 |
+
|
| 49 |
+
var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; };
|
| 50 |
+
|
| 51 |
+
if(!di.isSum) {
|
| 52 |
+
if(hasFlag('final') &&
|
| 53 |
+
(isHorizontal ? !hasFlag('x') : !hasFlag('y')) // don't display redundant info.
|
| 54 |
+
) {
|
| 55 |
+
text.push(point.finalLabel);
|
| 56 |
+
}
|
| 57 |
+
if(hasFlag('delta')) {
|
| 58 |
+
if(size < 0) {
|
| 59 |
+
text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing);
|
| 60 |
+
} else {
|
| 61 |
+
text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing);
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
if(hasFlag('initial')) {
|
| 65 |
+
text.push('Initial: ' + point.initialLabel);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if(text.length) point.extraText = text.join('<br>');
|
| 71 |
+
|
| 72 |
+
point.color = getTraceColor(trace, di);
|
| 73 |
+
|
| 74 |
+
return [point];
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
function getTraceColor(trace, di) {
|
| 78 |
+
var cont = trace[di.dir].marker;
|
| 79 |
+
var mc = cont.color;
|
| 80 |
+
var mlc = cont.line.color;
|
| 81 |
+
var mlw = cont.line.width;
|
| 82 |
+
if(opacity(mc)) return mc;
|
| 83 |
+
else if(opacity(mlc) && mlw) return mlc;
|
| 84 |
+
}
|
node_modules/plotly.js/src/traces/waterfall/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
attributes: require('./attributes'),
|
| 5 |
+
layoutAttributes: require('./layout_attributes'),
|
| 6 |
+
supplyDefaults: require('./defaults').supplyDefaults,
|
| 7 |
+
crossTraceDefaults: require('./defaults').crossTraceDefaults,
|
| 8 |
+
supplyLayoutDefaults: require('./layout_defaults'),
|
| 9 |
+
calc: require('./calc'),
|
| 10 |
+
crossTraceCalc: require('./cross_trace_calc'),
|
| 11 |
+
plot: require('./plot'),
|
| 12 |
+
style: require('./style').style,
|
| 13 |
+
hoverPoints: require('./hover'),
|
| 14 |
+
eventData: require('./event_data'),
|
| 15 |
+
|
| 16 |
+
selectPoints: require('../bar/select'),
|
| 17 |
+
|
| 18 |
+
moduleType: 'trace',
|
| 19 |
+
name: 'waterfall',
|
| 20 |
+
basePlotModule: require('../../plots/cartesian'),
|
| 21 |
+
categories: ['bar-like', 'cartesian', 'svg', 'oriented', 'showLegend', 'zoomScale'],
|
| 22 |
+
meta: {
|
| 23 |
+
description: [
|
| 24 |
+
'Draws waterfall trace which is useful graph to displays the',
|
| 25 |
+
'contribution of various elements (either positive or negative)',
|
| 26 |
+
'in a bar chart. The data visualized by the span of the bars is',
|
| 27 |
+
'set in `y` if `orientation` is set to *v* (the default) and the',
|
| 28 |
+
'labels are set in `x`.',
|
| 29 |
+
'By setting `orientation` to *h*, the roles are interchanged.'
|
| 30 |
+
].join(' ')
|
| 31 |
+
}
|
| 32 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/layout_attributes.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
waterfallmode: {
|
| 5 |
+
valType: 'enumerated',
|
| 6 |
+
values: ['group', 'overlay'],
|
| 7 |
+
dflt: 'group',
|
| 8 |
+
editType: 'calc',
|
| 9 |
+
description: [
|
| 10 |
+
'Determines how bars at the same location coordinate',
|
| 11 |
+
'are displayed on the graph.',
|
| 12 |
+
'With *group*, the bars are plotted next to one another',
|
| 13 |
+
'centered around the shared location.',
|
| 14 |
+
'With *overlay*, the bars are plotted over one another,',
|
| 15 |
+
'you might need to reduce *opacity* to see multiple bars.'
|
| 16 |
+
].join(' ')
|
| 17 |
+
},
|
| 18 |
+
waterfallgap: {
|
| 19 |
+
valType: 'number',
|
| 20 |
+
min: 0,
|
| 21 |
+
max: 1,
|
| 22 |
+
editType: 'calc',
|
| 23 |
+
description: [
|
| 24 |
+
'Sets the gap (in plot fraction) between bars of',
|
| 25 |
+
'adjacent location coordinates.'
|
| 26 |
+
].join(' ')
|
| 27 |
+
},
|
| 28 |
+
waterfallgroupgap: {
|
| 29 |
+
valType: 'number',
|
| 30 |
+
min: 0,
|
| 31 |
+
max: 1,
|
| 32 |
+
dflt: 0,
|
| 33 |
+
editType: 'calc',
|
| 34 |
+
description: [
|
| 35 |
+
'Sets the gap (in plot fraction) between bars of',
|
| 36 |
+
'the same location coordinate.'
|
| 37 |
+
].join(' ')
|
| 38 |
+
}
|
| 39 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/layout_defaults.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../../lib');
|
| 4 |
+
var layoutAttributes = require('./layout_attributes');
|
| 5 |
+
|
| 6 |
+
module.exports = function(layoutIn, layoutOut, fullData) {
|
| 7 |
+
var hasTraceType = false;
|
| 8 |
+
|
| 9 |
+
function coerce(attr, dflt) {
|
| 10 |
+
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
for(var i = 0; i < fullData.length; i++) {
|
| 14 |
+
var trace = fullData[i];
|
| 15 |
+
|
| 16 |
+
if(trace.visible && trace.type === 'waterfall') {
|
| 17 |
+
hasTraceType = true;
|
| 18 |
+
break;
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
if(hasTraceType) {
|
| 23 |
+
coerce('waterfallmode');
|
| 24 |
+
coerce('waterfallgap', 0.2);
|
| 25 |
+
coerce('waterfallgroupgap');
|
| 26 |
+
}
|
| 27 |
+
};
|
node_modules/plotly.js/src/traces/waterfall/plot.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
var Lib = require('../../lib');
|
| 5 |
+
var Drawing = require('../../components/drawing');
|
| 6 |
+
var BADNUM = require('../../constants/numerical').BADNUM;
|
| 7 |
+
var barPlot = require('../bar/plot');
|
| 8 |
+
var clearMinTextSize = require('../bar/uniform_text').clearMinTextSize;
|
| 9 |
+
|
| 10 |
+
module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
|
| 11 |
+
var fullLayout = gd._fullLayout;
|
| 12 |
+
|
| 13 |
+
clearMinTextSize('waterfall', fullLayout);
|
| 14 |
+
|
| 15 |
+
barPlot.plot(gd, plotinfo, cdModule, traceLayer, {
|
| 16 |
+
mode: fullLayout.waterfallmode,
|
| 17 |
+
norm: fullLayout.waterfallmode,
|
| 18 |
+
gap: fullLayout.waterfallgap,
|
| 19 |
+
groupgap: fullLayout.waterfallgroupgap
|
| 20 |
+
});
|
| 21 |
+
|
| 22 |
+
plotConnectors(gd, plotinfo, cdModule, traceLayer);
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
function plotConnectors(gd, plotinfo, cdModule, traceLayer) {
|
| 26 |
+
var xa = plotinfo.xaxis;
|
| 27 |
+
var ya = plotinfo.yaxis;
|
| 28 |
+
|
| 29 |
+
Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function(cd) {
|
| 30 |
+
var plotGroup = d3.select(this);
|
| 31 |
+
var trace = cd[0].trace;
|
| 32 |
+
|
| 33 |
+
var group = Lib.ensureSingle(plotGroup, 'g', 'lines');
|
| 34 |
+
|
| 35 |
+
if(!trace.connector || !trace.connector.visible) {
|
| 36 |
+
group.remove();
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
var isHorizontal = (trace.orientation === 'h');
|
| 41 |
+
var mode = trace.connector.mode;
|
| 42 |
+
|
| 43 |
+
var connectors = group.selectAll('g.line').data(Lib.identity);
|
| 44 |
+
|
| 45 |
+
connectors.enter().append('g')
|
| 46 |
+
.classed('line', true);
|
| 47 |
+
|
| 48 |
+
connectors.exit().remove();
|
| 49 |
+
|
| 50 |
+
var len = connectors.size();
|
| 51 |
+
|
| 52 |
+
connectors.each(function(di, i) {
|
| 53 |
+
// don't draw lines between nulls
|
| 54 |
+
if(i !== len - 1 && !di.cNext) return;
|
| 55 |
+
|
| 56 |
+
var xy = getXY(di, xa, ya, isHorizontal);
|
| 57 |
+
var x = xy[0];
|
| 58 |
+
var y = xy[1];
|
| 59 |
+
|
| 60 |
+
var shape = '';
|
| 61 |
+
|
| 62 |
+
if(
|
| 63 |
+
x[0] !== BADNUM && y[0] !== BADNUM &&
|
| 64 |
+
x[1] !== BADNUM && y[1] !== BADNUM
|
| 65 |
+
) {
|
| 66 |
+
if(mode === 'spanning') {
|
| 67 |
+
if(!di.isSum && i > 0) {
|
| 68 |
+
if(isHorizontal) {
|
| 69 |
+
shape += 'M' + x[0] + ',' + y[1] + 'V' + y[0];
|
| 70 |
+
} else {
|
| 71 |
+
shape += 'M' + x[1] + ',' + y[0] + 'H' + x[0];
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if(mode !== 'between') {
|
| 77 |
+
if(di.isSum || i < len - 1) {
|
| 78 |
+
if(isHorizontal) {
|
| 79 |
+
shape += 'M' + x[1] + ',' + y[0] + 'V' + y[1];
|
| 80 |
+
} else {
|
| 81 |
+
shape += 'M' + x[0] + ',' + y[1] + 'H' + x[1];
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if(x[2] !== BADNUM && y[2] !== BADNUM) {
|
| 87 |
+
if(isHorizontal) {
|
| 88 |
+
shape += 'M' + x[1] + ',' + y[1] + 'V' + y[2];
|
| 89 |
+
} else {
|
| 90 |
+
shape += 'M' + x[1] + ',' + y[1] + 'H' + x[2];
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
if(shape === '') shape = 'M0,0Z';
|
| 96 |
+
|
| 97 |
+
Lib.ensureSingle(d3.select(this), 'path')
|
| 98 |
+
.attr('d', shape)
|
| 99 |
+
.call(Drawing.setClipUrl, plotinfo.layerClipId, gd);
|
| 100 |
+
});
|
| 101 |
+
});
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function getXY(di, xa, ya, isHorizontal) {
|
| 105 |
+
var s = [];
|
| 106 |
+
var p = [];
|
| 107 |
+
|
| 108 |
+
var sAxis = isHorizontal ? xa : ya;
|
| 109 |
+
var pAxis = isHorizontal ? ya : xa;
|
| 110 |
+
|
| 111 |
+
s[0] = sAxis.c2p(di.s0, true);
|
| 112 |
+
p[0] = pAxis.c2p(di.p0, true);
|
| 113 |
+
|
| 114 |
+
s[1] = sAxis.c2p(di.s1, true);
|
| 115 |
+
p[1] = pAxis.c2p(di.p1, true);
|
| 116 |
+
|
| 117 |
+
s[2] = sAxis.c2p(di.nextS0, true);
|
| 118 |
+
p[2] = pAxis.c2p(di.nextP0, true);
|
| 119 |
+
|
| 120 |
+
return isHorizontal ? [s, p] : [p, s];
|
| 121 |
+
}
|
node_modules/plotly.js/src/traces/waterfall/style.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var d3 = require('@plotly/d3');
|
| 4 |
+
|
| 5 |
+
var Drawing = require('../../components/drawing');
|
| 6 |
+
var Color = require('../../components/color');
|
| 7 |
+
var DESELECTDIM = require('../../constants/interactions').DESELECTDIM;
|
| 8 |
+
var barStyle = require('../bar/style');
|
| 9 |
+
var resizeText = require('../bar/uniform_text').resizeText;
|
| 10 |
+
var styleTextPoints = barStyle.styleTextPoints;
|
| 11 |
+
|
| 12 |
+
function style(gd, cd, sel) {
|
| 13 |
+
var s = sel ? sel : d3.select(gd).selectAll('g.waterfalllayer').selectAll('g.trace');
|
| 14 |
+
resizeText(gd, s, 'waterfall');
|
| 15 |
+
|
| 16 |
+
s.style('opacity', function(d) { return d[0].trace.opacity; });
|
| 17 |
+
|
| 18 |
+
s.each(function(d) {
|
| 19 |
+
var gTrace = d3.select(this);
|
| 20 |
+
var trace = d[0].trace;
|
| 21 |
+
|
| 22 |
+
gTrace.selectAll('.point > path').each(function(di) {
|
| 23 |
+
if(!di.isBlank) {
|
| 24 |
+
var cont = trace[di.dir].marker;
|
| 25 |
+
|
| 26 |
+
d3.select(this)
|
| 27 |
+
.call(Color.fill, cont.color)
|
| 28 |
+
.call(Color.stroke, cont.line.color)
|
| 29 |
+
.call(Drawing.dashLine, cont.line.dash, cont.line.width)
|
| 30 |
+
.style('opacity', trace.selectedpoints && !di.selected ? DESELECTDIM : 1);
|
| 31 |
+
}
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
styleTextPoints(gTrace, trace, gd);
|
| 35 |
+
|
| 36 |
+
gTrace.selectAll('.lines').each(function() {
|
| 37 |
+
var cont = trace.connector.line;
|
| 38 |
+
|
| 39 |
+
Drawing.lineGroupStyle(
|
| 40 |
+
d3.select(this).selectAll('path'),
|
| 41 |
+
cont.width,
|
| 42 |
+
cont.color,
|
| 43 |
+
cont.dash
|
| 44 |
+
);
|
| 45 |
+
});
|
| 46 |
+
});
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
module.exports = {
|
| 50 |
+
style: style
|
| 51 |
+
};
|
node_modules/plotly.js/src/transforms/aggregate.js
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Axes = require('../plots/cartesian/axes');
|
| 4 |
+
var Lib = require('../lib');
|
| 5 |
+
var PlotSchema = require('../plot_api/plot_schema');
|
| 6 |
+
var pointsAccessorFunction = require('./helpers').pointsAccessorFunction;
|
| 7 |
+
var BADNUM = require('../constants/numerical').BADNUM;
|
| 8 |
+
|
| 9 |
+
exports.moduleType = 'transform';
|
| 10 |
+
|
| 11 |
+
exports.name = 'aggregate';
|
| 12 |
+
|
| 13 |
+
var attrs = exports.attributes = {
|
| 14 |
+
enabled: {
|
| 15 |
+
valType: 'boolean',
|
| 16 |
+
dflt: true,
|
| 17 |
+
editType: 'calc',
|
| 18 |
+
description: [
|
| 19 |
+
'Determines whether this aggregate transform is enabled or disabled.'
|
| 20 |
+
].join(' ')
|
| 21 |
+
},
|
| 22 |
+
groups: {
|
| 23 |
+
// TODO: groupby should support string or array grouping this way too
|
| 24 |
+
// currently groupby only allows a grouping array
|
| 25 |
+
valType: 'string',
|
| 26 |
+
strict: true,
|
| 27 |
+
noBlank: true,
|
| 28 |
+
arrayOk: true,
|
| 29 |
+
dflt: 'x',
|
| 30 |
+
editType: 'calc',
|
| 31 |
+
description: [
|
| 32 |
+
'Sets the grouping target to which the aggregation is applied.',
|
| 33 |
+
'Data points with matching group values will be coalesced into',
|
| 34 |
+
'one point, using the supplied aggregation functions to reduce data',
|
| 35 |
+
'in other data arrays.',
|
| 36 |
+
'If a string, `groups` is assumed to be a reference to a data array',
|
| 37 |
+
'in the parent trace object.',
|
| 38 |
+
'To aggregate by nested variables, use *.* to access them.',
|
| 39 |
+
'For example, set `groups` to *marker.color* to aggregate',
|
| 40 |
+
'about the marker color array.',
|
| 41 |
+
'If an array, `groups` is itself the data array by which we aggregate.'
|
| 42 |
+
].join(' ')
|
| 43 |
+
},
|
| 44 |
+
aggregations: {
|
| 45 |
+
_isLinkedToArray: 'aggregation',
|
| 46 |
+
target: {
|
| 47 |
+
valType: 'string',
|
| 48 |
+
editType: 'calc',
|
| 49 |
+
description: [
|
| 50 |
+
'A reference to the data array in the parent trace to aggregate.',
|
| 51 |
+
'To aggregate by nested variables, use *.* to access them.',
|
| 52 |
+
'For example, set `groups` to *marker.color* to aggregate',
|
| 53 |
+
'over the marker color array.',
|
| 54 |
+
'The referenced array must already exist, unless `func` is *count*,',
|
| 55 |
+
'and each array may only be referenced once.'
|
| 56 |
+
].join(' ')
|
| 57 |
+
},
|
| 58 |
+
func: {
|
| 59 |
+
valType: 'enumerated',
|
| 60 |
+
values: ['count', 'sum', 'avg', 'median', 'mode', 'rms', 'stddev', 'min', 'max', 'first', 'last', 'change', 'range'],
|
| 61 |
+
dflt: 'first',
|
| 62 |
+
editType: 'calc',
|
| 63 |
+
description: [
|
| 64 |
+
'Sets the aggregation function.',
|
| 65 |
+
'All values from the linked `target`, corresponding to the same value',
|
| 66 |
+
'in the `groups` array, are collected and reduced by this function.',
|
| 67 |
+
'*count* is simply the number of values in the `groups` array, so does',
|
| 68 |
+
'not even require the linked array to exist. *first* (*last*) is just',
|
| 69 |
+
'the first (last) linked value.',
|
| 70 |
+
'Invalid values are ignored, so for example in *avg* they do not',
|
| 71 |
+
'contribute to either the numerator or the denominator.',
|
| 72 |
+
'Any data type (numeric, date, category) may be aggregated with any',
|
| 73 |
+
'function, even though in certain cases it is unlikely to make sense,',
|
| 74 |
+
'for example a sum of dates or average of categories.',
|
| 75 |
+
'*median* will return the average of the two central values if there is',
|
| 76 |
+
'an even count. *mode* will return the first value to reach the maximum',
|
| 77 |
+
'count, in case of a tie.',
|
| 78 |
+
'*change* will return the difference between the first and last linked values.',
|
| 79 |
+
'*range* will return the difference between the min and max linked values.'
|
| 80 |
+
].join(' ')
|
| 81 |
+
},
|
| 82 |
+
funcmode: {
|
| 83 |
+
valType: 'enumerated',
|
| 84 |
+
values: ['sample', 'population'],
|
| 85 |
+
dflt: 'sample',
|
| 86 |
+
editType: 'calc',
|
| 87 |
+
description: [
|
| 88 |
+
'*stddev* supports two formula variants: *sample* (normalize by N-1)',
|
| 89 |
+
'and *population* (normalize by N).'
|
| 90 |
+
].join(' ')
|
| 91 |
+
},
|
| 92 |
+
enabled: {
|
| 93 |
+
valType: 'boolean',
|
| 94 |
+
dflt: true,
|
| 95 |
+
editType: 'calc',
|
| 96 |
+
description: [
|
| 97 |
+
'Determines whether this aggregation function is enabled or disabled.'
|
| 98 |
+
].join(' ')
|
| 99 |
+
},
|
| 100 |
+
editType: 'calc'
|
| 101 |
+
},
|
| 102 |
+
editType: 'calc'
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
var aggAttrs = attrs.aggregations;
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Supply transform attributes defaults
|
| 109 |
+
*
|
| 110 |
+
* @param {object} transformIn
|
| 111 |
+
* object linked to trace.transforms[i] with 'func' set to exports.name
|
| 112 |
+
* @param {object} traceOut
|
| 113 |
+
* the _fullData trace this transform applies to
|
| 114 |
+
* @param {object} layout
|
| 115 |
+
* the plot's (not-so-full) layout
|
| 116 |
+
* @param {object} traceIn
|
| 117 |
+
* the input data trace this transform applies to
|
| 118 |
+
*
|
| 119 |
+
* @return {object} transformOut
|
| 120 |
+
* copy of transformIn that contains attribute defaults
|
| 121 |
+
*/
|
| 122 |
+
exports.supplyDefaults = function(transformIn, traceOut) {
|
| 123 |
+
var transformOut = {};
|
| 124 |
+
var i;
|
| 125 |
+
|
| 126 |
+
function coerce(attr, dflt) {
|
| 127 |
+
return Lib.coerce(transformIn, transformOut, attrs, attr, dflt);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
var enabled = coerce('enabled');
|
| 131 |
+
|
| 132 |
+
if(!enabled) return transformOut;
|
| 133 |
+
|
| 134 |
+
/*
|
| 135 |
+
* Normally _arrayAttrs is calculated during doCalc, but that comes later.
|
| 136 |
+
* Anyway this can change due to *count* aggregations (see below) so it's not
|
| 137 |
+
* necessarily the same set.
|
| 138 |
+
*
|
| 139 |
+
* For performance we turn it into an object of truthy values
|
| 140 |
+
* we'll use 1 for arrays we haven't aggregated yet, 0 for finished arrays,
|
| 141 |
+
* as distinct from undefined which means this array isn't present in the input
|
| 142 |
+
* missing arrays can still be aggregate outputs for *count* aggregations.
|
| 143 |
+
*/
|
| 144 |
+
var arrayAttrArray = PlotSchema.findArrayAttributes(traceOut);
|
| 145 |
+
var arrayAttrs = {};
|
| 146 |
+
for(i = 0; i < arrayAttrArray.length; i++) arrayAttrs[arrayAttrArray[i]] = 1;
|
| 147 |
+
|
| 148 |
+
var groups = coerce('groups');
|
| 149 |
+
|
| 150 |
+
if(!Array.isArray(groups)) {
|
| 151 |
+
if(!arrayAttrs[groups]) {
|
| 152 |
+
transformOut.enabled = false;
|
| 153 |
+
return transformOut;
|
| 154 |
+
}
|
| 155 |
+
arrayAttrs[groups] = 0;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
var aggregationsIn = transformIn.aggregations || [];
|
| 159 |
+
var aggregationsOut = transformOut.aggregations = new Array(aggregationsIn.length);
|
| 160 |
+
var aggregationOut;
|
| 161 |
+
|
| 162 |
+
function coercei(attr, dflt) {
|
| 163 |
+
return Lib.coerce(aggregationsIn[i], aggregationOut, aggAttrs, attr, dflt);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
for(i = 0; i < aggregationsIn.length; i++) {
|
| 167 |
+
aggregationOut = {_index: i};
|
| 168 |
+
var target = coercei('target');
|
| 169 |
+
var func = coercei('func');
|
| 170 |
+
var enabledi = coercei('enabled');
|
| 171 |
+
|
| 172 |
+
// add this aggregation to the output only if it's the first instance
|
| 173 |
+
// of a valid target attribute - or an unused target attribute with "count"
|
| 174 |
+
if(enabledi && target && (arrayAttrs[target] || (func === 'count' && arrayAttrs[target] === undefined))) {
|
| 175 |
+
if(func === 'stddev') coercei('funcmode');
|
| 176 |
+
|
| 177 |
+
arrayAttrs[target] = 0;
|
| 178 |
+
aggregationsOut[i] = aggregationOut;
|
| 179 |
+
} else aggregationsOut[i] = {enabled: false, _index: i};
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// any array attributes we haven't yet covered, fill them with the default aggregation
|
| 183 |
+
for(i = 0; i < arrayAttrArray.length; i++) {
|
| 184 |
+
if(arrayAttrs[arrayAttrArray[i]]) {
|
| 185 |
+
aggregationsOut.push({
|
| 186 |
+
target: arrayAttrArray[i],
|
| 187 |
+
func: aggAttrs.func.dflt,
|
| 188 |
+
enabled: true,
|
| 189 |
+
_index: -1
|
| 190 |
+
});
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
return transformOut;
|
| 195 |
+
};
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
exports.calcTransform = function(gd, trace, opts) {
|
| 199 |
+
if(!opts.enabled) return;
|
| 200 |
+
|
| 201 |
+
var groups = opts.groups;
|
| 202 |
+
|
| 203 |
+
var groupArray = Lib.getTargetArray(trace, {target: groups});
|
| 204 |
+
if(!groupArray) return;
|
| 205 |
+
|
| 206 |
+
var i, vi, groupIndex, newGrouping;
|
| 207 |
+
|
| 208 |
+
var groupIndices = {};
|
| 209 |
+
var indexToPoints = {};
|
| 210 |
+
var groupings = [];
|
| 211 |
+
|
| 212 |
+
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
|
| 213 |
+
|
| 214 |
+
var len = groupArray.length;
|
| 215 |
+
if(trace._length) len = Math.min(len, trace._length);
|
| 216 |
+
|
| 217 |
+
for(i = 0; i < len; i++) {
|
| 218 |
+
vi = groupArray[i];
|
| 219 |
+
groupIndex = groupIndices[vi];
|
| 220 |
+
if(groupIndex === undefined) {
|
| 221 |
+
groupIndices[vi] = groupings.length;
|
| 222 |
+
newGrouping = [i];
|
| 223 |
+
groupings.push(newGrouping);
|
| 224 |
+
indexToPoints[groupIndices[vi]] = originalPointsAccessor(i);
|
| 225 |
+
} else {
|
| 226 |
+
groupings[groupIndex].push(i);
|
| 227 |
+
indexToPoints[groupIndices[vi]] = (indexToPoints[groupIndices[vi]] || []).concat(originalPointsAccessor(i));
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
opts._indexToPoints = indexToPoints;
|
| 232 |
+
|
| 233 |
+
var aggregations = opts.aggregations;
|
| 234 |
+
|
| 235 |
+
for(i = 0; i < aggregations.length; i++) {
|
| 236 |
+
aggregateOneArray(gd, trace, groupings, aggregations[i]);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
if(typeof groups === 'string') {
|
| 240 |
+
aggregateOneArray(gd, trace, groupings, {
|
| 241 |
+
target: groups,
|
| 242 |
+
func: 'first',
|
| 243 |
+
enabled: true
|
| 244 |
+
});
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
trace._length = groupings.length;
|
| 248 |
+
};
|
| 249 |
+
|
| 250 |
+
function aggregateOneArray(gd, trace, groupings, aggregation) {
|
| 251 |
+
if(!aggregation.enabled) return;
|
| 252 |
+
|
| 253 |
+
var attr = aggregation.target;
|
| 254 |
+
var targetNP = Lib.nestedProperty(trace, attr);
|
| 255 |
+
var arrayIn = targetNP.get();
|
| 256 |
+
var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn);
|
| 257 |
+
var func = getAggregateFunction(aggregation, conversions);
|
| 258 |
+
|
| 259 |
+
var arrayOut = new Array(groupings.length);
|
| 260 |
+
for(var i = 0; i < groupings.length; i++) {
|
| 261 |
+
arrayOut[i] = func(arrayIn, groupings[i]);
|
| 262 |
+
}
|
| 263 |
+
targetNP.set(arrayOut);
|
| 264 |
+
|
| 265 |
+
if(aggregation.func === 'count') {
|
| 266 |
+
// count does not depend on an input array, so it's likely not part of _arrayAttrs yet
|
| 267 |
+
// but after this transform it most definitely *is* an array attribute.
|
| 268 |
+
Lib.pushUnique(trace._arrayAttrs, attr);
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
function getAggregateFunction(opts, conversions) {
|
| 273 |
+
var func = opts.func;
|
| 274 |
+
var d2c = conversions.d2c;
|
| 275 |
+
var c2d = conversions.c2d;
|
| 276 |
+
|
| 277 |
+
switch(func) {
|
| 278 |
+
// count, first, and last don't depend on anything about the data
|
| 279 |
+
// point back to pure functions for performance
|
| 280 |
+
case 'count':
|
| 281 |
+
return count;
|
| 282 |
+
case 'first':
|
| 283 |
+
return first;
|
| 284 |
+
case 'last':
|
| 285 |
+
return last;
|
| 286 |
+
|
| 287 |
+
case 'sum':
|
| 288 |
+
// This will produce output in all cases even though it's nonsensical
|
| 289 |
+
// for date or category data.
|
| 290 |
+
return function(array, indices) {
|
| 291 |
+
var total = 0;
|
| 292 |
+
for(var i = 0; i < indices.length; i++) {
|
| 293 |
+
var vi = d2c(array[indices[i]]);
|
| 294 |
+
if(vi !== BADNUM) total += vi;
|
| 295 |
+
}
|
| 296 |
+
return c2d(total);
|
| 297 |
+
};
|
| 298 |
+
|
| 299 |
+
case 'avg':
|
| 300 |
+
// Generally meaningless for category data but it still does something.
|
| 301 |
+
return function(array, indices) {
|
| 302 |
+
var total = 0;
|
| 303 |
+
var cnt = 0;
|
| 304 |
+
for(var i = 0; i < indices.length; i++) {
|
| 305 |
+
var vi = d2c(array[indices[i]]);
|
| 306 |
+
if(vi !== BADNUM) {
|
| 307 |
+
total += vi;
|
| 308 |
+
cnt++;
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
return cnt ? c2d(total / cnt) : BADNUM;
|
| 312 |
+
};
|
| 313 |
+
|
| 314 |
+
case 'min':
|
| 315 |
+
return function(array, indices) {
|
| 316 |
+
var out = Infinity;
|
| 317 |
+
for(var i = 0; i < indices.length; i++) {
|
| 318 |
+
var vi = d2c(array[indices[i]]);
|
| 319 |
+
if(vi !== BADNUM) out = Math.min(out, vi);
|
| 320 |
+
}
|
| 321 |
+
return (out === Infinity) ? BADNUM : c2d(out);
|
| 322 |
+
};
|
| 323 |
+
|
| 324 |
+
case 'max':
|
| 325 |
+
return function(array, indices) {
|
| 326 |
+
var out = -Infinity;
|
| 327 |
+
for(var i = 0; i < indices.length; i++) {
|
| 328 |
+
var vi = d2c(array[indices[i]]);
|
| 329 |
+
if(vi !== BADNUM) out = Math.max(out, vi);
|
| 330 |
+
}
|
| 331 |
+
return (out === -Infinity) ? BADNUM : c2d(out);
|
| 332 |
+
};
|
| 333 |
+
|
| 334 |
+
case 'range':
|
| 335 |
+
return function(array, indices) {
|
| 336 |
+
var min = Infinity;
|
| 337 |
+
var max = -Infinity;
|
| 338 |
+
for(var i = 0; i < indices.length; i++) {
|
| 339 |
+
var vi = d2c(array[indices[i]]);
|
| 340 |
+
if(vi !== BADNUM) {
|
| 341 |
+
min = Math.min(min, vi);
|
| 342 |
+
max = Math.max(max, vi);
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
return (max === -Infinity || min === Infinity) ? BADNUM : c2d(max - min);
|
| 346 |
+
};
|
| 347 |
+
|
| 348 |
+
case 'change':
|
| 349 |
+
return function(array, indices) {
|
| 350 |
+
var first = d2c(array[indices[0]]);
|
| 351 |
+
var last = d2c(array[indices[indices.length - 1]]);
|
| 352 |
+
return (first === BADNUM || last === BADNUM) ? BADNUM : c2d(last - first);
|
| 353 |
+
};
|
| 354 |
+
|
| 355 |
+
case 'median':
|
| 356 |
+
return function(array, indices) {
|
| 357 |
+
var sortCalc = [];
|
| 358 |
+
for(var i = 0; i < indices.length; i++) {
|
| 359 |
+
var vi = d2c(array[indices[i]]);
|
| 360 |
+
if(vi !== BADNUM) sortCalc.push(vi);
|
| 361 |
+
}
|
| 362 |
+
if(!sortCalc.length) return BADNUM;
|
| 363 |
+
sortCalc.sort(Lib.sorterAsc);
|
| 364 |
+
var mid = (sortCalc.length - 1) / 2;
|
| 365 |
+
return c2d((sortCalc[Math.floor(mid)] + sortCalc[Math.ceil(mid)]) / 2);
|
| 366 |
+
};
|
| 367 |
+
|
| 368 |
+
case 'mode':
|
| 369 |
+
return function(array, indices) {
|
| 370 |
+
var counts = {};
|
| 371 |
+
var maxCnt = 0;
|
| 372 |
+
var out = BADNUM;
|
| 373 |
+
for(var i = 0; i < indices.length; i++) {
|
| 374 |
+
var vi = d2c(array[indices[i]]);
|
| 375 |
+
if(vi !== BADNUM) {
|
| 376 |
+
var counti = counts[vi] = (counts[vi] || 0) + 1;
|
| 377 |
+
if(counti > maxCnt) {
|
| 378 |
+
maxCnt = counti;
|
| 379 |
+
out = vi;
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
return maxCnt ? c2d(out) : BADNUM;
|
| 384 |
+
};
|
| 385 |
+
|
| 386 |
+
case 'rms':
|
| 387 |
+
return function(array, indices) {
|
| 388 |
+
var total = 0;
|
| 389 |
+
var cnt = 0;
|
| 390 |
+
for(var i = 0; i < indices.length; i++) {
|
| 391 |
+
var vi = d2c(array[indices[i]]);
|
| 392 |
+
if(vi !== BADNUM) {
|
| 393 |
+
total += vi * vi;
|
| 394 |
+
cnt++;
|
| 395 |
+
}
|
| 396 |
+
}
|
| 397 |
+
return cnt ? c2d(Math.sqrt(total / cnt)) : BADNUM;
|
| 398 |
+
};
|
| 399 |
+
|
| 400 |
+
case 'stddev':
|
| 401 |
+
return function(array, indices) {
|
| 402 |
+
// balance numerical stability with performance:
|
| 403 |
+
// so that we call d2c once per element but don't need to
|
| 404 |
+
// store them, reference all to the first element
|
| 405 |
+
var total = 0;
|
| 406 |
+
var total2 = 0;
|
| 407 |
+
var cnt = 1;
|
| 408 |
+
var v0 = BADNUM;
|
| 409 |
+
var i;
|
| 410 |
+
for(i = 0; i < indices.length && v0 === BADNUM; i++) {
|
| 411 |
+
v0 = d2c(array[indices[i]]);
|
| 412 |
+
}
|
| 413 |
+
if(v0 === BADNUM) return BADNUM;
|
| 414 |
+
|
| 415 |
+
for(; i < indices.length; i++) {
|
| 416 |
+
var vi = d2c(array[indices[i]]);
|
| 417 |
+
if(vi !== BADNUM) {
|
| 418 |
+
var dv = vi - v0;
|
| 419 |
+
total += dv;
|
| 420 |
+
total2 += dv * dv;
|
| 421 |
+
cnt++;
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
// This is population std dev, if we want sample std dev
|
| 426 |
+
// we would need (...) / (cnt - 1)
|
| 427 |
+
// Also note there's no c2d here - that means for dates the result
|
| 428 |
+
// is a number of milliseconds, and for categories it's a number
|
| 429 |
+
// of category differences, which is not generically meaningful but
|
| 430 |
+
// as in other cases we don't forbid it.
|
| 431 |
+
var norm = (opts.funcmode === 'sample') ? (cnt - 1) : cnt;
|
| 432 |
+
// this is debatable: should a count of 1 return sample stddev of
|
| 433 |
+
// 0 or undefined?
|
| 434 |
+
if(!norm) return 0;
|
| 435 |
+
return Math.sqrt((total2 - (total * total / cnt)) / norm);
|
| 436 |
+
};
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
function count(array, indices) {
|
| 441 |
+
return indices.length;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
function first(array, indices) {
|
| 445 |
+
return array[indices[0]];
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
function last(array, indices) {
|
| 449 |
+
return array[indices[indices.length - 1]];
|
| 450 |
+
}
|
node_modules/plotly.js/src/transforms/filter.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../lib');
|
| 4 |
+
var Registry = require('../registry');
|
| 5 |
+
var Axes = require('../plots/cartesian/axes');
|
| 6 |
+
var pointsAccessorFunction = require('./helpers').pointsAccessorFunction;
|
| 7 |
+
|
| 8 |
+
var filterOps = require('../constants/filter_ops');
|
| 9 |
+
var COMPARISON_OPS = filterOps.COMPARISON_OPS;
|
| 10 |
+
var INTERVAL_OPS = filterOps.INTERVAL_OPS;
|
| 11 |
+
var SET_OPS = filterOps.SET_OPS;
|
| 12 |
+
|
| 13 |
+
exports.moduleType = 'transform';
|
| 14 |
+
|
| 15 |
+
exports.name = 'filter';
|
| 16 |
+
|
| 17 |
+
exports.attributes = {
|
| 18 |
+
enabled: {
|
| 19 |
+
valType: 'boolean',
|
| 20 |
+
dflt: true,
|
| 21 |
+
editType: 'calc',
|
| 22 |
+
description: [
|
| 23 |
+
'Determines whether this filter transform is enabled or disabled.'
|
| 24 |
+
].join(' ')
|
| 25 |
+
},
|
| 26 |
+
target: {
|
| 27 |
+
valType: 'string',
|
| 28 |
+
strict: true,
|
| 29 |
+
noBlank: true,
|
| 30 |
+
arrayOk: true,
|
| 31 |
+
dflt: 'x',
|
| 32 |
+
editType: 'calc',
|
| 33 |
+
description: [
|
| 34 |
+
'Sets the filter target by which the filter is applied.',
|
| 35 |
+
|
| 36 |
+
'If a string, `target` is assumed to be a reference to a data array',
|
| 37 |
+
'in the parent trace object.',
|
| 38 |
+
'To filter about nested variables, use *.* to access them.',
|
| 39 |
+
'For example, set `target` to *marker.color* to filter',
|
| 40 |
+
'about the marker color array.',
|
| 41 |
+
|
| 42 |
+
'If an array, `target` is then the data array by which the filter is applied.'
|
| 43 |
+
].join(' ')
|
| 44 |
+
},
|
| 45 |
+
operation: {
|
| 46 |
+
valType: 'enumerated',
|
| 47 |
+
values: []
|
| 48 |
+
.concat(COMPARISON_OPS)
|
| 49 |
+
.concat(INTERVAL_OPS)
|
| 50 |
+
.concat(SET_OPS),
|
| 51 |
+
dflt: '=',
|
| 52 |
+
editType: 'calc',
|
| 53 |
+
description: [
|
| 54 |
+
'Sets the filter operation.',
|
| 55 |
+
|
| 56 |
+
'*=* keeps items equal to `value`',
|
| 57 |
+
'*!=* keeps items not equal to `value`',
|
| 58 |
+
|
| 59 |
+
'*<* keeps items less than `value`',
|
| 60 |
+
'*<=* keeps items less than or equal to `value`',
|
| 61 |
+
|
| 62 |
+
'*>* keeps items greater than `value`',
|
| 63 |
+
'*>=* keeps items greater than or equal to `value`',
|
| 64 |
+
|
| 65 |
+
'*[]* keeps items inside `value[0]` to `value[1]` including both bounds',
|
| 66 |
+
'*()* keeps items inside `value[0]` to `value[1]` excluding both bounds',
|
| 67 |
+
'*[)* keeps items inside `value[0]` to `value[1]` including `value[0]` but excluding `value[1]',
|
| 68 |
+
'*(]* keeps items inside `value[0]` to `value[1]` excluding `value[0]` but including `value[1]',
|
| 69 |
+
|
| 70 |
+
'*][* keeps items outside `value[0]` to `value[1]` and equal to both bounds',
|
| 71 |
+
'*)(* keeps items outside `value[0]` to `value[1]`',
|
| 72 |
+
'*](* keeps items outside `value[0]` to `value[1]` and equal to `value[0]`',
|
| 73 |
+
'*)[* keeps items outside `value[0]` to `value[1]` and equal to `value[1]`',
|
| 74 |
+
|
| 75 |
+
'*{}* keeps items present in a set of values',
|
| 76 |
+
'*}{* keeps items not present in a set of values'
|
| 77 |
+
].join(' ')
|
| 78 |
+
},
|
| 79 |
+
value: {
|
| 80 |
+
valType: 'any',
|
| 81 |
+
dflt: 0,
|
| 82 |
+
editType: 'calc',
|
| 83 |
+
description: [
|
| 84 |
+
'Sets the value or values by which to filter.',
|
| 85 |
+
|
| 86 |
+
'Values are expected to be in the same type as the data linked',
|
| 87 |
+
'to `target`.',
|
| 88 |
+
|
| 89 |
+
'When `operation` is set to one of',
|
| 90 |
+
'the comparison values (' + COMPARISON_OPS + ')',
|
| 91 |
+
'`value` is expected to be a number or a string.',
|
| 92 |
+
|
| 93 |
+
'When `operation` is set to one of the interval values',
|
| 94 |
+
'(' + INTERVAL_OPS + ')',
|
| 95 |
+
'`value` is expected to be 2-item array where the first item',
|
| 96 |
+
'is the lower bound and the second item is the upper bound.',
|
| 97 |
+
|
| 98 |
+
'When `operation`, is set to one of the set values',
|
| 99 |
+
'(' + SET_OPS + ')',
|
| 100 |
+
'`value` is expected to be an array with as many items as',
|
| 101 |
+
'the desired set elements.'
|
| 102 |
+
].join(' ')
|
| 103 |
+
},
|
| 104 |
+
preservegaps: {
|
| 105 |
+
valType: 'boolean',
|
| 106 |
+
dflt: false,
|
| 107 |
+
editType: 'calc',
|
| 108 |
+
description: [
|
| 109 |
+
'Determines whether or not gaps in data arrays produced by the filter operation',
|
| 110 |
+
'are preserved.',
|
| 111 |
+
'Setting this to *true* might be useful when plotting a line chart',
|
| 112 |
+
'with `connectgaps` set to *false*.'
|
| 113 |
+
].join(' ')
|
| 114 |
+
},
|
| 115 |
+
editType: 'calc'
|
| 116 |
+
};
|
| 117 |
+
|
| 118 |
+
exports.supplyDefaults = function(transformIn) {
|
| 119 |
+
var transformOut = {};
|
| 120 |
+
|
| 121 |
+
function coerce(attr, dflt) {
|
| 122 |
+
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
var enabled = coerce('enabled');
|
| 126 |
+
|
| 127 |
+
if(enabled) {
|
| 128 |
+
var target = coerce('target');
|
| 129 |
+
|
| 130 |
+
if(Lib.isArrayOrTypedArray(target) && target.length === 0) {
|
| 131 |
+
transformOut.enabled = false;
|
| 132 |
+
return transformOut;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
coerce('preservegaps');
|
| 136 |
+
coerce('operation');
|
| 137 |
+
coerce('value');
|
| 138 |
+
|
| 139 |
+
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleDefaults');
|
| 140 |
+
handleCalendarDefaults(transformIn, transformOut, 'valuecalendar', null);
|
| 141 |
+
handleCalendarDefaults(transformIn, transformOut, 'targetcalendar', null);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
return transformOut;
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
exports.calcTransform = function(gd, trace, opts) {
|
| 148 |
+
if(!opts.enabled) return;
|
| 149 |
+
|
| 150 |
+
var targetArray = Lib.getTargetArray(trace, opts);
|
| 151 |
+
if(!targetArray) return;
|
| 152 |
+
|
| 153 |
+
var target = opts.target;
|
| 154 |
+
|
| 155 |
+
var len = targetArray.length;
|
| 156 |
+
if(trace._length) len = Math.min(len, trace._length);
|
| 157 |
+
|
| 158 |
+
var targetCalendar = opts.targetcalendar;
|
| 159 |
+
var arrayAttrs = trace._arrayAttrs;
|
| 160 |
+
var preservegaps = opts.preservegaps;
|
| 161 |
+
|
| 162 |
+
// even if you provide targetcalendar, if target is a string and there
|
| 163 |
+
// is a calendar attribute matching target it will get used instead.
|
| 164 |
+
if(typeof target === 'string') {
|
| 165 |
+
var attrTargetCalendar = Lib.nestedProperty(trace, target + 'calendar').get();
|
| 166 |
+
if(attrTargetCalendar) targetCalendar = attrTargetCalendar;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray);
|
| 170 |
+
var filterFunc = getFilterFunc(opts, d2c, targetCalendar);
|
| 171 |
+
var originalArrays = {};
|
| 172 |
+
var indexToPoints = {};
|
| 173 |
+
var index = 0;
|
| 174 |
+
|
| 175 |
+
function forAllAttrs(fn, index) {
|
| 176 |
+
for(var j = 0; j < arrayAttrs.length; j++) {
|
| 177 |
+
var np = Lib.nestedProperty(trace, arrayAttrs[j]);
|
| 178 |
+
fn(np, index);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
var initFn;
|
| 183 |
+
var fillFn;
|
| 184 |
+
if(preservegaps) {
|
| 185 |
+
initFn = function(np) {
|
| 186 |
+
originalArrays[np.astr] = Lib.extendDeep([], np.get());
|
| 187 |
+
np.set(new Array(len));
|
| 188 |
+
};
|
| 189 |
+
fillFn = function(np, index) {
|
| 190 |
+
var val = originalArrays[np.astr][index];
|
| 191 |
+
np.get()[index] = val;
|
| 192 |
+
};
|
| 193 |
+
} else {
|
| 194 |
+
initFn = function(np) {
|
| 195 |
+
originalArrays[np.astr] = Lib.extendDeep([], np.get());
|
| 196 |
+
np.set([]);
|
| 197 |
+
};
|
| 198 |
+
fillFn = function(np, index) {
|
| 199 |
+
var val = originalArrays[np.astr][index];
|
| 200 |
+
np.get().push(val);
|
| 201 |
+
};
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
// copy all original array attribute values, and clear arrays in trace
|
| 205 |
+
forAllAttrs(initFn);
|
| 206 |
+
|
| 207 |
+
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
|
| 208 |
+
|
| 209 |
+
// loop through filter array, fill trace arrays if passed
|
| 210 |
+
for(var i = 0; i < len; i++) {
|
| 211 |
+
var passed = filterFunc(targetArray[i]);
|
| 212 |
+
if(passed) {
|
| 213 |
+
forAllAttrs(fillFn, i);
|
| 214 |
+
indexToPoints[index++] = originalPointsAccessor(i);
|
| 215 |
+
} else if(preservegaps) index++;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
opts._indexToPoints = indexToPoints;
|
| 219 |
+
trace._length = index;
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
function getFilterFunc(opts, d2c, targetCalendar) {
|
| 223 |
+
var operation = opts.operation;
|
| 224 |
+
var value = opts.value;
|
| 225 |
+
var hasArrayValue = Lib.isArrayOrTypedArray(value);
|
| 226 |
+
|
| 227 |
+
function isOperationIn(array) {
|
| 228 |
+
return array.indexOf(operation) !== -1;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
var d2cValue = function(v) { return d2c(v, 0, opts.valuecalendar); };
|
| 232 |
+
var d2cTarget = function(v) { return d2c(v, 0, targetCalendar); };
|
| 233 |
+
|
| 234 |
+
var coercedValue;
|
| 235 |
+
|
| 236 |
+
if(isOperationIn(COMPARISON_OPS)) {
|
| 237 |
+
coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value);
|
| 238 |
+
} else if(isOperationIn(INTERVAL_OPS)) {
|
| 239 |
+
coercedValue = hasArrayValue ?
|
| 240 |
+
[d2cValue(value[0]), d2cValue(value[1])] :
|
| 241 |
+
[d2cValue(value), d2cValue(value)];
|
| 242 |
+
} else if(isOperationIn(SET_OPS)) {
|
| 243 |
+
coercedValue = hasArrayValue ? value.map(d2cValue) : [d2cValue(value)];
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
switch(operation) {
|
| 247 |
+
case '=':
|
| 248 |
+
return function(v) { return d2cTarget(v) === coercedValue; };
|
| 249 |
+
|
| 250 |
+
case '!=':
|
| 251 |
+
return function(v) { return d2cTarget(v) !== coercedValue; };
|
| 252 |
+
|
| 253 |
+
case '<':
|
| 254 |
+
return function(v) { return d2cTarget(v) < coercedValue; };
|
| 255 |
+
|
| 256 |
+
case '<=':
|
| 257 |
+
return function(v) { return d2cTarget(v) <= coercedValue; };
|
| 258 |
+
|
| 259 |
+
case '>':
|
| 260 |
+
return function(v) { return d2cTarget(v) > coercedValue; };
|
| 261 |
+
|
| 262 |
+
case '>=':
|
| 263 |
+
return function(v) { return d2cTarget(v) >= coercedValue; };
|
| 264 |
+
|
| 265 |
+
case '[]':
|
| 266 |
+
return function(v) {
|
| 267 |
+
var cv = d2cTarget(v);
|
| 268 |
+
return cv >= coercedValue[0] && cv <= coercedValue[1];
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
case '()':
|
| 272 |
+
return function(v) {
|
| 273 |
+
var cv = d2cTarget(v);
|
| 274 |
+
return cv > coercedValue[0] && cv < coercedValue[1];
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
case '[)':
|
| 278 |
+
return function(v) {
|
| 279 |
+
var cv = d2cTarget(v);
|
| 280 |
+
return cv >= coercedValue[0] && cv < coercedValue[1];
|
| 281 |
+
};
|
| 282 |
+
|
| 283 |
+
case '(]':
|
| 284 |
+
return function(v) {
|
| 285 |
+
var cv = d2cTarget(v);
|
| 286 |
+
return cv > coercedValue[0] && cv <= coercedValue[1];
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
case '][':
|
| 290 |
+
return function(v) {
|
| 291 |
+
var cv = d2cTarget(v);
|
| 292 |
+
return cv <= coercedValue[0] || cv >= coercedValue[1];
|
| 293 |
+
};
|
| 294 |
+
|
| 295 |
+
case ')(':
|
| 296 |
+
return function(v) {
|
| 297 |
+
var cv = d2cTarget(v);
|
| 298 |
+
return cv < coercedValue[0] || cv > coercedValue[1];
|
| 299 |
+
};
|
| 300 |
+
|
| 301 |
+
case '](':
|
| 302 |
+
return function(v) {
|
| 303 |
+
var cv = d2cTarget(v);
|
| 304 |
+
return cv <= coercedValue[0] || cv > coercedValue[1];
|
| 305 |
+
};
|
| 306 |
+
|
| 307 |
+
case ')[':
|
| 308 |
+
return function(v) {
|
| 309 |
+
var cv = d2cTarget(v);
|
| 310 |
+
return cv < coercedValue[0] || cv >= coercedValue[1];
|
| 311 |
+
};
|
| 312 |
+
|
| 313 |
+
case '{}':
|
| 314 |
+
return function(v) {
|
| 315 |
+
return coercedValue.indexOf(d2cTarget(v)) !== -1;
|
| 316 |
+
};
|
| 317 |
+
|
| 318 |
+
case '}{':
|
| 319 |
+
return function(v) {
|
| 320 |
+
return coercedValue.indexOf(d2cTarget(v)) === -1;
|
| 321 |
+
};
|
| 322 |
+
}
|
| 323 |
+
}
|
node_modules/plotly.js/src/transforms/groupby.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../lib');
|
| 4 |
+
var PlotSchema = require('../plot_api/plot_schema');
|
| 5 |
+
var Plots = require('../plots/plots');
|
| 6 |
+
var pointsAccessorFunction = require('./helpers').pointsAccessorFunction;
|
| 7 |
+
|
| 8 |
+
exports.moduleType = 'transform';
|
| 9 |
+
|
| 10 |
+
exports.name = 'groupby';
|
| 11 |
+
|
| 12 |
+
exports.attributes = {
|
| 13 |
+
enabled: {
|
| 14 |
+
valType: 'boolean',
|
| 15 |
+
dflt: true,
|
| 16 |
+
editType: 'calc',
|
| 17 |
+
description: [
|
| 18 |
+
'Determines whether this group-by transform is enabled or disabled.'
|
| 19 |
+
].join(' ')
|
| 20 |
+
},
|
| 21 |
+
groups: {
|
| 22 |
+
valType: 'data_array',
|
| 23 |
+
dflt: [],
|
| 24 |
+
editType: 'calc',
|
| 25 |
+
description: [
|
| 26 |
+
'Sets the groups in which the trace data will be split.',
|
| 27 |
+
'For example, with `x` set to *[1, 2, 3, 4]* and',
|
| 28 |
+
'`groups` set to *[\'a\', \'b\', \'a\', \'b\']*,',
|
| 29 |
+
'the groupby transform with split in one trace',
|
| 30 |
+
'with `x` [1, 3] and one trace with `x` [2, 4].'
|
| 31 |
+
].join(' ')
|
| 32 |
+
},
|
| 33 |
+
nameformat: {
|
| 34 |
+
valType: 'string',
|
| 35 |
+
editType: 'calc',
|
| 36 |
+
description: [
|
| 37 |
+
'Pattern by which grouped traces are named. If only one trace is present,',
|
| 38 |
+
'defaults to the group name (`"%{group}"`), otherwise defaults to the group name',
|
| 39 |
+
'with trace name (`"%{group} (%{trace})"`). Available escape sequences are `%{group}`, which',
|
| 40 |
+
'inserts the group name, and `%{trace}`, which inserts the trace name. If grouping',
|
| 41 |
+
'GDP data by country when more than one trace is present, for example, the',
|
| 42 |
+
'default "%{group} (%{trace})" would return "Monaco (GDP per capita)".'
|
| 43 |
+
].join(' ')
|
| 44 |
+
},
|
| 45 |
+
styles: {
|
| 46 |
+
_isLinkedToArray: 'style',
|
| 47 |
+
target: {
|
| 48 |
+
valType: 'string',
|
| 49 |
+
editType: 'calc',
|
| 50 |
+
description: [
|
| 51 |
+
'The group value which receives these styles.'
|
| 52 |
+
].join(' ')
|
| 53 |
+
},
|
| 54 |
+
value: {
|
| 55 |
+
valType: 'any',
|
| 56 |
+
dflt: {},
|
| 57 |
+
editType: 'calc',
|
| 58 |
+
description: [
|
| 59 |
+
'Sets each group styles.',
|
| 60 |
+
'For example, with `groups` set to *[\'a\', \'b\', \'a\', \'b\']*',
|
| 61 |
+
'and `styles` set to *[{target: \'a\', value: { marker: { color: \'red\' } }}]',
|
| 62 |
+
'marker points in group *\'a\'* will be drawn in red.'
|
| 63 |
+
].join(' '),
|
| 64 |
+
_compareAsJSON: true
|
| 65 |
+
},
|
| 66 |
+
editType: 'calc'
|
| 67 |
+
},
|
| 68 |
+
editType: 'calc'
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Supply transform attributes defaults
|
| 73 |
+
*
|
| 74 |
+
* @param {object} transformIn
|
| 75 |
+
* object linked to trace.transforms[i] with 'type' set to exports.name
|
| 76 |
+
* @param {object} traceOut
|
| 77 |
+
* the _fullData trace this transform applies to
|
| 78 |
+
* @param {object} layout
|
| 79 |
+
* the plot's (not-so-full) layout
|
| 80 |
+
* @param {object} traceIn
|
| 81 |
+
* the input data trace this transform applies to
|
| 82 |
+
*
|
| 83 |
+
* @return {object} transformOut
|
| 84 |
+
* copy of transformIn that contains attribute defaults
|
| 85 |
+
*/
|
| 86 |
+
exports.supplyDefaults = function(transformIn, traceOut, layout) {
|
| 87 |
+
var i;
|
| 88 |
+
var transformOut = {};
|
| 89 |
+
|
| 90 |
+
function coerce(attr, dflt) {
|
| 91 |
+
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
var enabled = coerce('enabled');
|
| 95 |
+
|
| 96 |
+
if(!enabled) return transformOut;
|
| 97 |
+
|
| 98 |
+
coerce('groups');
|
| 99 |
+
coerce('nameformat', layout._dataLength > 1 ? '%{group} (%{trace})' : '%{group}');
|
| 100 |
+
|
| 101 |
+
var styleIn = transformIn.styles;
|
| 102 |
+
var styleOut = transformOut.styles = [];
|
| 103 |
+
|
| 104 |
+
if(styleIn) {
|
| 105 |
+
for(i = 0; i < styleIn.length; i++) {
|
| 106 |
+
var thisStyle = styleOut[i] = {};
|
| 107 |
+
Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'target');
|
| 108 |
+
var value = Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'value');
|
| 109 |
+
|
| 110 |
+
// so that you can edit value in place and have Plotly.react notice it, or
|
| 111 |
+
// rebuild it every time and have Plotly.react NOT think it changed:
|
| 112 |
+
// use _compareAsJSON to say we should diff the _JSON_value
|
| 113 |
+
if(Lib.isPlainObject(value)) thisStyle.value = Lib.extendDeep({}, value);
|
| 114 |
+
else if(value) delete thisStyle.value;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
return transformOut;
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* Apply transform !!!
|
| 124 |
+
*
|
| 125 |
+
* @param {array} data
|
| 126 |
+
* array of transformed traces (is [fullTrace] upon first transform)
|
| 127 |
+
*
|
| 128 |
+
* @param {object} state
|
| 129 |
+
* state object which includes:
|
| 130 |
+
* - transform {object} full transform attributes
|
| 131 |
+
* - fullTrace {object} full trace object which is being transformed
|
| 132 |
+
* - fullData {array} full pre-transform(s) data array
|
| 133 |
+
* - layout {object} the plot's (not-so-full) layout
|
| 134 |
+
*
|
| 135 |
+
* @return {object} newData
|
| 136 |
+
* array of transformed traces
|
| 137 |
+
*/
|
| 138 |
+
exports.transform = function(data, state) {
|
| 139 |
+
var newTraces, i, j;
|
| 140 |
+
var newData = [];
|
| 141 |
+
|
| 142 |
+
for(i = 0; i < data.length; i++) {
|
| 143 |
+
newTraces = transformOne(data[i], state);
|
| 144 |
+
|
| 145 |
+
for(j = 0; j < newTraces.length; j++) {
|
| 146 |
+
newData.push(newTraces[j]);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
return newData;
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
function transformOne(trace, state) {
|
| 154 |
+
var i, j, k, attr, srcArray, groupName, newTrace, transforms, arrayLookup;
|
| 155 |
+
var groupNameObj;
|
| 156 |
+
|
| 157 |
+
var opts = state.transform;
|
| 158 |
+
var transformIndex = state.transformIndex;
|
| 159 |
+
var groups = trace.transforms[transformIndex].groups;
|
| 160 |
+
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
|
| 161 |
+
|
| 162 |
+
if(!(Lib.isArrayOrTypedArray(groups)) || groups.length === 0) {
|
| 163 |
+
return [trace];
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
var groupNames = Lib.filterUnique(groups);
|
| 167 |
+
var newData = new Array(groupNames.length);
|
| 168 |
+
var len = groups.length;
|
| 169 |
+
|
| 170 |
+
var arrayAttrs = PlotSchema.findArrayAttributes(trace);
|
| 171 |
+
|
| 172 |
+
var styles = opts.styles || [];
|
| 173 |
+
var styleLookup = {};
|
| 174 |
+
for(i = 0; i < styles.length; i++) {
|
| 175 |
+
styleLookup[styles[i].target] = styles[i].value;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
if(opts.styles) {
|
| 179 |
+
groupNameObj = Lib.keyedContainer(opts, 'styles', 'target', 'value.name');
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
// An index to map group name --> expanded trace index
|
| 183 |
+
var indexLookup = {};
|
| 184 |
+
var indexCnts = {};
|
| 185 |
+
|
| 186 |
+
for(i = 0; i < groupNames.length; i++) {
|
| 187 |
+
groupName = groupNames[i];
|
| 188 |
+
indexLookup[groupName] = i;
|
| 189 |
+
indexCnts[groupName] = 0;
|
| 190 |
+
|
| 191 |
+
// Start with a deep extend that just copies array references.
|
| 192 |
+
newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace);
|
| 193 |
+
newTrace._group = groupName;
|
| 194 |
+
newTrace.transforms[transformIndex]._indexToPoints = {};
|
| 195 |
+
|
| 196 |
+
var suppliedName = null;
|
| 197 |
+
if(groupNameObj) {
|
| 198 |
+
suppliedName = groupNameObj.get(groupName);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
if(suppliedName || suppliedName === '') {
|
| 202 |
+
newTrace.name = suppliedName;
|
| 203 |
+
} else {
|
| 204 |
+
newTrace.name = Lib.templateString(opts.nameformat, {
|
| 205 |
+
trace: trace.name,
|
| 206 |
+
group: groupName
|
| 207 |
+
});
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
// In order for groups to apply correctly to other transform data (e.g.
|
| 211 |
+
// a filter transform), we have to break the connection and clone the
|
| 212 |
+
// transforms so that each group writes grouped values into a different
|
| 213 |
+
// destination. This function does not break the array reference
|
| 214 |
+
// connection between the split transforms it creates. That's handled in
|
| 215 |
+
// initialize, which creates a new empty array for each arrayAttr.
|
| 216 |
+
transforms = newTrace.transforms;
|
| 217 |
+
newTrace.transforms = [];
|
| 218 |
+
for(j = 0; j < transforms.length; j++) {
|
| 219 |
+
newTrace.transforms[j] = Lib.extendDeepNoArrays({}, transforms[j]);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
// Initialize empty arrays for the arrayAttrs, to be split in the next step
|
| 223 |
+
for(j = 0; j < arrayAttrs.length; j++) {
|
| 224 |
+
Lib.nestedProperty(newTrace, arrayAttrs[j]).set([]);
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// For each array attribute including those nested inside this and other
|
| 229 |
+
// transforms (small note that we technically only need to do this for
|
| 230 |
+
// transforms that have not yet been applied):
|
| 231 |
+
for(k = 0; k < arrayAttrs.length; k++) {
|
| 232 |
+
attr = arrayAttrs[k];
|
| 233 |
+
|
| 234 |
+
// Cache all the arrays to which we'll push:
|
| 235 |
+
for(j = 0, arrayLookup = []; j < groupNames.length; j++) {
|
| 236 |
+
arrayLookup[j] = Lib.nestedProperty(newData[j], attr).get();
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
// Get the input data:
|
| 240 |
+
srcArray = Lib.nestedProperty(trace, attr).get();
|
| 241 |
+
|
| 242 |
+
// Send each data point to the appropriate expanded trace:
|
| 243 |
+
for(j = 0; j < len; j++) {
|
| 244 |
+
// Map group data --> trace index --> array and push data onto it
|
| 245 |
+
arrayLookup[indexLookup[groups[j]]].push(srcArray[j]);
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
for(j = 0; j < len; j++) {
|
| 250 |
+
newTrace = newData[indexLookup[groups[j]]];
|
| 251 |
+
|
| 252 |
+
var indexToPoints = newTrace.transforms[transformIndex]._indexToPoints;
|
| 253 |
+
indexToPoints[indexCnts[groups[j]]] = originalPointsAccessor(j);
|
| 254 |
+
indexCnts[groups[j]]++;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
for(i = 0; i < groupNames.length; i++) {
|
| 258 |
+
groupName = groupNames[i];
|
| 259 |
+
newTrace = newData[i];
|
| 260 |
+
|
| 261 |
+
Plots.clearExpandedTraceDefaultColors(newTrace);
|
| 262 |
+
|
| 263 |
+
// there's no need to coerce styleLookup[groupName] here
|
| 264 |
+
// as another round of supplyDefaults is done on the transformed traces
|
| 265 |
+
newTrace = Lib.extendDeepNoArrays(newTrace, styleLookup[groupName] || {});
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
return newData;
|
| 269 |
+
}
|
node_modules/plotly.js/src/transforms/helpers.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
exports.pointsAccessorFunction = function(transforms, opts) {
|
| 4 |
+
var tr;
|
| 5 |
+
var prevIndexToPoints;
|
| 6 |
+
for(var i = 0; i < transforms.length; i++) {
|
| 7 |
+
tr = transforms[i];
|
| 8 |
+
if(tr === opts) break;
|
| 9 |
+
if(!tr._indexToPoints || tr.enabled === false) continue;
|
| 10 |
+
prevIndexToPoints = tr._indexToPoints;
|
| 11 |
+
}
|
| 12 |
+
var originalPointsAccessor = prevIndexToPoints ?
|
| 13 |
+
function(i) {return prevIndexToPoints[i];} :
|
| 14 |
+
function(i) {return [i];};
|
| 15 |
+
return originalPointsAccessor;
|
| 16 |
+
};
|
node_modules/plotly.js/src/transforms/sort.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var Lib = require('../lib');
|
| 4 |
+
var Axes = require('../plots/cartesian/axes');
|
| 5 |
+
var pointsAccessorFunction = require('./helpers').pointsAccessorFunction;
|
| 6 |
+
|
| 7 |
+
var BADNUM = require('../constants/numerical').BADNUM;
|
| 8 |
+
|
| 9 |
+
exports.moduleType = 'transform';
|
| 10 |
+
|
| 11 |
+
exports.name = 'sort';
|
| 12 |
+
|
| 13 |
+
exports.attributes = {
|
| 14 |
+
enabled: {
|
| 15 |
+
valType: 'boolean',
|
| 16 |
+
dflt: true,
|
| 17 |
+
editType: 'calc',
|
| 18 |
+
description: [
|
| 19 |
+
'Determines whether this sort transform is enabled or disabled.'
|
| 20 |
+
].join(' ')
|
| 21 |
+
},
|
| 22 |
+
target: {
|
| 23 |
+
valType: 'string',
|
| 24 |
+
strict: true,
|
| 25 |
+
noBlank: true,
|
| 26 |
+
arrayOk: true,
|
| 27 |
+
dflt: 'x',
|
| 28 |
+
editType: 'calc',
|
| 29 |
+
description: [
|
| 30 |
+
'Sets the target by which the sort transform is applied.',
|
| 31 |
+
|
| 32 |
+
'If a string, *target* is assumed to be a reference to a data array',
|
| 33 |
+
'in the parent trace object.',
|
| 34 |
+
'To sort about nested variables, use *.* to access them.',
|
| 35 |
+
'For example, set `target` to *marker.size* to sort',
|
| 36 |
+
'about the marker size array.',
|
| 37 |
+
|
| 38 |
+
'If an array, *target* is then the data array by which',
|
| 39 |
+
'the sort transform is applied.'
|
| 40 |
+
].join(' ')
|
| 41 |
+
},
|
| 42 |
+
order: {
|
| 43 |
+
valType: 'enumerated',
|
| 44 |
+
values: ['ascending', 'descending'],
|
| 45 |
+
dflt: 'ascending',
|
| 46 |
+
editType: 'calc',
|
| 47 |
+
description: [
|
| 48 |
+
'Sets the sort transform order.'
|
| 49 |
+
].join(' ')
|
| 50 |
+
},
|
| 51 |
+
editType: 'calc'
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
exports.supplyDefaults = function(transformIn) {
|
| 55 |
+
var transformOut = {};
|
| 56 |
+
|
| 57 |
+
function coerce(attr, dflt) {
|
| 58 |
+
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
var enabled = coerce('enabled');
|
| 62 |
+
|
| 63 |
+
if(enabled) {
|
| 64 |
+
coerce('target');
|
| 65 |
+
coerce('order');
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
return transformOut;
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
exports.calcTransform = function(gd, trace, opts) {
|
| 72 |
+
if(!opts.enabled) return;
|
| 73 |
+
|
| 74 |
+
var targetArray = Lib.getTargetArray(trace, opts);
|
| 75 |
+
if(!targetArray) return;
|
| 76 |
+
|
| 77 |
+
var target = opts.target;
|
| 78 |
+
|
| 79 |
+
var len = targetArray.length;
|
| 80 |
+
if(trace._length) len = Math.min(len, trace._length);
|
| 81 |
+
|
| 82 |
+
var arrayAttrs = trace._arrayAttrs;
|
| 83 |
+
var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray);
|
| 84 |
+
var indices = getIndices(opts, targetArray, d2c, len);
|
| 85 |
+
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
|
| 86 |
+
var indexToPoints = {};
|
| 87 |
+
var i, j;
|
| 88 |
+
|
| 89 |
+
for(i = 0; i < arrayAttrs.length; i++) {
|
| 90 |
+
var np = Lib.nestedProperty(trace, arrayAttrs[i]);
|
| 91 |
+
var arrayOld = np.get();
|
| 92 |
+
var arrayNew = new Array(len);
|
| 93 |
+
|
| 94 |
+
for(j = 0; j < len; j++) {
|
| 95 |
+
arrayNew[j] = arrayOld[indices[j]];
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
np.set(arrayNew);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
for(j = 0; j < len; j++) {
|
| 102 |
+
indexToPoints[j] = originalPointsAccessor(indices[j]);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
opts._indexToPoints = indexToPoints;
|
| 106 |
+
trace._length = len;
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
function getIndices(opts, targetArray, d2c, len) {
|
| 110 |
+
var sortedArray = new Array(len);
|
| 111 |
+
var indices = new Array(len);
|
| 112 |
+
var i;
|
| 113 |
+
|
| 114 |
+
for(i = 0; i < len; i++) {
|
| 115 |
+
sortedArray[i] = {v: targetArray[i], i: i};
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
sortedArray.sort(getSortFunc(opts, d2c));
|
| 119 |
+
|
| 120 |
+
for(i = 0; i < len; i++) {
|
| 121 |
+
indices[i] = sortedArray[i].i;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
return indices;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function getSortFunc(opts, d2c) {
|
| 128 |
+
switch(opts.order) {
|
| 129 |
+
case 'ascending':
|
| 130 |
+
return function(a, b) {
|
| 131 |
+
var ac = d2c(a.v);
|
| 132 |
+
var bc = d2c(b.v);
|
| 133 |
+
if(ac === BADNUM) {
|
| 134 |
+
return 1;
|
| 135 |
+
}
|
| 136 |
+
if(bc === BADNUM) {
|
| 137 |
+
return -1;
|
| 138 |
+
}
|
| 139 |
+
return ac - bc;
|
| 140 |
+
};
|
| 141 |
+
case 'descending':
|
| 142 |
+
return function(a, b) {
|
| 143 |
+
var ac = d2c(a.v);
|
| 144 |
+
var bc = d2c(b.v);
|
| 145 |
+
if(ac === BADNUM) {
|
| 146 |
+
return 1;
|
| 147 |
+
}
|
| 148 |
+
if(bc === BADNUM) {
|
| 149 |
+
return -1;
|
| 150 |
+
}
|
| 151 |
+
return bc - ac;
|
| 152 |
+
};
|
| 153 |
+
}
|
| 154 |
+
}
|
node_modules/plotly.js/src/version.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// package version injected by `npm run preprocess`
|
| 4 |
+
exports.version = '2.30.0';
|
node_modules/plotly.js/stackgl_modules/index.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|