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

Function initBase

src/traces/bar/cross_trace_calc.js:181–225  ·  view source on GitHub ↗
(sa, calcTraces)

Source from the content-addressed store, hash-verified

179}
180
181function initBase(sa, calcTraces) {
182 var i, j;
183
184 for (i = 0; i < calcTraces.length; i++) {
185 var cd = calcTraces[i];
186 var trace = cd[0].trace;
187 var base = trace.type === 'funnel' ? trace._base : trace.base;
188 var b;
189
190 // not sure if it really makes sense to have dates for bar size data...
191 // ideally if we want to make gantt charts or something we'd treat
192 // the actual size (trace.x or y) as time delta but base as absolute
193 // time. But included here for completeness.
194 var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar;
195
196 // 'base' on categorical axes makes no sense
197 var d2c =
198 sa.type === 'category' || sa.type === 'multicategory'
199 ? function () {
200 return null;
201 }
202 : sa.d2c;
203
204 if (isArrayOrTypedArray(base)) {
205 for (j = 0; j < Math.min(base.length, cd.length); j++) {
206 b = d2c(base[j], 0, scalendar);
207 if (isNumeric(b)) {
208 cd[j].b = +b;
209 cd[j].hasB = 1;
210 } else cd[j].b = 0;
211 }
212 for (; j < cd.length; j++) {
213 cd[j].b = 0;
214 }
215 } else {
216 b = d2c(base, 0, scalendar);
217 var hasBase = isNumeric(b);
218 b = hasBase ? b : 0;
219 for (j = 0; j < cd.length; j++) {
220 cd[j].b = b;
221 if (hasBase) cd[j].hasB = 1;
222 }
223 }
224 }
225}
226
227function setGroupPositionsInOverlayMode(gd, pa, sa, calcTraces, opts) {
228 // update position axis and set bar offsets and widths

Callers 1

setGroupPositionsFunction · 0.85

Calls 2

isArrayOrTypedArrayFunction · 0.50
d2cFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…