(view, mark, width, height, viewBounds)
| 120772 | }); |
| 120773 | } |
| 120774 | function titleLayout(view, mark, width, height, viewBounds) { |
| 120775 | var group = mark.items[0], frame = group.frame, orient = group.orient, anchor = group.anchor, offset = group.offset, padding = group.padding, title = group.items[0].items[0], subtitle = group.items[1] && group.items[1].items[0], end = orient === Left || orient === Right ? height : width, start = 0, x = 0, y = 0, sx = 0, sy = 0, pos; |
| 120776 | if (frame !== Group) orient === Left ? (start = viewBounds.y2, end = viewBounds.y1) : orient === Right ? (start = viewBounds.y1, end = viewBounds.y2) : (start = viewBounds.x1, end = viewBounds.x2); |
| 120777 | else if (orient === Left) start = height, end = 0; |
| 120778 | pos = anchor === Start ? start : anchor === End ? end : (start + end) / 2; |
| 120779 | if (subtitle && subtitle.text) { |
| 120780 | // position subtitle |
| 120781 | switch(orient){ |
| 120782 | case Top: |
| 120783 | case Bottom: |
| 120784 | sy = title.bounds.height() + padding; |
| 120785 | break; |
| 120786 | case Left: |
| 120787 | sx = title.bounds.width() + padding; |
| 120788 | break; |
| 120789 | case Right: |
| 120790 | sx = -title.bounds.width() - padding; |
| 120791 | break; |
| 120792 | } |
| 120793 | tempBounds.clear().union(subtitle.bounds); |
| 120794 | tempBounds.translate(sx - (subtitle.x || 0), sy - (subtitle.y || 0)); |
| 120795 | if (set(subtitle, "x", sx) | set(subtitle, "y", sy)) { |
| 120796 | view.dirty(subtitle); |
| 120797 | subtitle.bounds.clear().union(tempBounds); |
| 120798 | subtitle.mark.bounds.clear().union(tempBounds); |
| 120799 | view.dirty(subtitle); |
| 120800 | } |
| 120801 | tempBounds.clear().union(subtitle.bounds); |
| 120802 | } else tempBounds.clear(); |
| 120803 | tempBounds.union(title.bounds); // position title group |
| 120804 | switch(orient){ |
| 120805 | case Top: |
| 120806 | x = pos; |
| 120807 | y = viewBounds.y1 - tempBounds.height() - offset; |
| 120808 | break; |
| 120809 | case Left: |
| 120810 | x = viewBounds.x1 - tempBounds.width() - offset; |
| 120811 | y = pos; |
| 120812 | break; |
| 120813 | case Right: |
| 120814 | x = viewBounds.x2 + tempBounds.width() + offset; |
| 120815 | y = pos; |
| 120816 | break; |
| 120817 | case Bottom: |
| 120818 | x = pos; |
| 120819 | y = viewBounds.y2 + offset; |
| 120820 | break; |
| 120821 | default: |
| 120822 | x = group.x; |
| 120823 | y = group.y; |
| 120824 | } |
| 120825 | if (set(group, "x", x) | set(group, "y", y)) { |
| 120826 | tempBounds.translate(x, y); |
| 120827 | view.dirty(group); |
| 120828 | group.bounds.clear().union(tempBounds); |
| 120829 | mark.bounds.clear().union(tempBounds); |
| 120830 | view.dirty(group); |
| 120831 | } |
no test coverage detected