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

Function crossTraceCalc

src/traces/pie/calc.js:111–143  ·  view source on GitHub ↗
(gd, plotinfo)

Source from the content-addressed store, hash-verified

109 * in the order slices will be displayed
110 */
111function crossTraceCalc(gd, plotinfo) { // TODO: should we name the second argument opts?
112 var desiredType = (plotinfo || {}).type;
113 if(!desiredType) desiredType = 'pie';
114
115 var fullLayout = gd._fullLayout;
116 var calcdata = gd.calcdata;
117 var colorWay = fullLayout[desiredType + 'colorway'];
118 var colorMap = fullLayout['_' + desiredType + 'colormap'];
119
120 if(fullLayout['extend' + desiredType + 'colors']) {
121 colorWay = generateExtendedColors(colorWay, extendedColorWayList);
122 }
123 var dfltColorCount = 0;
124
125 for(var i = 0; i < calcdata.length; i++) {
126 var cd = calcdata[i];
127 var traceType = cd[0].trace.type;
128 if(traceType !== desiredType) continue;
129
130 for(var j = 0; j < cd.length; j++) {
131 var pt = cd[j];
132 if(pt.color === false) {
133 // have we seen this label and assigned a color to it in a previous trace?
134 if(colorMap[pt.label]) {
135 pt.color = colorMap[pt.label];
136 } else {
137 colorMap[pt.label] = pt.color = colorWay[dfltColorCount % colorWay.length];
138 dfltColorCount++;
139 }
140 }
141 }
142 }
143}
144
145/**
146 * pick a default color from the main default set, augmented by

Callers

nothing calls this directly

Calls 1

generateExtendedColorsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…