private addUnitTypeToAxisLabel()

in src/visual.ts [1774:1845]


    private addUnitTypeToAxisLabel(axes: MekkoChartAxisProperties): void {
        let unitType: string = MekkoChart.getUnitType(
            axes,
            (axis: MekkoChartAxisProperties) => axis.x);

        if (axes.x.isCategoryAxis) {
            this.categoryAxisHasUnitType = unitType !== null;
        }
        else {
            this.valueAxisHasUnitType = unitType !== null;
        }

        if (axes.x.axisLabel && unitType) {
            if (axes.x.isCategoryAxis) {
                axes.x.axisLabel = AxisHelper.createAxisLabel(
                    this.categoryAxisProperties,
                    axes.x.axisLabel,
                    unitType);
            }
            else {
                axes.x.axisLabel = AxisHelper.createAxisLabel(
                    this.valueAxisProperties,
                    axes.x.axisLabel,
                    unitType);
            }
        }

        unitType = MekkoChart.getUnitType(
            axes,
            (axis: MekkoChartAxisProperties) => axis.y1);

        if (!axes.y1.isCategoryAxis) {
            this.valueAxisHasUnitType = unitType !== null;
        }
        else {
            this.categoryAxisHasUnitType = unitType !== null;
        }

        if (axes.y1.axisLabel && unitType) {
            if (!axes.y1.isCategoryAxis) {
                axes.y1.axisLabel = AxisHelper.createAxisLabel(
                    this.valueAxisProperties,
                    axes.y1.axisLabel,
                    unitType);
            }
            else {
                axes.y1.axisLabel = AxisHelper.createAxisLabel(
                    this.categoryAxisProperties,
                    axes.y1.axisLabel,
                    unitType);
            }
        }

        if (axes.y2) {
            let unitType: string = MekkoChart.getUnitType(
                axes,
                (axis: MekkoChartAxisProperties) => axis.y2);

            this.secValueAxisHasUnitType = unitType !== null;

            if (axes.y2.axisLabel && unitType) {
                if (this.valueAxisProperties && this.valueAxisProperties["secAxisStyle"]) {
                    if (this.valueAxisProperties["secAxisStyle"] === axisStyle.showBoth) {
                        axes.y2.axisLabel = `${axes.y2.axisLabel} (${unitType})`;
                    }
                    else if (this.valueAxisProperties["secAxisStyle"] === axisStyle.showUnitOnly) {
                        axes.y2.axisLabel = unitType;
                    }
                }
            }
        }
    }