UNPKG

highcharts-regression-slcp

Version:

This allows you to add regression lines to any series. Supports: linear, polynomial, logarithmic, exponential and loess. Calculates the r-value

100 lines (92 loc) 3.04 kB
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/6.0.4/highcharts.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/6.0.4/js/modules/exporting.js"></script> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highcharts/6.0.4/css/highcharts.css"> <script src="../highcharts-regression.js"></script> <script> $(function () { $('#container').highcharts({ chart: { type: 'scatter', zoomType: 'xy' }, 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] ] }, { regression: false, name: 'Test input 2', color: 'rgba(34, 100, 83, .7)', data: [ [1, 4], [2, 3], [3, 5] ] }] }); }); </script> Highcharts Regression <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>