Set values of node labels in Sankey diagram

485 views
Skip to first unread message

William

unread,
Dec 9, 2019, 9:12:24 AM12/9/19
to Google Visualization API
I am trying to create a simple Sankey diagram showing flows between two sets of nodes, and would like the two sets to have the same names. However, this isn't allowed (it brings up a "Cycle found in rows" error), so I add "2" to the names of the nodes in the second set, like so:

     function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'From');
        data.addColumn('string', 'To');
        data.addColumn('number');
        data.addRows([
['foo', 'foo2', 6],
['bar', 'bar2', 4],
['foo', 'bar2', 6],
['bar', 'foo2', 4]
        ]);

        var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
        chart.draw(data);
      }

However, I don't want the node labels to say "foo2" and "bar2" -- I just want them to say "foo" and "bar". In some cases in Google Visualization API you can solve this problem with {v: 'foo2', f: 'foo'} and {v: 'bar2', f: 'bar'}, but that doesn't work here. Is there any way I can do this?

Daniel LaLiberte

unread,
Dec 9, 2019, 9:33:36 AM12/9/19
to Google Visualization API
Hi William,

Your idea of specifying the data with the v and f properties should work, but this chart was not implemented with that in mind.  This is a bug which should not be difficult to fix.   There is no alternative at this time, sorry.

--
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/0396c28a-e895-493e-b56b-87ad7fdd19cd%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages