jsoncanvas icon indicating copy to clipboard operation
jsoncanvas copied to clipboard

Proposal: Edges additional properties

Open chainlist opened this issue 2 years ago • 4 comments

I think some properties are missing to have the JSONCanvas standard to be adopted by awider range of apps.

type property

It would be a good addition to have another property on the Edge object:

type which could have those values:

  • sharp for sharp turns
  • curved for smooth turns (the default one)
  • straight no turns, a straight line between fromNode and toNode

See the example:

//edge object
{
   ...properties,
  "type": "curved"
},
{
   ...properties,
   "type": "sharp"
}

style property

Having a canvas style would add more variety on edge styles.

style would somehow follow the border CSS property style:

  • solid: For a solid line (the default one)
  • dotted: For a dotted line
  • dashed: For a dashed line
  • mixed: A mix between dotted and dashed
  • none: To hide the edge without removing it

e.g:

//edge object
{
   ...properties,
   "style": "solid"
},
{
   ...properties,
   "style": "dashed"
},
{
   ...properties,
  "style": "dotted"
},
{
   ...properties,
  "style": "mixed"
},
{
   ...properties,
   type: "none"
}

fromLabel & toLabel properties

For now we can only set a label to an edge, that would be supposedly displayed at the middle of it. What if we want to display a label that at the end or the beginning of the edge, or even both?

They would work like the label property but used to be displayed at the start or/and the end of an edge. Think about SQL schema n-m relationships. Those property would not be self exclusive and using the 3 labels properties would work.


{
   ...properties,
  "fromLabel": "1",
  "toLabel": "n",
  "label": "1-n relationship"
},
{
   ...properties,
  "fromLabel": "1"
},
{
   ...properties,
   "toLabel": "*"
}

chainlist avatar Mar 16 '24 13:03 chainlist

Looks like GrapViz edge attributes, in particular splines, style and headlabel, taillabel. If being added to JSON Canvas, these features should better be aligned with these GraphViz attributes.

nichtich avatar Mar 16 '24 20:03 nichtich

fromLabel and toLabel is exactly what I need too:

https://github.com/obsidianmd/jsoncanvas/issues/2

rodydavis avatar Mar 19 '24 20:03 rodydavis

Apart from GraphViz some GEXF formats support visual attributes as well:

  • nodes can have color (RGBA), shape (disc, square, triangle, diamond) and size (scale factor of default 1.0)
  • edges can have color (RGBA), shape (solid, dotted, dashed, double) and thickness (scale factor of default 1.0)

These seem to be a subset of GraphViz attributes (e.g. thickness convertable to penwidth), so alignment of visual attributes in JSON Canvas with (a subset of) GraphViz attributes seems a reasonable choice.

Please note that generic attributes (arbitrary key-value-pairs), as supported in GML, GDF, GraphML among other formats, are another issue! Visual attributes should be special because they come with shared sematics while generic attributes depend on use case and application.

nichtich avatar Mar 20 '24 08:03 nichtich

Hi everyone! I'm building on top of JSON Canvas and ran into the same issue of trying to extend the format for more visual features. After looking through the issues here, it seems the Obsidian developers aren’t too interested in extending the format. I then found the Open Canvas Working Group (OCWG) (https://www.canvasprotocol.org/), which is inspired by JSON Canvas and is approaching the extension problem with a more structured spec (you can check it out here: https://github.com/ocwg/spec/blob/main/spec/0.3/spec.md#extensions). It seems like a good framework for standardizing our extensions, so I recommend taking a look.

dragonman225 avatar Mar 04 '25 18:03 dragonman225