Official Charts Opinion Question: How would you like to retrieve your trendline data?

2090 views
Skip to first unread message

Sergey

unread,
Oct 28, 2014, 2:33:35 PM10/28/14
to google-visua...@googlegroups.com

Dearest Google Charts users,


We have been working hard on improving charts, and now need your input. We are considering adding a few methods to our corecharts to help you get data about your trendlines, such as the r^2 value. However, we're not quite sure how you’ll want to use them. We know that we want a method to get the trendline r^2 value, and we think that getting an evaluator function for a trendline would be useful as well; but we also want to give you the ability to pull out the trendline expression. Here's where things get a bit blurry.


We could do the simple thing, and simply create a method that returns the plaintext equation. This would allow you to show the equation elsewhere on the page. You might also parse it, but parsing can be hard, so we’ll provide some utilities to help with that. Some alternatives to mitigate this issue would be:

  • to return a JSON form an abstract syntax tree of the equation, an example might be:

    • y = 2x + 1: {operation: '=', operands: ['y', {operation: '+', operands: [{operation: '*', operands: [2, 'x']}, 1]}]}

  • to return a Lisp/Scheme-like abstract syntax tree, using arrays and prefix notation. An example of that might be:

    • y = 2x + 1: ['=', 'y', ['+', [2, 'x'], 1]]

  • to return an array of coefficients, possibly with the type of the trendline:

    • 2x + 1: {type: 'linear', coefficients: [2, 1]}

    • exp(5x + 3): {type: 'exponential', coefficients: [5, 3]}


We can also return an abstract syntax tree as well as a plaintext form, though that is getting a bit redundant. So, what are your thoughts here? Your opinions are most welcome.


Happy Coding,

Sergey and the rest of the Google Charts Team


northatl...@mac.com

unread,
Nov 3, 2014, 1:12:49 PM11/3/14
to google-visua...@googlegroups.com
Sergey

I rather like your curve fitting charts - in fact I think the whole Charts product is really well done - so thanks for a lot of great work. 

One use I have been making of your trendlines  is to simply fit curves to data points with the intention of then using the results inside a new piece of javascript that makes use of the equation. Typically the coefficients one generates are not nice round numbers so its really helpful if one can just cut and paste them into one's javascript to avoid transcription errors. In fact being able to cut and paste an expression which included the coefficients that was in javascript would be really useful - its so easy to make a minor error and its quite hard to check. So I think I'm saying an array of coefficients would be really helpful but also some sort of standard output which one could have appear in the chart on screen which could be scraped off the screen and pasted into some code would work for me.

What would be REALLY awesome would be the ability to do multiple non-linear regression and then have the coefficients of the model in a form where they could be assigned to javascript variables. That way it would be possible to build something that got a better and better fit as more data were fed its way instead of doing the analysis off-line and updating things from time to time. Sorry - thats not what you asked - but hey, I just thought I would mention it.

Cheers,

Bryan
Message has been deleted

Travis Finlay

unread,
Feb 10, 2015, 9:43:38 PM2/10/15
to google-visua...@googlegroups.com
I would like an array of coefficients.  Its much easier to understand to me than the other two options.  Currently I calculate the trendline myself (3rd - 6th order polynomial) and store the resulting coefficients in an array.  I then have to create a dataset using the equation to graph over the original dataset to check the fit visually (I think.  I'm still working on this).  The trendline function is then used in later calculations.

Getting the equation output directly from the trendline option would save me a bunch of work.

Joshua Sharf

unread,
Apr 7, 2015, 10:57:29 AM4/7/15
to google-visua...@googlegroups.com
Sergey,

I also like the idea of an array of coefficients.  Not only would it be easier to do calculations on, but it lends itself to adding additional fit information later on, such as the confidence intervals, or the goodness-of-fit measures.

Joshua

anders.hi...@gmail.com

unread,
May 5, 2015, 7:03:41 AM5/5/15
to google-visua...@googlegroups.com
Hi!
I really like the trendline functionality. I need to the trendline functions to calculate forecast values. Some sort of function where you could add a "x-value" and the function returns the y value would be great for me. Is this sort of functionality coming to the api or should I look else ware. 
/Anders
Message has been deleted

Theo Ekelmans

unread,
Jun 5, 2015, 3:19:48 AM6/5/15
to google-visua...@googlegroups.com
Hi,

I was wondering.... 

Why not go at it like this: let us select out ot of a list of a set of matching algorithms and provide a dataset, you guys run the dataset through all of these determining ftting scores and generate the graph using the best fitting one, and return some numeric data describing the best fittng algorithm?

This way it would be much simpeler for the non-math geeks like me :)

Theo 
NL

Op dinsdag 28 oktober 2014 19:33:35 UTC+1 schreef Sergey:

dunba...@gmail.com

unread,
Jan 22, 2016, 11:07:13 AM1/22/16
to Google Visualization API
Hi Sergey, 
I wanted to resuscitate this thread because I had a couple of questions. 

Firstly, what is the current official method for exporting trendline data? I know that your API stores the information because it appears in the trendline tooltip. Suppose I want to get that information in an array? Or how would I go about generating a series of trendline data points that I can plot separately? This is important to me in a current application where I need to store scatter chart trendlines from mulitple datasets in their own dataTable which I can use separately to generate line charts. 

The second question is whether you have given any thought to including spline fitting functionality in your trendlines. Here the use scenario might be that I want to use a cubic polynomial for data domain X: {0,10} and a linear trendline for X>10, with a spline fit to join them together. 

All feedback appreciated. 

Nick 

Sergey Grabkovsky

unread,
Jan 22, 2016, 2:04:02 PM1/22/16
to Google Visualization API
Hi Nick,

Thanks for your message.

We currently don't have any way of exporting trendline data. The entire purpose of this thread was to figure out what data people actually wanted. However, it seemed to me that the thread didn't reach consensus, and some of the posts were just flatout off-topic.

So to answer your questions, you currently cannot extract the trendline data from a chart. If you need this today and are unwilling to wait for us to implement the trendline retrieval API (which could take a while), you would have to implement your own linear regression, and compute the trendline yourself.

As for your second question, we have not given any thought to piecewise trendlines. We will consider this feature for inclusion in the API when we start work on implementing multiple trendlines for the same series.

--
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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/3d24532b-df2b-4894-a0dc-c6bf6e4db97e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

unnamed.gif

Sergey Grabkovsky

Software Engineer

Google, Inc

gra...@google.com


Nick Dunbar

unread,
Jan 22, 2016, 5:45:48 PM1/22/16
to google-visua...@googlegroups.com
Hi Sergey, 

Thanks for getting back to me. 

It would be great if something could be done on the trendline export. Even if it is just a hack (as I said, you do have the info already in the tooltip). 

For what it's worth here is my two cents. It was a nice gesture to ask everyone 15 months ago what they wanted. But you are Google. You can do anything you like. What ever you do, people will figure it out. But please, please just do something. 

Best, 

Nick 

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/vHSBJPvIANo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

krishna prasad

unread,
Mar 1, 2016, 12:32:04 AM3/1/16
to Google Visualization API
Dear Sir,

My Chart output should be http://onnetsourcing.com/vivera/chart.html . Here I have manually added the data in the code. Actually this process should be automatic. I have taken data from mysql table but I could not enter the data in the matrix format. Please help me to get the data for this chart in matrix format or any other technique. The chart should be as in the given URL. Please help me on this.

In A block if 1 floor in completed which should go one up. Please help me to get this done. 

Regards,
Krishnaprasad PB

Bob Rozelle

unread,
Apr 25, 2016, 9:14:41 AM4/25/16
to Google Visualization API

Sergey,


I am interested in being able to apply a trendline by equation rather than by data-points.  I am looking at ways to visualize big data predictive analysis and have the charting provide a representative scatter chart plus my predicted trendline where I provide the equation plus all the statistical information I want to display.  I am starting out visualizing simple regressions, but plan on moving on to more complex predictions in the future.

Thanks,
Bob

relief...@gmail.com

unread,
Jun 20, 2016, 4:51:12 AM6/20/16
to Google Visualization API
Hi Sergey,

funny I was just searching for a method to do this. It would be great to return the plane Formula, but maybe one of the simplest additional functions would be a method where i hand over an X or Y-Value and the function returns the trendline-value. It looks like this post has been here for a while, is there already something new concerning this topic? Thanks for the support and

Greetings Chris

Humble Millennial

unread,
Nov 18, 2016, 1:56:37 PM11/18/16
to Google Visualization API
I would suggest the 3rd option, return an array of coefficients. You can quickly determine the order and access the coefficients efficiently.

Nick Dunbar

unread,
Jan 6, 2017, 4:38:44 PM1/6/17
to Google Visualization API
Have you made any progress on this yet? You asked the question over two years ago. We gave you some feedback. Your indecision would make Hamlet proud. 
Just sayin...
Nick 



On Tuesday, October 28, 2014 at 6:33:35 PM UTC, Sergey wrote:
Message has been deleted

Csaba Toth

unread,
Sep 30, 2017, 11:41:11 PM9/30/17
to Google Visualization API
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

Pat Ng

unread,
Aug 24, 2021, 12:34:23 PMAug 24
to Google Visualization API
Csaba, have the same wish for extracting the simple linear fit equation from trendline (top chart), and recast trendline overlay on histogram (bottom chart).

Q: any update or alternate pathway to accomplish that using Google Chart?

Google_trendline_eqt.PNG
Reply all
Reply to author
Forward
0 new messages