springy icon indicating copy to clipboard operation
springy copied to clipboard

Update readme on how to load JSON with attributes.

Open siuyin opened this issue 8 years ago • 6 comments

Hi, This is just a documentation update which I think Springy users may find helpful.

This just saves them a bit of time in reading the source.

siuyin avatar Dec 25 '16 04:12 siuyin

Hey thanks! This is a feature I've been meaning to add for a while now. :)

I reckon this would be better as something built-in rather than asking users to patch a function in the readme. It looks like you're pretty close to getting it working already.

dhotson avatar Dec 28 '16 23:12 dhotson

Yes, you are right. I thought of preserving the API. With the capability built-in I would need to extend the API -- say with a loadJSONRich command.

A new name is needed so that it does not disrupt the existing users of loadJSON.

siuyin avatar Dec 29 '16 02:12 siuyin

Hmm, do you think it'd be possible to extend the existing loadJSON and still retain compatibility?

Currently nodes are expected to be passed as simple string ids, which makes passing extra metadata difficult. Perhaps nodes could be in an extended format?

e.g.

graph.loadJSON({
  nodes: [
    "a",
    ["b", { label: "B" }] // Maybe like this?
  ],
  edges: [
    ["a", "b", { label: "ab" }], // I think this already works
  ]
});

dhotson avatar Dec 29 '16 03:12 dhotson

Thanks for the insight -- yes, I think that could work... I'll do some experiments.

siuyin avatar Dec 29 '16 03:12 siuyin

Added capability into springy.js and also updated README to reflect changes. Should be ready for merge -- but do remember to update the version number in the README.

Springy 1.2+ also accepts JSON with node attributes see [demo-json.html](http://dhotson.github.com/springy/demo-json.htm

siuyin avatar Dec 29 '16 05:12 siuyin

I would rebase/squash commits and probably split JSON instructions into two parts.

techtonik avatar Mar 16 '17 15:03 techtonik