MCPcopy Create free account
hub / github.com/plotly/plotly.js / dimensionDefaults

Function dimensionDefaults

src/traces/parcats/defaults.js:31–69  ·  view source on GitHub ↗
(dimensionIn, dimensionOut)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

coerceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…