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

Function axisLabels

docs/app/js/sanddance-app.js:149109–149194  ·  view source on GitHub ↗
(spec, config, userEncode, dataRef, size, band)

Source from the content-addressed store, hash-verified

149107 };
149108}
149109function axisLabels(spec, config, userEncode, dataRef, size, band) {
149110 const _ = lookup(spec, config), orient = spec.orient, scale8 = spec.scale, sign = getSign(orient, -1, 1), flush = deref(_("labelFlush")), flushOffset = deref(_("labelFlushOffset")), labelAlign = _("labelAlign"), labelBaseline = _("labelBaseline");
149111 let flushOn = flush === 0 || !!flush, update;
149112 const tickSize = encoder(size);
149113 tickSize.mult = sign;
149114 tickSize.offset = encoder(_("labelPadding") || 0);
149115 tickSize.offset.mult = sign;
149116 const tickPos = {
149117 scale: scale8,
149118 field: Value,
149119 band: 0.5,
149120 offset: extendOffset(band.offset, _("labelOffset"))
149121 };
149122 const align = ifX(orient, flushOn ? flushExpr(scale8, flush, '"left"', '"right"', '"center"') : {
149123 value: "center"
149124 }, ifRight(orient, "left", "right"));
149125 const baseline1 = ifX(orient, ifTop(orient, "bottom", "top"), flushOn ? flushExpr(scale8, flush, '"top"', '"bottom"', '"middle"') : {
149126 value: "middle"
149127 });
149128 const offsetExpr = flushExpr(scale8, flush, `-(${flushOffset})`, flushOffset, 0);
149129 flushOn = flushOn && flushOffset;
149130 const enter = {
149131 opacity: zero,
149132 x: ifX(orient, tickPos, tickSize),
149133 y: ifY(orient, tickPos, tickSize)
149134 };
149135 const encode = {
149136 enter: enter,
149137 update: update = {
149138 opacity: one,
149139 text: {
149140 field: Label
149141 },
149142 x: enter.x,
149143 y: enter.y,
149144 align,
149145 baseline: baseline1
149146 },
149147 exit: {
149148 opacity: zero,
149149 x: enter.x,
149150 y: enter.y
149151 }
149152 };
149153 addEncoders(encode, {
149154 dx: !labelAlign && flushOn ? ifX(orient, offsetExpr) : null,
149155 dy: !labelBaseline && flushOn ? ifY(orient, offsetExpr) : null
149156 });
149157 addEncoders(encode, {
149158 angle: _("labelAngle"),
149159 fill: _("labelColor"),
149160 fillOpacity: _("labelOpacity"),
149161 font: _("labelFont"),
149162 fontSize: _("labelFontSize"),
149163 fontWeight: _("labelFontWeight"),
149164 fontStyle: _("labelFontStyle"),
149165 limit: _("labelLimit"),
149166 lineHeight: _("labelLineHeight")

Callers 1

parseAxisFunction · 0.70

Calls 14

lookupFunction · 0.70
getSignFunction · 0.70
derefFunction · 0.70
_Function · 0.70
encoderFunction · 0.70
extendOffsetFunction · 0.70
ifXFunction · 0.70
flushExprFunction · 0.70
ifRightFunction · 0.70
ifTopFunction · 0.70
ifYFunction · 0.70
addEncodersFunction · 0.70

Tested by

no test coverage detected