Number format in Sankey charts

101 views
Skip to first unread message

dunba...@gmail.com

unread,
Nov 29, 2015, 1:06:34 PM11/29/15
to Google Visualization API
Hi, 

I've become a big fan of Google's sankey charts, but one thing is bothering me - I can't figure out how to do number formatting so that the relevant units show up with the numbers in the third data table column. I've tried several approaches - trying to set 'pattern' options, using formatter, but for the life of me nothing seems to work - see this JSFiddle example: http://jsfiddle.net/nickdunbar/t9e3dcy3/1/


Number formatting works so smoothly for the other Google chart types I can't believe that there isn't an option available somewhere. It isn't in the Google documentation. I have looked at the D3 literature but nothing obvious springs out there either. 

All help appreciated. 

NIck 

Sergey Grabkovsky

unread,
Nov 30, 2015, 9:50:25 AM11/30/15
to Google Visualization API
Hi Nick,

We don't have any options for controlling the formatting on the Sankey chart yet. We'll work on improving this for future versions, but you can file a feature request to help remind us.

--
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 http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/b813316e-b1f9-4fc5-b1de-b9099e27c60d%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,
Nov 30, 2015, 9:59:20 AM11/30/15
to google-visua...@googlegroups.com
Hi Sergey, 
What do you think? 
Regards,
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/ax7ITGgcrQY/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 http://groups.google.com/group/google-visualization-api.

Sergey Grabkovsky

unread,
Nov 30, 2015, 10:16:50 AM11/30/15
to google-visua...@googlegroups.com
Oh that's true. I forgot about custom tooltips. Sorry about that; slipped my mind.

If that's enough for your use case, then by all means use them.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Nov 30, 2015, 10:29:49 AM11/30/15
to google-visua...@googlegroups.com
Not at all, I'm happy to share what I find out. You guys have done a great service to the community. Keep up the good work. 

Nick Dunbar

unread,
Nov 30, 2015, 11:41:16 AM11/30/15
to google-visua...@googlegroups.com
One thing that would be helpful to know is how to reinstate the Google default tooltip for Sankey charts along with the customisation. At present, as soon as the custom tooltip is added, the default of 'source -> target' etc disappears. How can I get that back again? Thanks again, Nick 

Sergey Grabkovsky

unread,
Nov 30, 2015, 11:49:36 AM11/30/15
to google-visua...@googlegroups.com
Right, so you can't do that automatically. That's one of the reasons why this solution didn't come to mind; it replaces the entire tooltip, instead of just formatting the value. You'd have to reproduce the formatting yourself.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Nov 30, 2015, 11:56:54 AM11/30/15
to google-visua...@googlegroups.com
So could you do it with two tooltip columns - one for the tooltip text and one for the formatting? Would that reproduce the default while including the additional formatting? Something like this maybe (in pseudocode): 

1st column
data.getValue(source)+'->'+data.getValue(target)
2nd column
formatter.formatValue(data.getValue)

Sergey Grabkovsky

unread,
Nov 30, 2015, 11:59:43 AM11/30/15
to google-visua...@googlegroups.com
I don't understand why you would need two tooltip columns. You can do it with one, you just need a newline between the two things. You'd probably be better off using a DataView and a calculated column than the exact solution you got on stackoverflow, though there's no reason that you can't use that method.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Nov 30, 2015, 12:06:13 PM11/30/15
to google-visua...@googlegroups.com
You're right it only needs one column. But I can't get the newline to work. Putting '\n' inside the quote marks doesn't have any effect. I guess it could be done in HTML with a <br> tag. 

Sergey Grabkovsky

unread,
Nov 30, 2015, 12:32:20 PM11/30/15
to google-visua...@googlegroups.com
Oh I guess you're right. I thought we fixed that issue across all charts, but I guess not. I suppose your only remaining solution is an HTML tooltip with a <br> tag like you said.


For more options, visit https://groups.google.com/d/optout.

Daniel Hinostroza

unread,
Aug 22, 2024, 8:54:21 PMAug 22
to Google Visualization API
It worked for me with </br> instead of <br>
Reply all
Reply to author
Forward
0 new messages