Reading DOT files in javascript/d3

前端 未结 4 888
眼角桃花
眼角桃花 2020-12-12 15:28

Is there a standard way to read and parse DOT graph files in javascript, ideally in way that will work nicely in d3?

Currently, the only thing I can think of doing i

4条回答
  •  悲哀的现实
    2020-12-12 16:02

    The question asks for a possibility to visualise .dot files einther in javascript or D3js. I think the solution from the highest rated answer will work for most of you.

    I was unhappy because of these 3 reasons:

    1. It involves libraries like lowdash, dagre and graphlib additionally to D3js and is heavyweight.
    2. Parser output is not a D3js "friedly" data-structure.
    3. Usage (API) in not D3js style.

    That's why I created an adapter which will basically allow you to use .dot files with any of thousands of D3js samples by changing just one statement. If you have some D3js visualisation working on following data-structure:

    {
      "nodes": [ {"id": "Myriel"}, {"id": "Napoleon"}],
      "links": [ {"source": "Myriel"}, {"target": "Napoleon"}]
    } 
    

    Just include following script and call d3.dot:

    
    
    

    instead of:

    d3.json(url, function(graph) {...});
    

    GitHub repository with code and examples

提交回复
热议问题