# GrapeCity.Spreadsheet.Charts.ITrendlines.Add

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Spreadsheet_Charts_ITrendlines_Add_" data-uid="GrapeCity.Spreadsheet.Charts.ITrendlines.Add*">Add Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Spreadsheet_Charts_ITrendlines_Add_" data-uid="GrapeCity.Spreadsheet.Charts.ITrendlines.Add*"></a>
<h4 id="GrapeCity_Spreadsheet_Charts_ITrendlines_Add_GrapeCity_Spreadsheet_Charts_TrendlineType_System_Int32_System_Int32_System_Double_System_Double_System_Double_System_Boolean_System_Boolean_System_String_" data-uid="GrapeCity.Spreadsheet.Charts.ITrendlines.Add(GrapeCity.Spreadsheet.Charts.TrendlineType,System.Int32,System.Int32,System.Double,System.Double,System.Double,System.Boolean,System.Boolean,System.String)">Add(TrendlineType, int, int, double, double, double, bool, bool, string)</h4>
<div class="markdown level1 summary"><p>Creates a new trendline.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">ITrendline Add(TrendlineType type, int order = 2, int period = 2, double forward = 0, double backward = 0, double intercept = NaN, bool displayEquation = false, bool displayRSquare = false, string name = null)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Function Add(type As TrendlineType, Optional order As Integer = 2, Optional period As Integer = 2, Optional forward As Double = 0, Optional backward As Double = 0, Optional intercept As Double = NaN, Optional displayEquation As Boolean = False, Optional displayRSquare As Boolean = False, Optional name As String = Nothing) As ITrendline</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Spreadsheet.Charts.TrendlineType.html">TrendlineType</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The trendline type.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">order</span></td>
      <td><p>The trendline order when <code class="paramref">type</code> is <a class="xref" href="GrapeCity.Spreadsheet.Charts.TrendlineType.html#GrapeCity_Spreadsheet_Charts_TrendlineType_Polynomial">Polynomial</a>. Must be an integer from 2 to 6, inclusive.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">period</span></td>
      <td><p>The trendline period when <code class="paramref">type</code> is <a class="xref" href="GrapeCity.Spreadsheet.Charts.TrendlineType.html#GrapeCity_Spreadsheet_Charts_TrendlineType_MovingAverage">MovingAverage</a>. Must be an integer greater than 1 and less than the number of data points in the series you are adding a trendline to.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><span class="parametername">forward</span></td>
      <td><p>The number of periods (or units on a scatter chart) that the trendline extends forward.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><span class="parametername">backward</span></td>
      <td><p>The number of periods (or units on a scatter chart) that the trendline extends backward.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><span class="parametername">intercept</span></td>
      <td><p>The trendline intercept. If this argument is omitted, the intercept is automatically set by the regression.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">displayEquation</span></td>
      <td><p><code>true</code> to display the equation of the trendline on the chart (in the same data label as the R-squared value).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">displayRSquare</span></td>
      <td><p><code>true</code> to display the R-squared value of the trendline on the chart (in the same data label as the equation).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">name</span></td>
      <td><p>The name of the trendline as text.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="GrapeCity.Spreadsheet.Charts.ITrendline.html">ITrendline</a></td>
      <td><p>An <a class="xref" href="GrapeCity.Spreadsheet.Charts.ITrendline.html">ITrendline</a> object that represents the new trendline.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
