Number format in Sankey charts

103 views
Skip to first unread message
unread,
Nov 29, 2015, 12: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, 8: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 [email protected].
To post to this group, send email to [email protected].
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

[email protected]

Nick Dunbar

unread,
Nov 30, 2015, 8:59:20 AM11/30/15
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 [email protected].

Sergey Grabkovsky

unread,
Nov 30, 2015, 9:16:50 AM11/30/15
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.

Nick Dunbar

unread,
Nov 30, 2015, 9:29:49 AM11/30/15
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, 10:41:16 AM11/30/15
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, 10:49:36 AM11/30/15
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.

Nick Dunbar

unread,
Nov 30, 2015, 10:56:54 AM11/30/15
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, 10:59:43 AM11/30/15
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.

Nick Dunbar

unread,
Nov 30, 2015, 11:06:13 AM11/30/15
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, 11:32:20 AM11/30/15
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.

Daniel Hinostroza

unread,
Aug 22, 2024, 7: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