import { DimensionType, TableCalculationType } from '../../types/field';
import { ChartKind, } from '../../types/savedCharts';
export var VizAggregationOptions;
(function (VizAggregationOptions) {
    VizAggregationOptions["SUM"] = "sum";
    VizAggregationOptions["COUNT"] = "count";
    VizAggregationOptions["AVERAGE"] = "avg";
    VizAggregationOptions["MIN"] = "min";
    VizAggregationOptions["MAX"] = "max";
    VizAggregationOptions["ANY"] = "any";
})(VizAggregationOptions || (VizAggregationOptions = {}));
export var SortByDirection;
(function (SortByDirection) {
    SortByDirection["ASC"] = "ASC";
    SortByDirection["DESC"] = "DESC";
})(SortByDirection || (SortByDirection = {}));
export const vizAggregationOptions = [
    VizAggregationOptions.SUM,
    VizAggregationOptions.COUNT,
    VizAggregationOptions.AVERAGE,
    VizAggregationOptions.MIN,
    VizAggregationOptions.MAX,
    VizAggregationOptions.ANY,
];
export const VIZ_DEFAULT_AGGREGATION = VizAggregationOptions.COUNT;
export var VizIndexType;
(function (VizIndexType) {
    VizIndexType["TIME"] = "time";
    VizIndexType["CATEGORY"] = "category";
})(VizIndexType || (VizIndexType = {}));
export var AxisSide;
(function (AxisSide) {
    AxisSide[AxisSide["LEFT"] = 0] = "LEFT";
    AxisSide[AxisSide["RIGHT"] = 1] = "RIGHT";
})(AxisSide || (AxisSide = {}));
export var StackType;
(function (StackType) {
    StackType["NONE"] = "none";
    StackType["NORMAL"] = "stack";
    StackType["PERCENT"] = "stack100";
})(StackType || (StackType = {}));
export function getColumnAxisType(dimensionType) {
    switch (dimensionType) {
        case DimensionType.DATE:
        case DimensionType.TIMESTAMP:
            return VizIndexType.TIME;
        case DimensionType.BOOLEAN:
        case DimensionType.NUMBER:
        case DimensionType.STRING:
        default:
            return VizIndexType.CATEGORY;
    }
}
export function getTableCalculationAxisType(tableCalculationType) {
    switch (tableCalculationType) {
        case TableCalculationType.DATE:
        case TableCalculationType.TIMESTAMP:
            return VizIndexType.TIME;
        default:
            return VizIndexType.CATEGORY;
    }
}
export const isPivotChartLayout = (obj) => {
    if (typeof obj !== 'object' || obj === null) {
        return false;
    }
    // PivotChartLayout.y is always an array of { reference, aggregation }.
    // A VizColumnsConfig could have a column named "y" but its value would be
    // a VizColumnConfig object (with label, frozen, visible), never an array.
    if ('y' in obj && Array.isArray(obj.y)) {
        return true;
    }
    return false;
};
export const isVizBarChartConfig = (value) => !!value && value.type === ChartKind.VERTICAL_BAR;
export const isVizLineChartConfig = (value) => !!value && value.type === ChartKind.LINE;
export const isVizCartesianChartConfig = (value) => !!value &&
    (value.type === ChartKind.LINE || value.type === ChartKind.VERTICAL_BAR);
export const isVizPieChartConfig = (value) => !!value && value.type === ChartKind.PIE;
export const isVizTableConfig = (value) => !!value && value.type === ChartKind.TABLE;
//# sourceMappingURL=index.js.map