MCPcopy Index your code
hub / github.com/plotly/plotly.js / extractScale

Function extractScale

src/components/colorscale/helpers.js:115–135  ·  view source on GitHub ↗

* Extract colorscale into numeric domain and color range. * * @param {object} cont colorscale container (e.g. trace, marker) * - colorscale {array of arrays} * - cmin/zmin {number} * - cmax/zmax {number} * - reversescale {boolean} * * @return {object} * - domain {array} * - range {ar

(cont)

Source from the content-addressed store, hash-verified

113 * - range {array}
114 */
115function extractScale(cont) {
116 var cOpts = extractOpts(cont);
117 var cmin = cOpts.min;
118 var cmax = cOpts.max;
119
120 var scl = cOpts.reversescale ?
121 flipScale(cOpts.colorscale) :
122 cOpts.colorscale;
123
124 var N = scl.length;
125 var domain = new Array(N);
126 var range = new Array(N);
127
128 for(var i = 0; i < N; i++) {
129 var si = scl[i];
130 domain[i] = cmin + si[0] * (cmax - cmin);
131 range[i] = si[1];
132 }
133
134 return {domain: domain, range: range};
135}
136
137function flipScale(scl) {
138 var N = scl.length;

Callers 1

Calls 2

extractOptsFunction · 0.85
flipScaleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…