add a trendline with categories to line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

add a trendline with categories to line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts test tool</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script> 
      <script type="text/javascript" src="http://rawgit.com/virtualstaticvoid/highcharts_trendline/master/regression.js"></script> 
      <style id="compiled-css" type="text/css">

#container {/*from   w  w  w. j  a  v a 2  s .  c  o m*/
   max-width: 600px;
   height: 600px;
   margin: 1em auto;
}


      </style> 
      <script type="text/javascript">
    $(function(){
$(function () {
    var sourceData = [100,200,300,500];
    var categories = ['18-Jul-14', '19-Jul-14', '20-Jul-14', '21-Jul-14'];
    console.log(fitData(sourceData));
        $('#container').highcharts({
            xAxis: {
                categories: categories
            },
             series: [{
                name: 'RNA - CP ( Radio Network Availability - Customer Perceived)',
                data: sourceData
            },{
                type: 'line',
                name: 'trend',
                data: (function() {
                  return fitData(sourceData).data;
                })()
            }]
      });
});
    });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container"></div>  
   </body>
</html>

Related Tutorials