protected renderGroup()

in src/visualComponent/mainChart/chartLabelBaseComponent.ts [74:131]


    protected renderGroup(
        selector: CssConstants.ClassAndSelector,
        renderGroupData: IRenderGroup[],
    ): void {
        const selection: Selection<any, IRenderGroup[], any, any> = this.element
            .selectAll(selector.selectorName)
            .data([renderGroupData]);

        selection
            .exit()
            .remove();

        const mergedSelection = selection
            .enter()
            .append("div")
            .classed(selector.className, true)
            .merge(selection);

        const itemSelection: Selection<any, IRenderGroup, any, any> = mergedSelection
            .selectAll(this.itemSelector.selectorName)
            .data((data: IRenderGroup[]) => {
                return data.filter((renderGroup: IRenderGroup) => {
                    return renderGroup && renderGroup.isShown;
                });
            });

        itemSelection
            .exit()
            .remove();

        itemSelection
            .enter()
            .append("div")
            .merge(itemSelection)
            .attr("class", (data: IRenderGroup) => {
                const baseSelector: string = this.itemSelector.className;

                return data.selector
                    ? `${baseSelector} ${data.selector.className}`
                    : baseSelector;
            })
            .text((data: IRenderGroup) => data.data)
            .style("color", (data: IRenderGroup) => data.color)
            .style("font-size", (data: IRenderGroup) => {
                if (!data.fontSizeInPt || isNaN(data.fontSizeInPt)) {
                    return null;
                }

                const fontSizeInPx: number = pixelConverter.fromPointToPixel(data.fontSizeInPt);

                return pixelConverter.toString(fontSizeInPx);
            });

        this.constructorOptions.tooltipServiceWrapper.addTooltip<IRenderGroup>(
            itemSelection,
            (data) => data.tooltipDataItems ? data.tooltipDataItems : null
        );
    }