Sparklines Help

I have a column that has spark lines. Is there a way to visualize those in an app? It seems anything I do, the columns shows the sparkline in sheets but is empty when viewing the data in Glide itself.

Hola @Craig_Greiner,

I am not familiar with Sparklines but if this is something that you created in GS, I don’t think Glide knows how to read it and show it in the app.

I might be wrong though.

The sparkline formula would only show it in the Sheet, same with image formula.

Consider formatting your data the right way to use Quickchart’s sparkline here.

https://quickchart.io/documentation/#sparkline

3 Likes

I am trying to create a sparkline based on google finance data to show a 30 day stock trend. Do you know of a way to do that in quickchart?

1 Like

If you construct an URL like this:

https://quickchart.io/chart?c={type:'sparkline',data:{datasets:[{data:[140,60,274,370,199]}]}}

Replace your data into the datasets part, then you can display them inside Glide using that same URL.

It’s just a matter of building a template column in the proper format with the url and all joined together into one string of text, like this:

https://quickchart.io/chart?c={type:'sparkline',data:{datasets:[{data:[140,60,274,370,199]}]}}

and use the template column as the source of an image component to get this.

Since you are using google finance data, you could probably create the url with google sheet formulas too, but it’s just easier within glide.

3 Likes

I understand the quickchart format, but does it work without feeding the URL actual numbers?

In your example you have:

https://quickchart.io/chart?c={type:‘sparkline’,data:{datasets:[{data:[140,60,274,370,199]}]}}”

But I do not have the:
140,60,274,370,199

If I had those readily available, it would be a much easier task.

I may be able to generate them, but what I rather do replace those numbers with a google finance formula that generates them on the fly. Otherwise I have to store the numbers somewhere.

Is that possible?

But you already have to store them in the Sheets, so I assume you can join them together using a join text and then a template to combine it with the quickchart format.

1 Like

I do not have the data already. That is the beauty of the sparkline and googlefinance combo in sheets. I can put this formula in a cell:

=sparkline(GOOGLEFINANCE(A2,“price”,today()-180,Today(),“weekly”),{“charttype”,“line”;“linewidth”,2;“color”,"#5f88cc"})

replacing A2 with a stock ticket and I get this output directly in the cell:

image

That represents the weekly price of a stock for the last 180 days. I did not have to store the weekly price values to generate the sparkline. Now, I would simply like to display that image in a Glide App.

If I use quickcharts, I have to store the individual values to feed into the URL which would mean columns and columns of data.

Just take out the the sparkline part thats wrapped around the google finance formula. Then you will get numbers that you can use for quickcharts.

It is not that simple.

If I run the google finance call on its own, you get an array (table) of data with dates and prices a

image

Even if I just bring back the price column, I get this:

image

There is not way to feed this direct to a quickchart that I can find without having to dsiplay the values in the google sheet which I cannot do the way my data is formatted.

For example, this does not work

https://quickchart.io/chart?c={type:‘sparkline’,data:{datasets:[{data:[INDEX(GOOGLEFINANCE(“BB”,“price”,today()-30,Today(),“daily”),2)]}]}}

IT does not pass the data from google finance back to quick charts dynamically

Any more thoughts?

Simple with the right formulas. :wink: Use something like this to get your list of numbers.

=JOIN(",", TRANSPOSE(QUERY(INDEX(GOOGLEFINANCE("MMM","price",today()-180,Today(),"weekly"),"",2), "SELECT * OFFSET 1",0)))

Then wrap that with the rest of the quickchart url so you end up with something like this.
https://quickchart.io/chart?c={type:'sparkline',data:{datasets:[{data:[158.33,166.1,161.71,165.66,165.77,166.17,169.55,160.27,160.36,169.3,170.97,169.8,159.96,163.02,169.79,172.89,176.89,172.46,174.02,176.42,174.52,174.79,166.62,165.55,169.04]}]}}

To get this.

2 Likes

ok…

So I follow the transpose to get my list of values in the correct format.

But then it looks like you still had to manually copy those values into the quickchart URL. For example, if I generate that list in cell A2 in an google sheet, I cannot just replace the data range with A2 and it work.

Similarly, I cannot place the formula within the URL link:

https://quickchart.io/chart?c={type:‘sparkline’,data:{datasets:[{data:[JOIN(",", TRANSPOSE(QUERY(INDEX(GOOGLEFINANCE(“MMM”,“price”,today()-180,Today(),“weekly”),"",2), “SELECT * OFFSET 1”,0)))]}]}}

That above does not work.

Am I missing something?

How do I automatically feed the list of values I generate into the URL?

And THANK YOU!

No, I didn’t manually copy the values. I’m just showing the result of another column that joins the beginning and end of the url with the formula result. In my sheet I just did ="urlstart" & A2 & "urlend" as a crude example.

You could do the same thing with yours, and instead of A2, put in the formula instead. In your example, you are not properly joining separate strings of text together.

Nothing is manually done except for the need to copy the formula to each line. The rest of it is built dynamically. Alternately, you could also use a template column in glide to build out the url by joining the url to the data, but since you are using a googlefinance formula in the sheet, there isn’t much of an advantage except for making your sheet formulas look cleaner.

Just to add, on top of what I mentioned above, you would replace the manually entered ticker symbol with the column that contains the symbol, like this.
...GOOGLEFINANCE(A2,"price",to...

2 Likes

First off…thank you! I have wanted this capability for months and finally had time to dig into it but could not solve it. You helped me makes months of progress in hours.

I was concatenating URLs in other cells dynamically and really should have seen that I could do the same here. It was right in front of me, but I could see it. Again, thank you!

I will have to share hte APP link here in a bit when I polish a few things.

One last question though…

Do I add this column in as a Webpart, Image, etc?

1 Like

You use it as an image. Even though it doesn’t have .jpg or .png in the url, it’s still treated as an image url.

Got it. While still something I am working through, this is the link to the app:

Not sure how much you can see as it is a pro app and locked down by email adress access

I too have been trying to make get a sparkline image / graph into my app.
Mine is for Currency trend between 2 currencies - I can get a trend graph in Google Sheet to show but it just shows a black cell in the Glide Table.
I have read all I can find and tried to make it work but it just does not make any sense to me!

This is the code in a Google sheet - any guidance would be much appreciated…