ramnathv / rCharts

Interactive JS Charts from R
http://rcharts.io
Other
1.19k stars 655 forks source link

Multilevel sankey diagrams on ragged levels #425

Open smartinsightsfromdata opened 10 years ago

smartinsightsfromdata commented 10 years ago

I'm trying to build a sankey diagram in D3 / rCharts. The problem is that the chart is not only multilevel, but it is on ragged level. I described the issue with attachments here https://groups.google.com/forum/#!topic/shiny-discuss/wnMfEBS7-_Q

I've found a similar post with a reply from Mike Bostock here https://groups.google.com/forum/#!topic/d3-js/TOgwGwDNJxc

Apparently there are functions like below: moveSourcesRight(x); moveSinksRight(x); But no API (as of the date of the post).

There is also this article on SOF that propose a solution via padding http://stackoverflow.com/questions/18653784/d3-sankey-is-it-possible-to-affect-or-decide-the-placement-of-nodes

I think if this was managed the sankey diagrams would be much more useful and meaningful (as in the example of Georgia bills I've attached to my post).

Is there a chance to do anything? Personally I would just add a column representing the desired level on the X axis (from left to right)...

Enzo

ramnathv commented 10 years ago

@enzoma I think it would be great if this feature can be added. However, I don't think I have the bandwidth currently to explore this. I am copying @timelyportfolio and @benjh33 who are very adept with creating new rCharts libraries to see if they have some time to take a look at this.

bjameshunter commented 10 years ago

I was just about to have a look at how sankey diagrams are made. I haven't looked at them at all, other than playing with the examples.

@enzoma, can I have a look at your data?

On a related note, I just finished this zoomable treemap, which I think uses a similar layout. I have a problem with it described here: http://stackoverflow.com/questions/23862023/allowing-empty-values-in-d3-nest. There's a fiddle link in the question. I was going to hit up @ramnathv and @timelyportfolio to have a look at it when they have time. I think it's a similar problem - the code expects every node to have the same number of branches, so I have to expand.grid and insert zeros where there's no data. That is, the data are ragged.

smartinsightsfromdata commented 10 years ago

Hi Ben

Please find attached (dummy) data that support what I am trying to represent. I will also describe the data, relative to a police force "business flow" (it could be a sales office or similar):

In summation, a multi-level sankey diagram where all starts on the left end side and all terminates to the right end side is of limited usefulness. I think a way to specify either source or sink level (or both like in the attached spreadsheet) would be ideal.

Any suggestion is welcome. Let me know what you think!

Thanks

Enzo

On 27 May 2014 16:10, Ben Hunter notifications@github.com wrote:

I was just about to have a look at how sankey diagrams are made. I haven't looked at them at all, other than playing with the examples.

@enzoma https://github.com/enzoma, can I have a look at your data?

On a related note, I just finished this zoomable treemaphttp://mostlyconjecture.com/2014/05/25/zoomable-treemap-with-rcharts/, which I think uses a similar layout. I have a problem with it described here: http://stackoverflow.com/questions/23862023/allowing-empty-values-in-d3-nest. There's a fiddle link in the question. I was going to hit up @ramnathvhttps://github.com/ramnathvand @timelyportfolio https://github.com/timelyportfolio to have a look at it when they have time. I think it's a similar problem - the code expects every node to have the same number of branches, so I have to expand.grid and insert zeros where there's no data. That is, the data are ragged.

— Reply to this email directly or view it on GitHubhttps://github.com/ramnathv/rCharts/issues/425#issuecomment-44289290 .

bjameshunter commented 10 years ago

Did you see this?

http://stackoverflow.com/questions/21539265/d3-sankey-charts-manually-position-node-along-x-axis

It was pretty easy to just add the lines as he suggests, define an xPos variable and place the nodes arbitrarily. Is that what you want?

On Tue, May 27, 2014 at 9:32 AM, Enzo notifications@github.com wrote:

Hi Ben

Please find attached (dummy) data that support what I am trying to represent. I will also describe the data, relative to a police force "business flow" (it could be a sales office or similar):

  • the main entry point is the call centre (999 or similar emergency number). These call may be routed to other entities (e.g. Fire Brigade), or go to the response team that once on site will further dispatch the call on the presumption of one or many crime types.
  • there are potentially other entry points, e.g. coming from investigations. These shouldn't be at the same level on the X axis, as they are more mature.
  • Of course any investigation or incident can be dropped (for a variety of good reasons) at any point in time in the flow. I do not think that anything should just flow to the extreme right: if an investigation or similar is dropped earlier in the process, the "box" referring to "dropped" should be mapped in different positions in the flow (all the "dropped" boxes will all have a subtle difference between them: the more they are mapped to the right the more resources they will have absorbed).

In summation, a multi-level sankey diagram where all starts on the left end side and all terminates to the right end side is of limited usefulness. I think a way to specify either source or sink level (or both like in the attached spreadsheet) would be ideal.

Any suggestion is welcome. Let me know what you think!

Thanks

Enzo

On 27 May 2014 16:10, Ben Hunter notifications@github.com wrote:

I was just about to have a look at how sankey diagrams are made. I haven't looked at them at all, other than playing with the examples.

@enzoma https://github.com/enzoma, can I have a look at your data?

On a related note, I just finished this zoomable treemap< http://mostlyconjecture.com/2014/05/25/zoomable-treemap-with-rcharts/>, which I think uses a similar layout. I have a problem with it described here:

http://stackoverflow.com/questions/23862023/allowing-empty-values-in-d3-nest.

There's a fiddle link in the question. I was going to hit up @ramnathv< https://github.com/ramnathv>and @timelyportfolio https://github.com/timelyportfolio to have a look at it when they have time. I think it's a similar problem - the code expects every node to have the same number of branches, so I have to expand.grid and insert zeros where there's no data. That is, the data are ragged.

— Reply to this email directly or view it on GitHub< https://github.com/ramnathv/rCharts/issues/425#issuecomment-44289290> .

— Reply to this email directly or view it on GitHubhttps://github.com/ramnathv/rCharts/issues/425#issuecomment-44300629 .

smartinsightsfromdata commented 10 years ago

Hi Ben

I am aware of the post (it was attached to my original email to the shiny mail group). The problem I have with this are:

The above issues prevent, in my mind, a much larger utilisation of the chart.

I home it makes some sense. What do you think of the issue?

(any suggestion on alternative charts will also be welcome!)

Many thanks in advance

Enzo

On 28 May 2014 04:55, Ben Hunter notifications@github.com wrote:

Did you see this?

http://stackoverflow.com/questions/21539265/d3-sankey-charts-manually-position-node-along-x-axis

It was pretty easy to just add the lines as he suggests, define an xPos variable and place the nodes arbitrarily. Is that what you want?

On Tue, May 27, 2014 at 9:32 AM, Enzo notifications@github.com wrote:

Hi Ben

Please find attached (dummy) data that support what I am trying to represent. I will also describe the data, relative to a police force "business flow" (it could be a sales office or similar):

  • the main entry point is the call centre (999 or similar emergency number). These call may be routed to other entities (e.g. Fire Brigade), or go to the response team that once on site will further dispatch the call on the presumption of one or many crime types.
  • there are potentially other entry points, e.g. coming from investigations. These shouldn't be at the same level on the X axis, as they are more mature.
  • Of course any investigation or incident can be dropped (for a variety of good reasons) at any point in time in the flow. I do not think that anything should just flow to the extreme right: if an investigation or similar is dropped earlier in the process, the "box" referring to "dropped" should be mapped in different positions in the flow (all the "dropped" boxes will all have a subtle difference between them: the more they are mapped to the right the more resources they will have absorbed).

In summation, a multi-level sankey diagram where all starts on the left end side and all terminates to the right end side is of limited usefulness. I think a way to specify either source or sink level (or both like in the attached spreadsheet) would be ideal.

Any suggestion is welcome. Let me know what you think!

Thanks

Enzo

On 27 May 2014 16:10, Ben Hunter notifications@github.com wrote:

I was just about to have a look at how sankey diagrams are made. I haven't looked at them at all, other than playing with the examples.

@enzoma https://github.com/enzoma, can I have a look at your data?

On a related note, I just finished this zoomable treemap< http://mostlyconjecture.com/2014/05/25/zoomable-treemap-with-rcharts/>, which I think uses a similar layout. I have a problem with it described here:

http://stackoverflow.com/questions/23862023/allowing-empty-values-in-d3-nest.

There's a fiddle link in the question. I was going to hit up @ramnathv< https://github.com/ramnathv>and @timelyportfolio https://github.com/timelyportfolio to have a look at it when they have time. I think it's a similar problem - the code expects every node to have the same number of branches, so I have to expand.grid and insert zeros where there's no data. That is, the data are ragged.

— Reply to this email directly or view it on GitHub< https://github.com/ramnathv/rCharts/issues/425#issuecomment-44289290> .

— Reply to this email directly or view it on GitHub< https://github.com/ramnathv/rCharts/issues/425#issuecomment-44300629> .

— Reply to this email directly or view it on GitHubhttps://github.com/ramnathv/rCharts/issues/425#issuecomment-44363174 .

ignacio82 commented 9 years ago

Is it possible to make a treemap with rCharts? http://mostlyconjecture.com/2014/05/25/zoomable-treemap-with-rcharts/ is down

Thanks!