public preRender()

in src/visualComponent/axes/xAxisComponent.ts [100:149]


    public preRender(options: IXAxisComponentRenderOptions): void {
        if (!this.areRenderOptionsValid(options)) {
            return;
        }

        const {
            axis,
            settings,
        } = options;

        if (settings.show) {
            this.show();
        } else {
            this.hide();
        }

        const fontSize: number = settings.fontSizeInPx;

        this.formatter = this.getValueFormatterOfXAxis(axis, settings);

        const domain: any[] = axis.scale.getDomain();

        this.maxElementHeight = labelMeasurementService.getLabelHeight(
            axis.max,
            this.formatter,
            fontSize,
            settings.fontFamily,
        );

        this.maxElementWidth = labelMeasurementService.getLabelWidth(
            [axis.min, axis.max],
            this.formatter,
            fontSize,
            settings.fontFamily,
        );

        this.firstLabelWidth = this.getLabelWidthWithAdditionalOffset(
            [domain[0] || ""],
            this.formatter,
            fontSize,
            settings.fontFamily,
        ) / 2;

        this.latestLabelWidth = this.getLabelWidthWithAdditionalOffset(
            [domain.slice(-1)[0] || ""],
            this.formatter,
            fontSize,
            settings.fontFamily,
        ) / 2;
    }