forked from virtualstaticvoid/highcharts_trendline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
77 lines (69 loc) · 2.08 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<title>HighCharts - Scatter with Regression Demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="regression.js"></script>
</head>
<body>
<h2>Linear Regression</h2>
<div id="linear" style="width: 350px; height: 350px;"></div>
<h2>Exponential Regression</h2>
<div id="exponential" style="width: 350px; height: 350px;"></div>
<script type="text/javascript">
// define data array
var sourceData = [
[106.4, 271.8], [129.2, 213.4],
[295.6, 432.3], [154.4, 398.1],
[129.9, 133.2], [271.5, 432.1],
[144.0, 134.7], [176.0, 399.2],
[216.4, 319.2], [194.1, 542.1],
[435.6, 665.3], [348.5, 435.9]
];
var chart_linear = new Highcharts.Chart({
chart: {
renderTo: 'linear'
},
plotOptions: {
series: {
enableMouseTracking: false
}
},
series: [{
type: 'scatter',
data: sourceData
},
{
type: 'line',
marker: { enabled: false },
/* function returns data for trend-line */
data: (function() {
return fitData(sourceData).data;
})()
}]
});
var chart_exponential = new Highcharts.Chart({
chart: {
renderTo: 'exponential'
},
plotOptions: {
series: {
enableMouseTracking: false
}
},
series: [{
type: 'scatter',
data: sourceData
},
{
type: 'spline',
marker: { enabled: false },
/* function returns data for trend-line */
data: (function() {
return fitData(sourceData, 'exponential').data;
})()
}]
});
</script>
</body>
</html>