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

Function groupScale

src/traces/pie/plot.js:1117–1167  ·  view source on GitHub ↗
(cdModule, scaleGroups)

Source from the content-addressed store, hash-verified

1115}
1116
1117function groupScale(cdModule, scaleGroups) {
1118 var cd0, i, trace;
1119
1120 // scale those that are grouped
1121 for (var k = 0; k < scaleGroups.length; k++) {
1122 var min = Infinity;
1123 var g = scaleGroups[k];
1124
1125 for (i = 0; i < cdModule.length; i++) {
1126 cd0 = cdModule[i][0];
1127 trace = cd0.trace;
1128
1129 if (trace.scalegroup === g) {
1130 var area;
1131 if (trace.type === 'pie') {
1132 area = cd0.r * cd0.r;
1133 } else if (trace.type === 'funnelarea') {
1134 var rx, ry;
1135
1136 if (trace.aspectratio > 1) {
1137 rx = cd0.r;
1138 ry = rx / trace.aspectratio;
1139 } else {
1140 ry = cd0.r;
1141 rx = ry * trace.aspectratio;
1142 }
1143
1144 rx *= (1 + trace.baseratio) / 2;
1145
1146 area = rx * ry;
1147 }
1148
1149 min = Math.min(min, area / cd0.vTotal);
1150 }
1151 }
1152
1153 for (i = 0; i < cdModule.length; i++) {
1154 cd0 = cdModule[i][0];
1155 trace = cd0.trace;
1156 if (trace.scalegroup === g) {
1157 var v = min * cd0.vTotal;
1158 if (trace.type === 'funnelarea') {
1159 v /= (1 + trace.baseratio) / 2;
1160 v /= trace.aspectratio;
1161 }
1162
1163 cd0.r = Math.sqrt(v);
1164 }
1165 }
1166 }
1167}
1168
1169function setCoords(cd) {
1170 var cd0 = cd[0];

Callers 1

layoutAreasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…