title: How to calculate the trend line
body: <p>I am trying to calculate a trend line, according to the formula I got from this site:</p>
  
  <p><a href="http://classroom.synonym.com/calculate-trendline-2709.html" rel="nofollow noreferrer">http://classroom.synonym.com/calculate-trendline-2709.html</a></p>
  
  <p>I have done the trend line in High Charts by adding the code and passing the values dynamically and this is my code: </p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
          &lt;title&gt;Highcharts Example&lt;/title&gt;
  
          &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript" src="regression.js"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript" src="http://code.highcharts.com/highcharts.js"&gt;&lt;/script&gt;
  
          &lt;script type="text/javascript"&gt;
  
      $(function () {        
          var sourceData = [
            [0, 99.75], [1, 99.77],
            [2, 99.78], [3, 99.84],
            [4, 99.82], [5, 99.82],
            [6, 99.76], [7, 99.78],
            [8, 99.8], [9, 99.65],
            [10, 99.94], [11, 99.8]
          ];
  
          $('#container').highcharts({
              title: {
                  text: 'RNA',
                  x: -20 //center
              },
              subtitle: {
                  text: 'Outage Reasons',
                  x: -20
              },
              xAxis: {
                  categories: ['18-Jul-14', '19-Jul-14', '20-Jul-14', '21-Jul-14', '22-Jul-14', '23-Jul-14',
                      '24-Jul-14', '25-Jul-14', '26-Jul-14', '27-Jul-14', '28-Jul-14', '29-Jul-14']
              },
              yAxis: {
                  title: {
                      text: 'Percent'
                  },
                  plotLines: [{
                      value: 0,
                      width: 1,
                      color: '#808080'
                  }]
              },
              tooltip: {
                  valueSuffix: '%'
              },
              legend: {
                  layout: 'vertical',
                  //align: 'right',
                  //verticalAlign: 'middle',
                  borderWidth: 0
              },
              series: [{
                  name: 'RNA - CP ( Radio Network Availability - Customer Perceived)',
                  data: sourceData
              },
              {
                  type: 'line',
                  marker: { enabled: false },
                  /* function returns data for trend-line */
                  data: (function() {
                    return fitData(sourceData).data;
                  })()
              }],
              credits: {
                  enabled: false
              }
        });
  });
  
  
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
  &lt;script src="exporting.js"&gt;&lt;/script&gt;
  
  &lt;div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>This is graph that gets generated: </p>
  
  <p><img src="https://i.stack.imgur.com/kVNzk.png" alt="enter image description here"></p>
  
  <p>What I would like to know is:</p>
  
  <ol>
  <li><p>How the values are calculating the values according to the formula and what are the values</p></li>
  <li><p>How the trend line is plotting on the graph.</p></li>
  <li><p>I know the dates on the x-axis isn't calculate with formula.</p></li>
  <li><p>I have done calculate according to the values</p>
  
  <p>[0, 99.75], [1, 99.77],<br/>
  [2, 99.78], [3, 99.84],<br/>
  [4, 99.82], [5, 99.82],<br/>
  [6, 99.76], [7, 99.78],<br/>
  [8, 99.8], [9, 99.65],<br/>
  [10, 99.94], [11, 99.8]</p></li>
  </ol>
  
  <p>but the values are different that are plotted on the graph.</p>
  
  <p>Thanks </p>