[v11.0.x] Canvas: Improve connection vertex logic (#87581)

Canvas: Improve connection vertex logic (#87580)

Canvas: Prevent machine error causing logic swap
(cherry picked from commit dfdf119f7f)

Co-authored-by: Drew Slobodnjak <60050885+drew08t@users.noreply.github.com>
pull/87591/head
grafana-delivery-bot[bot] 1 year ago committed by GitHub
parent 11e83015bf
commit 50400c8915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      public/app/plugins/panel/canvas/components/connections/ConnectionSVG.tsx

@ -276,10 +276,10 @@ export const ConnectionSVG = ({
}
// Calculate arc control points
const lDelta = lSegment - lHalfArc;
xa = lDelta * Math.cos(angle1) + x1;
ya = lDelta * Math.sin(angle1) + y1;
xb = lHalfArc * Math.cos(angle2) + X;
yb = lHalfArc * Math.sin(angle2) + Y;
xa = Math.round(lDelta * Math.cos(angle1) + x1);
ya = Math.round(lDelta * Math.sin(angle1) + y1);
xb = Math.round(lHalfArc * Math.cos(angle2) + X);
yb = Math.round(lHalfArc * Math.sin(angle2) + Y);
// Check if arc control points are inside of segment, otherwise swap sign
if ((xa > X && xa > x1) || (xa < X && xa < x1)) {
@ -325,10 +325,10 @@ export const ConnectionSVG = ({
// Calculate arc control points
const lDelta = lSegment - lHalfArc;
xa = lDelta * Math.cos(angle1) + Xp;
ya = lDelta * Math.sin(angle1) + Yp;
xb = lHalfArc * Math.cos(angle2) + X;
yb = lHalfArc * Math.sin(angle2) + Y;
xa = Math.round(lDelta * Math.cos(angle1) + Xp);
ya = Math.round(lDelta * Math.sin(angle1) + Yp);
xb = Math.round(lHalfArc * Math.cos(angle2) + X);
yb = Math.round(lHalfArc * Math.sin(angle2) + Y);
// Check if arc control points are inside of segment, otherwise swap sign
if ((xa > X && xa > Xp) || (xa < X && xa < Xp)) {

Loading…
Cancel
Save