SheetXL - v1.0.2
    Preparing search index...

    Interface ITrendline

    A line fitted to a series' points, or their moving average, with the fit's equation and R² as an optional label.

    interface ITrendline {
        isITrendline: true;
        delete(options?: ITransaction.OperationOptions): void;
        getBackwardPeriod(): number;
        getChart(): IChart;
        getElementType(): IChart.ElementType;
        getFit(): TrendlineFit | null;
        getForwardPeriod(): number;
        getIntercept(): number | null;
        getLabel(): IChart.ITrendlineLabel;
        getMovingAveragePeriod(): number;
        getName(): string;
        getParent(): IElement | null;
        getPath(): string;
        getPolynomialOrder(): number;
        getShowEquation(): boolean;
        getShowRSquared(): boolean;
        getStyle(): IShapeStyle;
        getType(): TrendlineType;
        isInterceptAuto(): boolean;
        isNameAuto(): boolean;
        setBackwardPeriod(
            period: number,
            options?: ITransaction.OperationOptions,
        ): this;
        setForwardPeriod(
            period: number,
            options?: ITransaction.OperationOptions,
        ): this;
        setIntercept(
            intercept: number | "auto",
            options?: ITransaction.OperationOptions,
        ): this;
        setMovingAveragePeriod(
            period: number,
            options?: ITransaction.OperationOptions,
        ): this;
        setName(name: string | null, options?: ITransaction.OperationOptions): this;
        setPolynomialOrder(
            order: number,
            options?: ITransaction.OperationOptions,
        ): this;
        setShowEquation(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setShowRSquared(
            show: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        setType(type: TrendlineType, options?: ITransaction.OperationOptions): this;
        update(
            update: IChart.ITrendline.Update,
            options?: ITransaction.OperationOptions,
        ): this;
    }

    Hierarchy (View Summary)

    Index
    isITrendline: true

    For runtime type checking.

    • Returns how far the line runs before the first point.

      Returns number

    • Returns the fit: the numbers the label shows, unrounded. null for a moving average, or where the points allow no fit.

      Returns TrendlineFit | null

    • Returns how far the line runs past the last point, in x: in categories on a category axis.

      Returns number

    • Returns the y the line is drawn through at x = 0: the one set, else a linear, exponential or polynomial fit's (null for the other types, which have none, or where the points allow no fit).

      Returns number | null

    • Returns a moving average's period, in points; 2 for another type.

      Returns number

    • Returns the trendline's entry in the legend: the one set, else Excel's, Linear (Sales).

      Returns string

    • Returns the element this one is part of: a point's series, a gridline's axis, a legend entry's legend. The parts at the top (the title, the legend, the plot area, an axis, a series, a group) are the chart area's; the chart area has none.

      Returns IElement | null

    • Returns where the element is in its chart, as IChart.getElement takes it.

      Returns string

      A path is its parts' names joined by /, and does not change while the part is there:

      • chartArea, title, legend, legend/entries/<n>, plotArea, dataTable, and dataLabels (every series' at once);
      • axes/<primary|secondary>/<category|value|series>, and an axis's …/title, …/majorGridlines and …/minorGridlines;
      • series/<key>, and a series' …/marker, …/dataLabels, …/errorBars/<x|y>, …/trendlines/<n>, …/trendlines/<n>/label, …/points/<n>, …/points/<n>/marker and …/points/<n>/dataLabel;
      • groups/<n>, and a group's …/upDownBars, …/hiLoLines, …/dropLines and …/seriesLines.

      A series' key is its index in the file (c:idx), which an edit does not change; its place in the plot order can change. A point, a trendline, a legend entry and a group are named by their place, from 0: when one before it is removed, the path names the one that took its place.

    • Returns a polynomial's order, 2 to 6; 2 for another type.

      Returns number

    • Returns whether the label shows the fit's equation.

      Returns boolean

    • Returns whether the label shows the fit's R².

      Returns boolean

    • Returns what the line is drawn with (Office Scripts' getFormat().getLine()): reads resolve to Excel's dotted 1.5 pt line in the series' color where it states none.

      Returns IShapeStyle

    • Returns whether the intercept is the fit's own rather than set.

      Returns boolean

    • Returns whether the name is Excel's own rather than set.

      Returns boolean

    • Sets how far the line runs before the first point.

      Parameters

      Returns this

      ExpectedError for a negative run, and on a category axis for one past half a category, as in Excel.

    • Sets how far the line runs past the last point; 0 for not at all. On a category axis a run adds unlabeled categories.

      Parameters

      Returns this

      ExpectedError for a negative run.

    • Holds the fit to intercept at x = 0, or 'auto' to let it go. Excel keeps an intercept on a linear, exponential or polynomial fit and a moving average; on a logarithmic or power fit it changes nothing, as in Excel.

      Parameters

      Returns this

    • Sets a moving average's period: 2 to one fewer than the series' points.

      Parameters

      Returns this

      ExpectedError for a period outside that, or on a trendline that is not a moving average.

    • Sets a polynomial's order, 2 to 6. On another type it changes nothing, as in Excel.

      Parameters

      Returns this

      ExpectedError for an order outside 2 to 6.