MCPcopy Create free account
hub / github.com/microsoft/SandDance / legendParams

Function legendParams

docs/app/js/sanddance-app.js:120611–120682  ·  view source on GitHub ↗
(g, orient, config, xb, yb, w, h)

Source from the content-addressed store, hash-verified

120609 return max1 > -Infinity ? max1 : value;
120610}
120611function legendParams(g, orient, config, xb, yb, w, h) {
120612 const _ = lookup$1(config, orient), offset = offsets(g, _("offset", 0)), anchor = _("anchor", Start), mult = anchor === End ? 1 : anchor === Middle ? 0.5 : 0;
120613 const p = {
120614 align: Each,
120615 bounds: _("bounds", Flush),
120616 columns: _("direction") === "vertical" ? 1 : g.length,
120617 padding: _("margin", 8),
120618 center: _("center"),
120619 nodirty: true
120620 };
120621 switch(orient){
120622 case Left:
120623 p.anchor = {
120624 x: Math.floor(xb.x1) - offset,
120625 column: End,
120626 y: mult * (h || xb.height() + 2 * xb.y1),
120627 row: anchor
120628 };
120629 break;
120630 case Right:
120631 p.anchor = {
120632 x: Math.ceil(xb.x2) + offset,
120633 y: mult * (h || xb.height() + 2 * xb.y1),
120634 row: anchor
120635 };
120636 break;
120637 case Top:
120638 p.anchor = {
120639 y: Math.floor(yb.y1) - offset,
120640 row: End,
120641 x: mult * (w || yb.width() + 2 * yb.x1),
120642 column: anchor
120643 };
120644 break;
120645 case Bottom:
120646 p.anchor = {
120647 y: Math.ceil(yb.y2) + offset,
120648 x: mult * (w || yb.width() + 2 * yb.x1),
120649 column: anchor
120650 };
120651 break;
120652 case TopLeft:
120653 p.anchor = {
120654 x: offset,
120655 y: offset
120656 };
120657 break;
120658 case TopRight:
120659 p.anchor = {
120660 x: w - offset,
120661 y: offset,
120662 column: End
120663 };
120664 break;
120665 case BottomLeft:
120666 p.anchor = {
120667 x: offset,
120668 y: h - offset,

Callers 1

layoutGroupFunction · 0.70

Calls 3

lookup$1Function · 0.70
offsetsFunction · 0.70
_Function · 0.70

Tested by

no test coverage detected