-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain what flow_selection
does in Bundles (for self-loops)
#21
Comments
Unfortunately I couldn't understand the exception message. Is there an explanation anywhere about how to code self-loops? |
No, this needs better documentation. I'll try to give an example which might help, but really I think it needs a few diagrams to explain! The issue is that it's ambiguous what you want. For example, with these flows:
and these nodes: nodes = {
'start': ProcessGroup(['start']),
'middle': ProcessGroup(['a', 'b']),
'end': ProcessGroup(['end']),
} Then it's ambiguous what to do with the |
I think you probably want to include all the self-flows. You can do that like this: bundles = [
...
Bundle('a', 'a', flow_selection='source != ""'),
...
] Does that do what you want? This isn't very obvious, I agree. Perhaps we could make one of the following changes:
|
First of all, I am sorry for the lack of proper editing. Below is the code I have problems with, and a file with dummy data. The last row in the file (speed,speed,back,4) is the instance of a self loop I need to visualize. Most of my ProcessGroups have several processes. By "self loop" I mean the flows between the same processes, not the flows within the same ProcessGroup between different processes. In this example I have only one self loop (speed -> speed), but in the actual data most of the processes will have such self loops (e.g. main_menu -> main_menu, services -> services, etc.). It is the data about behavior of users in an IVR system, each process is a menu option and a self loop means a repeated listening of an option. I have added a bundle with a flow_selection as you recommended, but it didn't work. I guess, I've missed something. Can you please take a look at my case? File: Code: size = dict(width=1140, height=600) nodes = { ordering = [ bundles = [ level2_part = Partition.Simple('process', [ level1_part = Partition.Simple('process', [ level3_part = Partition.Simple('process', [ nodes['level2'].partition = level2_part sdd = SankeyDefinition(nodes, bundles, ordering) The resulting graph looks almost exactly like the graph of data without a self loop. Difference is highlighted. |
I think there's a bug in d3-sankey-diagram about how the self-loop is drawn -- it is there, but it has very small radius so you can't see it. The workaround is to use a from floweaver import *
size = dict(width=1140, height=600)
level2_part = Partition.Simple('process', [
'my_pp',
'other_pp',
'content',
'mfs',
'settings',
'speed',
])
level1_part = Partition.Simple('process', [
'price_plan', 'services', 'inet'
])
level3_part = Partition.Simple('process', [
'out', 'oper'
])
nodes = {
'mm': ProcessGroup(['main_menu']),
'level1': ProcessGroup(['price_plan', 'services', 'inet'], level1_part),
'level2': ProcessGroup(['my_pp', 'other_pp', 'content', 'mfs', 'settings', 'speed'], level2_part),
'level3': ProcessGroup(['out', 'oper'], level3_part),
'level2_loop': Waypoint(direction='L'),
'level1_return1': Waypoint(direction='L'),
'level2_return2': Waypoint(direction='L'),
'level2_return1': Waypoint(direction='L'),
'mm_return': Waypoint(direction='L'),
}
# I added 2 "layers" to put the return flows more neatly at the bottom
ordering = [
[['mm'], ['mm_return']],
[['level1'], ['level1_return1', 'level2_return1']],
[['level2'], ['level2_loop', 'level2_return2']],
[['level3']],
]
bundles = [
# These are the main flows through
Bundle('mm', 'level1'),
Bundle('mm', 'level3'),
Bundle('level1', 'level2'),
Bundle('level1', 'level3'),
Bundle('level2', 'level3'),
# Return flows to previous stages
Bundle('level1', 'mm', waypoints=['level1_return1', 'mm_return']),
Bundle('level2', 'mm', waypoints=['level2_return2', 'level2_return1', 'mm_return']),
Bundle('level2', 'level1', waypoints=['level2_return2', 'level2_return1']),
# Loops to same stage
Bundle('level2', 'level2', flow_selection='source != ""', waypoints=['level2_loop'])
]
sdd = SankeyDefinition(nodes, bundles, ordering)
weave(sdd, flows).to_widget(**size) I've left the waypoint titles visible so it's easier to see what's going on but you can hide them: nodes = {
'level2_loop': Waypoint(direction='L', title=''),
# ...
} |
Logged in ricklupton/d3-sankey-diagram#16 |
When a Bundle has the same source and target, you need to specify which flows to include.
The text was updated successfully, but these errors were encountered: