(view, item, entry)
| 120711 | return b; |
| 120712 | } |
| 120713 | function legendGroupLayout(view, item, entry) { |
| 120714 | var pad = item.padding, ex = pad - entry.x, ey = pad - entry.y; |
| 120715 | if (!item.datum.title) { |
| 120716 | if (ex || ey) translate(view, entry, ex, ey); |
| 120717 | } else { |
| 120718 | var title = item.items[1].items[0], anchor = title.anchor, tpad = item.titlePadding || 0, tx = pad - title.x, ty = pad - title.y; |
| 120719 | switch(title.orient){ |
| 120720 | case Left: |
| 120721 | ex += Math.ceil(title.bounds.width()) + tpad; |
| 120722 | break; |
| 120723 | case Right: |
| 120724 | case Bottom: |
| 120725 | break; |
| 120726 | default: |
| 120727 | ey += title.bounds.height() + tpad; |
| 120728 | } |
| 120729 | if (ex || ey) translate(view, entry, ex, ey); |
| 120730 | switch(title.orient){ |
| 120731 | case Left: |
| 120732 | ty += legendTitleOffset(item, entry, title, anchor, 1, 1); |
| 120733 | break; |
| 120734 | case Right: |
| 120735 | tx += legendTitleOffset(item, entry, title, End, 0, 0) + tpad; |
| 120736 | ty += legendTitleOffset(item, entry, title, anchor, 1, 1); |
| 120737 | break; |
| 120738 | case Bottom: |
| 120739 | tx += legendTitleOffset(item, entry, title, anchor, 0, 0); |
| 120740 | ty += legendTitleOffset(item, entry, title, End, -1, 0, 1) + tpad; |
| 120741 | break; |
| 120742 | default: |
| 120743 | tx += legendTitleOffset(item, entry, title, anchor, 0, 0); |
| 120744 | } |
| 120745 | if (tx || ty) translate(view, title, tx, ty); // translate legend if title pushes into negative coordinates |
| 120746 | if ((tx = Math.round(title.bounds.x1 - pad)) < 0) { |
| 120747 | translate(view, entry, -tx, 0); |
| 120748 | translate(view, title, -tx, 0); |
| 120749 | } |
| 120750 | } |
| 120751 | } |
| 120752 | function legendTitleOffset(item, entry, title, anchor, y, lr, noBar) { |
| 120753 | const grad = item.datum.type !== "symbol", vgrad = title.datum.vgrad, e = grad && (lr || !vgrad) && !noBar ? entry.items[0] : entry, s = e.bounds[y ? "y2" : "x2"] - item.padding, u = vgrad && lr ? s : 0, v = vgrad && lr ? 0 : s, o = y <= 0 ? 0 : (0, _vegaScenegraph.multiLineOffset)(title); |
| 120754 | return Math.round(anchor === Start ? u : anchor === End ? v - o : 0.5 * (s - o)); |
no test coverage detected