(view, group, _)
| 120859 | return group && group.mark.role !== "legend-entry"; |
| 120860 | } |
| 120861 | function layoutGroup(view, group, _) { |
| 120862 | var items = group.items, width = Math.max(0, group.width || 0), height = Math.max(0, group.height || 0), viewBounds = new (0, _vegaScenegraph.Bounds)().set(0, 0, width, height), xBounds = viewBounds.clone(), yBounds = viewBounds.clone(), legends = [], title, mark, orient, b1, i, n; // layout axes, gather legends, collect bounds |
| 120863 | for(i = 0, n = items.length; i < n; ++i){ |
| 120864 | mark = items[i]; |
| 120865 | switch(mark.role){ |
| 120866 | case AxisRole: |
| 120867 | b1 = isYAxis(mark) ? xBounds : yBounds; |
| 120868 | b1.union(axisLayout(view, mark, width, height)); |
| 120869 | break; |
| 120870 | case TitleRole: |
| 120871 | title = mark; |
| 120872 | break; |
| 120873 | case LegendRole: |
| 120874 | legends.push(legendLayout(view, mark)); |
| 120875 | break; |
| 120876 | case FrameRole: |
| 120877 | case ScopeRole: |
| 120878 | case RowHeader: |
| 120879 | case RowFooter: |
| 120880 | case RowTitle: |
| 120881 | case ColHeader: |
| 120882 | case ColFooter: |
| 120883 | case ColTitle: |
| 120884 | xBounds.union(mark.bounds); |
| 120885 | yBounds.union(mark.bounds); |
| 120886 | break; |
| 120887 | default: |
| 120888 | viewBounds.union(mark.bounds); |
| 120889 | } |
| 120890 | } // layout legends, adjust viewBounds |
| 120891 | if (legends.length) { |
| 120892 | // group legends by orient |
| 120893 | const l = {}; |
| 120894 | legends.forEach((item)=>{ |
| 120895 | orient = item.orient || Right; |
| 120896 | if (orient !== None) (l[orient] || (l[orient] = [])).push(item); |
| 120897 | }); // perform grid layout for each orient group |
| 120898 | for(const orient1 in l){ |
| 120899 | const g = l[orient1]; |
| 120900 | gridLayout(view, g, legendParams(g, orient1, _.legends, xBounds, yBounds, width, height)); |
| 120901 | } // update view bounds |
| 120902 | legends.forEach((item)=>{ |
| 120903 | const b = item.bounds; |
| 120904 | if (!b.equals(item._bounds)) { |
| 120905 | item.bounds = item._bounds; |
| 120906 | view.dirty(item); // dirty previous location |
| 120907 | item.bounds = b; |
| 120908 | view.dirty(item); |
| 120909 | } |
| 120910 | if (_.autosize && _.autosize.type === Fit) // For autosize fit, incorporate the orthogonal dimension only. |
| 120911 | // Legends that overrun the chart area will then be clipped; |
| 120912 | // otherwise the chart area gets reduced to nothing! |
| 120913 | switch(item.orient){ |
| 120914 | case Left: |
| 120915 | case Right: |
| 120916 | viewBounds.add(b.x1, 0).add(b.x2, 0); |
| 120917 | break; |
| 120918 | case Top: |
no test coverage detected