Sankey diagram in javascript

前端 未结 7 863
灰色年华
灰色年华 2021-02-02 16:22

I want to draw a Sankey diagram using Javascript. Can anyone provide some direction regarding the algorithms or libraries that are available for this?

相关标签:
7条回答
  • 2021-02-02 17:08

    Update 2020:

    For anyone struggling to bring D3 Sankey examples to life, I found this supereasy video tutorial. Worked like a charm for me :)

    https://reactviz.holiday/sankey/

    Also, in case you can't make this one work either, react-google-charts have a pretty nice looking alternative which couldn't be easier to work with (at least implementing the example was just copy-pasting the whole component from here https://react-google-charts.com/sankey-diagram):

    import Chart from "react-google-charts";
    
    
    <Chart
      width={600}
      height={'300px'}
      chartType="Sankey"
      loader={<div>Loading Chart</div>}
      data={[
        ['From', 'To', 'Weight'],
        ['A', 'X', 5],
        ['A', 'Y', 7],
        ['A', 'Z', 6],
        ['B', 'X', 2],
        ['B', 'Y', 9],
        ['B', 'Z', 4],
      ]}
      rootProps={{ 'data-testid': '1' }}
    />
    
    0 讨论(0)
提交回复
热议问题