streamlinesocial / highcharts-regression

Linear and non-linear regression support for highcharts
MIT License
73 stars 64 forks source link

Adding polynomial regression as a third series to chart with two other series adds an extra (fourth) series!! #108

Closed cosmoKenney closed 3 years ago

cosmoKenney commented 3 years ago

I have a chart with two series -- a line series with markers only (lineWidth: 0) and moving average. But, when I add the polynomial regression to it as a third series, it adds an extra series. So I end up with four series total. One is the polynomial series as I expect it. And the forth is some version of the polynomial series with a lower order, markers and data labels. This is my series config:

            series: [
                {
                    type: 'line',
                    name: 'Rate',
                    id: "Rates",
                    lineWidth: 0,
                    marker: {
                        enabled: true,
                        symbol: "square"
                    },
                    data: seriesData
                },
                {
                    type: 'sma',
                    dataLabels: { enabled: false },
                    linkedTo: 'Rates',
                    color: "#a13034",
                    params: {
                        index: 1,
                        period: 3
                    }
                },
                ({
                    regression: true,
                    regressionSettings: {
                        name: 'trend',
                        type: 'polynomial',
                        color: '#c8dbea',
                        order: 5,
                        regressionSeriesOptions: { dataLabels: { enabled: false } }
                    },
                    data: polyData
                } as any)
            ]

Here is the chart without the polynomial regression series: HC-regression1

And with the polynomial regression series added as a third series. Here you can see my poly series is light-blue and looks like I want it to. But there is an fourth series there also: HC-regression2

Where is the fourth series coming from?

cosmoKenney commented 3 years ago

Okay, I figured it out. Just had to merge the regressionSettings into my first (line) series. HC-regression-fixed