For the equation of trendline - here is one answer. https://stackoverflow.com/questions/45413670/google-charts-get-the-equation-of-linear-trendlines
I would also appreciate reference on getting R^2 . On Sunday, March 14, 2021 at 12:02:41 PM UTC-5 [email protected] wrote: > I am trying to use apps script to automatically build charts from a google > spreadsheet, but also project what may happen in the future using > trendlines. I have figured out how to create the chart with a trendline > equation in the title, but I need to do a few more steps: > > > 1. Create multiple types of trendlines (linear, exponential, different > types of polynomials, logarithmic, etc.) > 2. Compare the R^2 values of each trendline and use the one closest to > 1 to do step 3. > 3. Extract the exact equation of the trendline and use it to project > data. > 4. Place data in spreadsheet > > > Here is what I have so far: > > function createChart() { > > var trendlinesopt = { > 0: { > > type: 'linear', > color: 'black', > lineWidth: 1, > opacity: 0.2, > showR2: true, > visibleInLegend: true, > > } > > }; > > var chart2 = formulaSheet.newChart().asScatterChart() > .addRange(formulaSheet.getRange(2,6,15,2)) > .setPosition(1,1,5,5) > .setOption("trendlines",trendlinesopt) > .build(); > > formulaSheet.insertChart(chart2); > > } > > I can generate multiple charts easily, this is just consolidated to the > linear function. How do I extract the R^2 value and the equation of the > trendline? > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/b64c5ee6-cdc6-4322-9e5f-faf91e9c0211n%40googlegroups.com.
