MCPcopy Index your code
hub / github.com/microsoft/SandDance / axisLayout

Function axisLayout

docs/app/js/sanddance-app.js:120296–120343  ·  view source on GitHub ↗
(view, axis, width, height)

Source from the content-addressed store, hash-verified

120294 ];
120295}
120296function axisLayout(view, axis, width, height) {
120297 var item = axis.items[0], datum = item.datum, delta = item.translate != null ? item.translate : 0.5, orient = item.orient, indices = axisIndices(datum), range = item.range, offset = item.offset, position = item.position, minExtent = item.minExtent, maxExtent = item.maxExtent, title = datum.title && item.items[indices[2]].items[0], titlePadding = item.titlePadding, bounds = item.bounds, dl = title && (0, _vegaScenegraph.multiLineOffset)(title), x = 0, y = 0, i, s;
120298 tempBounds.clear().union(bounds);
120299 bounds.clear();
120300 if ((i = indices[0]) > -1) bounds.union(item.items[i].bounds);
120301 if ((i = indices[1]) > -1) bounds.union(item.items[i].bounds); // position axis group and title
120302 switch(orient){
120303 case Top:
120304 x = position || 0;
120305 y = -offset;
120306 s = Math.max(minExtent, Math.min(maxExtent, -bounds.y1));
120307 bounds.add(0, -s).add(range, 0);
120308 if (title) axisTitleLayout(view, title, s, titlePadding, dl, 0, -1, bounds);
120309 break;
120310 case Left:
120311 x = -offset;
120312 y = position || 0;
120313 s = Math.max(minExtent, Math.min(maxExtent, -bounds.x1));
120314 bounds.add(-s, 0).add(0, range);
120315 if (title) axisTitleLayout(view, title, s, titlePadding, dl, 1, -1, bounds);
120316 break;
120317 case Right:
120318 x = width + offset;
120319 y = position || 0;
120320 s = Math.max(minExtent, Math.min(maxExtent, bounds.x2));
120321 bounds.add(0, 0).add(s, range);
120322 if (title) axisTitleLayout(view, title, s, titlePadding, dl, 1, 1, bounds);
120323 break;
120324 case Bottom:
120325 x = position || 0;
120326 y = height + offset;
120327 s = Math.max(minExtent, Math.min(maxExtent, bounds.y2));
120328 bounds.add(0, 0).add(range, s);
120329 if (title) axisTitleLayout(view, title, s, titlePadding, 0, 0, 1, bounds);
120330 break;
120331 default:
120332 x = item.x;
120333 y = item.y;
120334 } // update bounds
120335 (0, _vegaScenegraph.boundStroke)(bounds.translate(x, y), item);
120336 if (set(item, "x", x + delta) | set(item, "y", y + delta)) {
120337 item.bounds = tempBounds;
120338 view.dirty(item);
120339 item.bounds = bounds;
120340 view.dirty(item);
120341 }
120342 return item.mark.bounds.clear().union(bounds);
120343}
120344function axisTitleLayout(view, title, offset, pad, dl, isYAxis1, sign, bounds) {
120345 const b = title.bounds;
120346 if (title.auto) {

Callers 1

layoutGroupFunction · 0.70

Calls 8

axisIndicesFunction · 0.70
axisTitleLayoutFunction · 0.70
setFunction · 0.70
clearMethod · 0.65
maxMethod · 0.45
minMethod · 0.45
addMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected