Google Charts Manually add Trendline

5.9k Views Asked by At

Google added Trendlines to Google Charts. It's nice and you just give the point coordinates and it will automatically calculate the trend line. It's nice but I need to add the trendline manually. Do you know if there is any possibility? A combination of both, scattered chart and line chart is sadly not possible I think so I have to do it with trend line.

Thank you.

https://developers.google.com/chart/interactive/docs/gallery/trendlines

1

There are 1 best solutions below

1
On BEST ANSWER

You cannot specify your own trendline. If you can calculate your own, you can add it to a LineChart as an additional data series. You can fake a ScatterChart with a LineChart by setting the series.<series index>.pointSize option to something larger than 0 and the series.<series index>.lineWidth option to 0.

series: {
    0: {
        // "scatter" series
        pointSize: 3,
        lineWidth: 0
    },
    1: {
        // "trendline" series
    }
}