Skip to content

Polynomial Regression fails when y-axis data contains 0 value #100

@markoberholzer-es

Description

@markoberholzer-es

Description:
Polynomial regression fails when any point has a y-axis value of 0.

Steps to reproduce:
Configure Chart with the following data:
$(function() { $('#container').highcharts({ chart: { type: 'scatter' }, legend: { verticalAlign: 'top', }, series: [{ regression: true, regressionSettings: { type: 'polynomial', order: 2 }, data: [ [1, 50], [5,0], [10, 50] ] }] }); });

Actual Result:
A linear line with the equation of y=0x^x + 0x +50 is drawn

Expected Result:
A polynomial regression curve with the equation of y=2.5x^2 -27.5x + 75 should be drawn

Demo:
http://jsfiddle.net/snoopliving/jxfgst4q/6/

Cause:
Issue is most likely caused at the following line:
https://github.com/streamlinesocial/highcharts-regression/blob/master/highcharts-regression.js#L397

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions