Basic default settings: linear regression with equation in the legend - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Basic default settings: linear regression with equation in the legend

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Regression Tooltip Tes</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function() {//from www .  jav a  2  s  .c  om
    $('#container').highcharts({
        chart: {
            type: 'scatter',
            zoomType: 'xy',
            events: {
                load: function() {
                    this.series[1].update({
                        enableMouseTracking: false
                    })
                }
            }
        },
        title: {
            text: 'Basic default settings: linear regression with equation in the legend'
        },
        subtitle: {
            text: 'Source: Heinz  2003'
        },
        xAxis: {
            title: {
                enabled: true,
                text: 'Height (cm)'
            },
            startOnTick: true,
            endOnTick: true,
            showLastLabel: true
        },
        yAxis: {
            title: {
                text: 'Weight (kg)'
            }
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            verticalAlign: 'top',
            x: 100,
            y: 70,
            floating: true,
            backgroundColor: '#FFFFFF',
            borderWidth: 1
        },
        plotOptions: {
            scatter: {
                marker: {
                    radius: 5,
                    states: {
                        hover: {
                            enabled: true,
                            lineColor: 'rgb(100,100,100)'
                        }
                    }
                },
                states: {
                    hover: {
                        marker: {
                            enabled: false
                        }
                    }
                },
                tooltip: {
                    headerFormat: '<b>{series.name}</b><br>',
                    pointFormat: '{point.x} cm, {point.y} kg'
                }
            }
        },
        series: [{
            regression: true,
            name: 'Test input',
            color: 'rgba(223, 83, 83, .5)',
            data: [
                [1, 1],
                [2, 3],
                [3, 9],
            ],
            regressionSettings: {
                enableMouseTracking: false
            }
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <script src="http://rawgithub.com/phpepe/highcharts-regression/master/highcharts-regression.js?8">

      </script>
       Highcharts Regression 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials