1

I'm currently trying to create a Sankey Diagram in Google Charts to examine the frequency of certain sequences:

LOCATION A -> LOCATION B -> LOCATION C

Where each location is a node, and the arrows contain the frequency that this path occurs. However, I have cases where people return to the same location i.e:

LOCATION A -> LOCATION B -> LOCATION A

Here's an example of what a basic diagram looks like: jsfiddle

But we want to extend it by doing:

data.addRows([
      [ 'A', 'X', 5 ],
      [ 'A', 'Y', 7 ],
      [ 'A', 'Z', 6 ],
      [ 'B', 'X', 2 ],
      [ 'B', 'Y', 9 ],
      [ 'X', 'A', 4 ],
      [ 'X', 'B', 4 ]]);

This does not render with Google Charts because it creates a cycle. How do I bypass this without changing the node name (to A2 and B2)?

ldren
  • 159
  • 5

1 Answers1

2

The documentation explicitly states that cycles are not supported:

Note: Avoid cycles in your data: if A links to itself, or links to B which links to C which links to A, your chart will not render

D3 Sankey chart is able to render cycles though so I'm afraid if you really need cycles, you will have to switch to D3 library. Example how to do it with D3 is here - http://bl.ocks.org/soxofaan/bb6f91d57dc4b6afe91d

DurkoMatko
  • 5,238
  • 4
  • 26
  • 35