visjs / vis-network

:dizzy: Display dynamic, automatically organised, customizable network views.
https://visjs.github.io/vis-network/
Apache License 2.0
3.07k stars 374 forks source link

Offset and rotation for middle arrow? #1237

Open jychiao opened 3 years ago

jychiao commented 3 years ago

I'm using a middle arrow (image type) to show an indicator on an edge. It works great, but it appears slightly off center since the arrows are drawn to center off the top of the arrow, instead of the midpoint of the arrow. You can see this happen in the provided visjs example for a default arrow type, not just images. For my specific usage, here's a screenshot (sorry for the partial screenshot, I can't disclose sensitive information)

My edge config looks something like:

arrows: {
   middle: {
      enabled: true,
      type: 'IMAGE',
      imageHeight: 15,
      imageWidth: 15,
      src: /* image url */
   }
}

image

endPointOffset exists for from / to arrows, but why not middle? It'd be nice if I could adjust the offset for my use case, and for just some added flexibility with using arrows. I understand I could customize the arrow rendering, but I think having this offset could make sense as an OOTB option!

As a separate suggestion, what would it be like to have a rotation parameter at least for middle arrows, or maybe fix the rotation so that it's always vertically aligned no matter the edge placement? I can easily just rotate my source images, but maybe there could be a case where someone wants their image to be aligned differently than towards the target node.

jychiao commented 3 years ago

Any follow-up on the middle arrow alignment? We have the option to simply patch our instance of VisJS to align the middle arrows differently as well, but could use a bit of guidance on where to start there.

kosirm commented 7 months ago

+1 please consider this, I really need this