export function getLabelRect()

in src/label/dataLabelRectPositioner.ts [53:131]


export function getLabelRect(labelDataPointLayoutInfo: LabelDataPointLayoutInfo, position: RectLabelPosition, offset: number): IRect {
    let labelDataPoint = labelDataPointLayoutInfo.labelDataPoint;
    let parentRect: LabelParentRect = <LabelParentRect>labelDataPoint.parentShape;
    if (parentRect != null) {
        // Each combination of position and orientation results in a different actual positioning, which is then called.
        switch (position) {
            case RectLabelPosition.InsideCenter:
            case RectLabelPosition.OverflowInsideCenter:
                switch (parentRect.orientation) {
                    case NewRectOrientation.VerticalBottomBased:
                    case NewRectOrientation.VerticalTopBased:
                        return middleVertical(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalLeftBased:
                    case NewRectOrientation.HorizontalRightBased:
                        return middleHorizontal(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.None:
                    // TODO: which of the above cases should we default to for rects with no orientation?
                }
            case RectLabelPosition.InsideBase:
            case RectLabelPosition.OverflowInsideBase:
                switch (parentRect.orientation) {
                    case NewRectOrientation.VerticalBottomBased:
                        return bottomInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.VerticalTopBased:
                        return topInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalLeftBased:
                        return leftInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalRightBased:
                        return rightInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.None:
                    // TODO: which of the above cases should we default to for rects with no orientation?
                }
            case RectLabelPosition.InsideEnd:
            case RectLabelPosition.OverflowInsideEnd:
                switch (parentRect.orientation) {
                    case NewRectOrientation.VerticalBottomBased:
                        return topInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.VerticalTopBased:
                        return bottomInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalLeftBased:
                        return rightInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalRightBased:
                        return leftInside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.None:
                    // TODO: which of the above cases should we default to for rects with no orientation?
                }
            case RectLabelPosition.OutsideBase:
                switch (parentRect.orientation) {
                    case NewRectOrientation.VerticalBottomBased:
                        return bottomOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.VerticalTopBased:
                        return topOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalLeftBased:
                        return leftOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalRightBased:
                        return rightOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.None:
                    // TODO: which of the above cases should we default to for rects with no orientation?
                }
            case RectLabelPosition.OutsideEnd:
                switch (parentRect.orientation) {
                    case NewRectOrientation.VerticalBottomBased:
                        return topOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.VerticalTopBased:
                        return bottomOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalLeftBased:
                        return rightOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.HorizontalRightBased:
                        return leftOutside(labelDataPointLayoutInfo.labelSize, parentRect.rect, offset);
                    case NewRectOrientation.None:
                    // TODO: which of the above cases should we default to for rects with no orientation?
                }
        }
    }
    else {
        // TODO: Data labels for non-rectangular visuals (line chart)
    }
    return null;
}