SVG Sparklines

Hy there,
I needed some kind of sparkline for an application and decided to use SVG image to get it.
I donโ€™t know if it will be the best way, or if anyone has a better solution.
To create the image I used a formula in Gsheet:

Blockquote
=โ€œdata:image/svg+xml;utf8,<svg xmlns=โ€โ€œhttp://www.w3.org/2000/svgโ€" preserveAspectRatio="โ€œxMidYMin meetโ€" viewBox=""-5 -5 118 โ€œ&MAX(B7:G7)*10+20&โ€ โ€œโ€ width="โ€œ100%โ€" height="โ€œ100%โ€" >
<line x1="โ€œ3"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ3"โ€ y2="""&(MAX(B7:G7)-((B7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<line x1="โ€œ23"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ23"โ€ y2="""&(MAX(B7:G7)-((C7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<line x1="โ€œ43"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ43"โ€ y2="""&(MAX(B7:G7)-((D7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<line x1="โ€œ63"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ63"โ€ y2="""&(MAX(B7:G7)-((E7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<line x1="โ€œ83"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ83"โ€ y2="""&(MAX(B7:G7)-((F7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<line x1="โ€œ103"โ€ y1="""&MAX(B7:G7)10&""" x2="โ€œ103"โ€ y2="""&(MAX(B7:G7)-((G7MAX(B7:G7)))/MAX(B7:G7))*10&""" style="โ€œstroke:blue;stroke-width:6"โ€ />
<text x="โ€œ0"โ€ y="""&MAX(B7:G7)*10+10&""" fill="โ€œredโ€" font-size="โ€œ9"โ€ font-family="โ€œVerdanaโ€">"&B7&" <tspan x="โ€œ20"โ€ y="""&MAX(B7:G7)*10+10&""">"&C7&" <tspan x="โ€œ40"โ€ y="""&MAX(B7:G7)*10+10&""">"&D7&" <tspan x="โ€œ60"โ€ y="""&MAX(B7:G7)*10+10&""">"&E7&" <tspan x="โ€œ80"โ€ y="""&MAX(B7:G7)*10+10&""">"&F7&" <tspan x="โ€œ100"โ€ y="""&MAX(B7:G7)*10+10&""">"&G7&" <line x1="โ€œ0"โ€ y1="""&MAX(B7:G7)*10+1&""" x2="โ€œ108"โ€ y2="""&MAX(B7:G7)*10+1&""" style="โ€œstroke:rgb(1,1,1);stroke-width:0.5"โ€ /> "

Blockquote

Not the best solution but I didnโ€™t find a way to do it in Appsheet. If anyone can help me, I appreciate it.

The end result is something like this:

5 8 1,830
8 REPLIES 8

@Jonathon has lots of SVG experience and might like this example as well.

Update:
I think using the Google API (deprecated in 2012, but it work) we got a better solution.
https://developers.google.com/chart/image/docs/making_charts

Here is a comparison between the two options, using a virtual column with the formula:

"https://chart.googleapis.com/chart?cht=bvs:nda&chs=180x100&chd=t:"
   &[V_0]&","&[V_1]&","&[V_2]&","&[V_3]&","&[V_4]&","&[V_5]& "&chco=0000FF&chm=N,ff0000,0,-1,9,,e::10|o,ff0000,0,-1,6"

I hope it is useful for someone.

This is great, thanks @Sergio_Sa!

Hi @Sergio_Sa,

Earlier @Jonathon had shared some interesting charting possibilities with SVG. Now you have further extended it by adding Google Chart APIs. Thank you both for sharing these interesting charting possibilities insights.

Youโ€™re welcome @Peter and @Suvrutt_Gurjar . Good thing itโ€™s useful.

I am still learning how to work with Appsheet and have realized that there are so many possibilities that we ended up doing more than we initially anticipated.

The possibility exists, getting it is more difficult.

Would this be possible also with https://quickchart.io/ ?

Thatโ€™s really really neatโ€ฆ Do you think if the whole community starts using it, we could rate limit since all the calls would be coming through appsheet? Regardless itโ€™s even cheap to host if thatโ€™s an issueโ€ฆ Really cool find!

โ€œThere is a built-in rate limit of 240 charts/min (4 charts/sec) per IP.โ€

Top Labels in this Space