/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { IgrAxis } from './igr-axis';
import { toPoint, fromRect, ensureBool } from "igniteui-react-core/ES2015/componentUtil";
/**
 * Represents the base class for all IgxDataChartComponent category-based axes.
*/
export class IgrCategoryAxisBase extends IgrAxis {
    constructor(props) {
        super(props);
        this._chartLevelData = null;
        this._dataSource = null;
    }
    provideData(data) {
        this._chartLevelData = data;
        this.updateDataSource();
    }
    updateDataSource() {
        if (this._dataSource == null) {
            this.i.itemsSource = this._chartLevelData;
        }
        else {
            this.i.itemsSource = this._dataSource;
        }
    }
    set dataSource(value) {
        this._dataSource = value;
        this.updateDataSource();
        //console.log("setting axis data source: " + value)
    }
    get dataSource() {
        if (this._dataSource != null) {
            return this._dataSource;
        }
        return this.i.itemsSource;
    }
    get i() {
        return this._implementation;
    }
    /**
 * Gets if the current axis is a continuous rather than a discrete scale
*/
    get isContinuous() {
        return this.i.b4;
    }
    /**
     * Checks if the axis is of category axis type
    */
    get isCategory() {
        return this.i.b2;
    }
    /**
     * Gets the number of items in the current category axis items source.
    */
    get itemsCount() {
        return this.i.js;
    }
    set itemsCount(v) {
        this.i.js = +v;
    }
    /**
     * Gets or sets the amount of space between adjacent categories for the current axis object.
     * The gap is silently clamped to the range [0, 1] when used.
    *
    * Use the `gap` property to configure the spacing between items on a category axis with item spacing.
    *
    * A `gap` of 0 allocates no space between items.  A `gap` of 1 allocates a space between items equal to the width of one item.
    *
    * To set the item spacing to 75% the width of one item, set the `gap` to 0.75, as in this code:
    */
    get gap() {
        return this.i.jh;
    }
    set gap(v) {
        this.i.jh = +v;
    }
    /**
     * Gets or sets the amount of overlap between adjacent categories for the current axis object.
     * The overlap is silently clamped to the range [-1, 1] when used.
    *
    * Use the `overlap` property to configure the spacing between items on a category axis with item spacing and more than one series.
    *
    * An `overlap` of 0 places grouped items adjacent to each other.  An `overlap` of 1 places grouped items in the same axis space, completely overlapping.  An `overlap` of -1 places a space between grouped items equal to the width of one item.
    *
    * To place grouped items with 75% overlap, set the `overlap` to 0.75, as in this code:
    */
    get overlap() {
        return this.i.jo;
    }
    set overlap(v) {
        this.i.jo = +v;
    }
    /**
     * Gets or sets whether the category axis should use clustering display mode even if no series are present that would force clustering mode.
    *
    * `useClusteringMode` applies grouping and spacing to a category axis equivalent to the grouping that occurs when grouping series, such as ColumnSeries, are used.
    *
    * Try setting it on an axis displaying financial series to adjust the spacing on the left and right sides of the axis:
    */
    get useClusteringMode() {
        return this.i.jc;
    }
    set useClusteringMode(v) {
        this.i.jc = ensureBool(v);
    }
    getCategoryBoundingBox(point, useInterpolation, singularWidth) {
        let iv = this.i.kn(toPoint(point), useInterpolation, singularWidth);
        return fromRect(iv);
    }
    getCategoryBoundingBoxHelper(point, useInterpolation, singularWidth, isVertical) {
        let iv = this.i.ko(toPoint(point), useInterpolation, singularWidth, isVertical);
        return fromRect(iv);
    }
    /**
     * Unscales a value from screen space into axis space.
    
    * @param unscaledValue  * The scaled value in screen coordinates to unscale into axis space.
    */
    unscaleValue(unscaledValue) {
        let iv = this.i.jp(unscaledValue);
        return (iv);
    }
    notifySetItem(index, oldItem, newItem) {
        this.i.ka(index, oldItem, newItem);
    }
    /**
     * Used to manually notify the axis that the data source has reset or cleared its items.
    
    */
    notifyClearItems() {
        this.i.j7();
    }
    notifyInsertItem(index, newItem) {
        this.i.j8(index, newItem);
    }
    notifyRemoveItem(index, oldItem) {
        this.i.j9(index, oldItem);
    }
}
