array-to-relational-converter

This code can create Relational data (nodes,links) for graphs made by D3 js and others from Array of Objects.

Usage no npm install needed!

<script type="module">
  import arrayToRelationalConverter from 'https://cdn.skypack.dev/array-to-relational-converter';
</script>

README

Array to Relational Converter

We can create Relational Data ({ nodes, links }) for graphs from Array of Objects. ([ {}, {} ])

For Relation based graphs, like Force Graph or Sankey we need to have this kind of data structure. Very useful for D3 js visualisations.


Usage

You can find example usage in example.js too.

Method name: createForceFromArray()

const result = createForceFromArray(data, {
    paths:[
        {
            source:'sourceKey',
            target:'targetKey',
        },
        {
            source:'secondSourceKey',
            target:'secondTargetKey'
        }
    ],
    circular:false,
    targetType:"id", //This can be 'id' or 'name' or 'reference'
    includedKeys:['extra'] //Keys connected to nodes
});

Roadmap


Documentation is not detailed yet, because the project in under construction, but i will put more examples and explanation here and in my webpage.