How do I make a Line Chart where values are converted to percentage?

28 views
Skip to first unread message

Mikael Jonsson

unread,
Nov 18, 2019, 9:55:10 AM11/18/19
to Google Visualization API
This might be super easy and I'm just having a temporary blind spot when looking through the documentation. Below is my dummy data. The options is what I need help with. If it's even possible.

var data = google.visualization.arrayToDataTable([

['Blabla', 'Yes', 'Maybe', 'Maybe not', 'Definitely no'],

['2014', 12, 12, 5, 10],

['2015', 10, 8, 8, 2],

['2016', 5, 12, 5, 5],

['2017', 25, 4, 7, 12],

['2018', 16, 10, 11, 8],

['2019', 15, 12, 14, 1]

]);




I want the graph to show the values as percentage of it's total value. So for 2014 the values are (12+12+5+10) 39 and so the "Yes" point should be at ~31 %. (12 of 39).

Do I make any sense? Can someone shed a light on my noobness and help me out?

Thanks in advance!

Mikael Jonsson

unread,
Nov 18, 2019, 10:21:28 AM11/18/19
to Google Visualization API
Just to be clear. The dummy chart in the picture is NOT what I want.

Michael Brown

unread,
Nov 18, 2019, 11:46:21 AM11/18/19
to google-visua...@googlegroups.com
I don't know if the graph supports a percentage view, but it's possible to solve by precalculating each column just like you did, then put the percentage values in the arrayToDataTable call, and scale the graph to 100.

I've had to precalculate my 5 minute solar power values into kilowatt-hours before populating the graph in a similar way

--

Mike Brown

"Driving a gasoline sports car is going to feel like a steam engine with a side of quiche."  Elon Musk


On Mon, Nov 18, 2019 at 10:21 PM Mikael Jonsson <mikael....@gmail.com> wrote:
Just to be clear. The dummy chart in the picture is NOT what I want.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/fcc0b045-5e7d-4bc1-a798-7a6b6874feed%40googlegroups.com.

Mikael Jonsson

unread,
Nov 18, 2019, 3:02:49 PM11/18/19
to Google Visualization API
Thanks, but I want to show exact percentage and how many voted on each tooltip. I need both values. :O/


Den måndag 18 november 2019 kl. 17:46:21 UTC+1 skrev Michael Brown:
I don't know if the graph supports a percentage view, but it's possible to solve by precalculating each column just like you did, then put the percentage values in the arrayToDataTable call, and scale the graph to 100.

I've had to precalculate my 5 minute solar power values into kilowatt-hours before populating the graph in a similar way

--

Mike Brown

"Driving a gasoline sports car is going to feel like a steam engine with a side of quiche."  Elon Musk


On Mon, Nov 18, 2019 at 10:21 PM Mikael Jonsson <mikael...@gmail.com> wrote:
Just to be clear. The dummy chart in the picture is NOT what I want.

--
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-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages