private getCategoryAxisValues()

in src/visual.ts [1335:1436]


    private getCategoryAxisValues(instances: VisualObjectInstance[]): void {
        let supportedType: string = axisType.both,
            isValueScalar: boolean = false,
            logPossible: boolean = !!this.axes.x.isLogScaleAllowed,
            scaleOptions: string[] = [axisScale.log, axisScale.linear];

        if (this.layers && this.layers[0].getSupportedCategoryAxisType) {
            supportedType = this.layers[0].getSupportedCategoryAxisType();

            if (supportedType === axisType.scalar) {
                isValueScalar = true;
            }
            else {
                isValueScalar = isScalar(
                    supportedType === axisType.both,
                    this.categoryAxisProperties);
            }
        }

        if (!isValueScalar) {
            if (this.categoryAxisProperties) {
                this.categoryAxisProperties["start"] = null;
                this.categoryAxisProperties["end"] = null;
            }
        }

        const instance: VisualObjectInstance = {
            selector: null,
            properties: {},
            objectName: "categoryAxis",
            validValues: {
                axisScale: scaleOptions
            }
        };

        instance.properties["show"] = this.categoryAxisProperties && this.categoryAxisProperties["show"] != null
            ? this.categoryAxisProperties["show"]
            : true;

        if (this.yAxisIsCategorical)
            instance.properties["position"] = this.valueAxisProperties && this.valueAxisProperties["position"] != null
                ? this.valueAxisProperties["position"]
                : axisPosition.left;

        if (supportedType === axisType.both) {
            instance.properties["axisType"] = isValueScalar
                ? axisType.scalar
                : axisType.categorical;
        }

        if (isValueScalar) {
            instance.properties["axisScale"] = (this.categoryAxisProperties && this.categoryAxisProperties["axisScale"] != null && logPossible)
                ? this.categoryAxisProperties["axisScale"]
                : axisScale.linear;

            instance.properties["start"] = this.categoryAxisProperties
                ? this.categoryAxisProperties["start"]
                : null;

            instance.properties["end"] = this.categoryAxisProperties
                ? this.categoryAxisProperties["end"]
                : null;
        }

        instance.properties["showAxisTitle"] = this.categoryAxisProperties && this.categoryAxisProperties["showAxisTitle"] != null
            ? this.categoryAxisProperties["showAxisTitle"]
            : false;

        instance.properties["showBorder"] = this.categoryAxisProperties && this.categoryAxisProperties["showBorder"] != null
            ? this.categoryAxisProperties["showAxisTitle"]
            : false;

        instance.properties["fontSize"] = this.categoryAxisProperties && this.categoryAxisProperties["fontSize"] != null
            ? this.categoryAxisProperties["fontSize"]
            : MekkoChart.DefaultLabelFontSizeInPt;

        instances
            .push(instance);

        instances
            .push({
                selector: null,
                properties: {
                    axisStyle: this.categoryAxisProperties && this.categoryAxisProperties["axisStyle"]
                        ? this.categoryAxisProperties["axisStyle"]
                        : axisStyle.showTitleOnly,
                    labelColor: this.categoryAxisProperties && this.categoryAxisProperties["labelColor"]
                        ? this.categoryAxisProperties["labelColor"]
                        : MekkoChart.DefaultSettings.categoryAxis.labelColor
                },
                objectName: "categoryAxis",
                validValues: {
                    axisStyle: this.categoryAxisHasUnitType
                        ? [
                            axisStyle.showTitleOnly,
                            axisStyle.showUnitOnly,
                            axisStyle.showBoth
                        ]
                        : [axisStyle.showTitleOnly],
                }
            });
    }