Git Product home page Git Product logo

jsonld-vis's Introduction

JSON-LD visualization

Turn JSON-LD into pretty graphs. See the online example.

Folded view of JSON tree

Partly unfolded view of JSON tree

Fully unfolded view of JSON tree

Usage

See the examples/ folder for usage details.

Import jsonld-vis.js and jsonld-vis.css. The CSS may look better if 'Open Sans' is available as a font (but it will work without it).

To initialize, simply load data into the exported jsonldVis function:

import d3 from 'd3';
import jsonldVis from 'jsonld-vis';
jsonldVis(d3);

d3.json('example.json', (err, data) => {
  if (err) return console.warn(err);
  d3.jsonldVis(data, '#graph', { w: 800, h: 600, maxLabelWidth: 250 });
});

d3.jsonldVis(data, querySelector[, config])

Where the optional config variable is as follows:

{
  h: 600, // height
  w: 800, // width
  maxLabelWidth: 250, // maximum label width
  transitionDuration: 750, // transition duration, in ms
  transitionEase: 'cubic-in-out', // transition easing function
  minRadius: 5 // minimum node radius
  scalingFactor: 2 // factor to scale node sizes
}

Specifying the width is just for initialization purposes. The width of the svg element will dynamically be adjusted as necessary. For horizontal auto-scrolling, the specified querySelector must have horizontal scroll enabled:

query-selector {
  overflow-x: autho;
}

For large data, it may be necessary to adjust the scaling so that node sizes still look reasonable. The scalingFactor allows adjustment of this - larger values of scalingFactor will reduce the maximum node size.

Labels that are longer than maximum label width are truncated; hover over the node to see the full label:

Truncated label Hover text

License

Apache 2.0

jsonld-vis's People

Contributors

staticskies avatar darobin avatar sballesteros avatar

Stargazers

 avatar

Watchers

BigBlueHat avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.