MCPcopy
hub / github.com/plotly/plotly.js / _calc

Function _calc

test/jasmine/tests/histogram_test.js:557–594  ·  view source on GitHub ↗
(opts, extraTraces, layout, prependExtras)

Source from the content-addressed store, hash-verified

555
556 describe('calc', function() {
557 function _calc(opts, extraTraces, layout, prependExtras) {
558 var base = { type: 'histogram' };
559 var trace = Lib.extendFlat({}, base, opts);
560 var gd = { data: prependExtras ? [] : [trace] };
561
562 if(layout) gd.layout = layout;
563
564 if(Array.isArray(extraTraces)) {
565 extraTraces.forEach(function(extraTrace) {
566 gd.data.push(Lib.extendFlat({}, base, extraTrace));
567 });
568 }
569
570 if(prependExtras) gd.data.push(trace);
571
572 supplyAllDefaults(gd);
573 var fullTrace = gd._fullData[prependExtras ? gd._fullData.length - 1 : 0];
574
575 if(prependExtras) {
576 for(var i = 0; i < gd._fullData.length - 1; i++) {
577 calc(gd, gd._fullData[i]);
578 }
579 }
580
581 var out = calc(gd, fullTrace);
582 delete out[0].trace;
583
584 // this is dumb - but some of the `ph0` values are `-0` which doesn't match `0`
585 // even though -0 === 0
586 out.forEach(function(cdi) {
587 for(var key in cdi) {
588 if(typeof cdi[key] === 'function') cdi[key] = cdi[key]();
589 if(cdi[key] === 0) cdi[key] = 0;
590 }
591 });
592
593 return out;
594 }
595
596 var oneDay = 24 * 3600000;
597

Callers 2

histogram_test.jsFile · 0.70
calcPositionsFunction · 0.70

Calls 1

calcFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…