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

Function calc

src/traces/barpolar/calc.js:12–67  ·  view source on GitHub ↗
(gd, trace)

Source from the content-addressed store, hash-verified

10var extendFlat = require('../../lib').extendFlat;
11
12function calc(gd, trace) {
13 var fullLayout = gd._fullLayout;
14 var subplotId = trace.subplot;
15 var radialAxis = fullLayout[subplotId].radialaxis;
16 var angularAxis = fullLayout[subplotId].angularaxis;
17 var rArray = radialAxis.makeCalcdata(trace, 'r');
18 var thetaArray = angularAxis.makeCalcdata(trace, 'theta');
19 var len = trace._length;
20 var cd = new Array(len);
21
22 // 'size' axis variables
23 var sArray = rArray;
24 // 'pos' axis variables
25 var pArray = thetaArray;
26
27 for(var i = 0; i < len; i++) {
28 cd[i] = {p: pArray[i], s: sArray[i]};
29 }
30
31 // convert width and offset in 'c' coordinate,
32 // set 'c' value(s) in trace._width and trace._offset,
33 // to make Bar.crossTraceCalc "just work"
34 function d2c(attr) {
35 var val = trace[attr];
36 if(val !== undefined) {
37 trace['_' + attr] = isArrayOrTypedArray(val) ?
38 angularAxis.makeCalcdata(trace, attr) :
39 angularAxis.d2c(val, trace.thetaunit);
40 }
41 }
42
43 if(angularAxis.type === 'linear') {
44 d2c('width');
45 d2c('offset');
46 }
47
48 if(hasColorscale(trace, 'marker')) {
49 colorscaleCalc(gd, trace, {
50 vals: trace.marker.color,
51 containerStr: 'marker',
52 cLetter: 'c'
53 });
54 }
55 if(hasColorscale(trace, 'marker.line')) {
56 colorscaleCalc(gd, trace, {
57 vals: trace.marker.line.color,
58 containerStr: 'marker.line',
59 cLetter: 'c'
60 });
61 }
62
63 arraysToCalcdata(cd, trace);
64 calcSelection(cd, trace);
65
66 return cd;
67}
68
69function crossTraceCalc(gd, polarLayout, subplotId) {

Callers

nothing calls this directly

Calls 4

hasColorscaleFunction · 0.85
arraysToCalcdataFunction · 0.85
calcSelectionFunction · 0.85
d2cFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…