c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.34k stars 1.39k forks source link

Sankey Diagrams #795

Open benoist opened 9 years ago

benoist commented 9 years ago

Hi,

I would like to request Sankey Diagrams as a chart type.

Cheers, Benoist

aendra-rininsland commented 9 years ago

Might not be too hard, D3 has a really good Sankey plugin (Just used it, actually...).

Three questions:

  1. How frequently do you use Sankey charts? Is the added convenience of having them in D3 worth the extra bloat to the codebase? Does providing Sankey charts improve the utility of C3 to its general user base?
  2. What would abstracting it into C3 provide that D3 alone cannot? For line charts, C3 saves time by providing baked-in axes, scales, colour configs and interactions — Sankey diagrams don't have axes, and interactions are a bit confusing due to most of the data being in a path (By this I mean, you click a path — what data is in the tooltip, if there even is one?).
  3. Given the existing data API in C3, how would you structure data? D3's Sankey plugin requires an object containing two objects, nodes and links. Short of providing C3 with data already in that structure, how would the relational (i.e., node/link) format fit in with the columns and rows methods?
benoist commented 9 years ago

Question 1 and 2 are valid questions. I think that this would be a good addition to the library. The benefit for me would be one less dependency, similar API to my other charts and same color configs.

My suggestion on how to use columns and rows would be:

Column 1: source label Column 2: target label Column 3: weight

[ ["node1", "node2", 50],
  ["node1, "node3", 50],
  ["node2, "node4", 100],
  ["node3, "node4", 25]]
aendra-rininsland commented 9 years ago

Seems reasonable enough. If the plugin API ever comes to fruition, this would be a terrific candidate for that — all the benefit of the above, without adding any weight to the core library.

benoist commented 9 years ago

I agree that this is a better candidate for a plugin to C3

aendra-rininsland commented 9 years ago

The plugin architecture is kind of in-progress at the moment; if you wish to contribute to that effort, we'd welcome the help! More info at #351.

aendra-rininsland commented 9 years ago

Due to this relying on a working plugin infrastructure, I'm adding on hold and closing until #351 is complete.

aendra-rininsland commented 9 years ago

Reopening after discussion with @masayuki0812 re: how to handle on hold issues.