When I use dotted line style , the display line is lopsidedness.
My suggestion code (take linear regression for example)
`var predata = dataPreprocess(data);
var sumX = 0;
var sumY = 0;
var sumXY = 0;
var sumXX = 0;
var len = predata.length;
var min = 0;
var max = 0;
for (var i = 0; i < len; i++) {
sumX += predata[i][0];
sumY += predata[i][1];
sumXY += predata[i][0] * predata[i][1];
sumXX += predata[i][0] * predata[i][0];
if (max <= predata[i][0]) {
max = predata[i][0];
}
if (min >= predata[i][0]) {
min = predata[i][0];
}
}
var gradient = ((len * sumXY) - (sumX * sumY)) / ((len * sumXX) - (sumX * sumX));
var intercept = (sumY / len) - ((gradient * sumX) / len);
var result = [];
for (var j = Math.floor(min); j < Math.ceil(max); j++) {
var coordinate = [j, gradient * j + intercept];
result.push(coordinate);
}`
When I use dotted line style , the display line is lopsidedness. My suggestion code (take linear regression for example) `var predata = dataPreprocess(data); var sumX = 0; var sumY = 0; var sumXY = 0; var sumXX = 0; var len = predata.length;
It works~~