Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Link display inconsistencies between diagram and SVG (Read 1290 times)
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Link display inconsistencies between diagram and SVG
Jan 21st, 2025 at 1:48pm
Print Post  
Hello, MindFusion Team!
I tried exporting line with the specific StrokeDashStyle to SVG and mentioned that it does not look the same as it displays in diagram in the app. Please check the attached project and images. You can clearly see, that dots look thicker in SVG file. Is there a workaround I can use to miss that discrepancy?
  

link.svg ( 1 KB | 66 Downloads )
DiagramLinkIssues_001.zip ( 427 KB | 57 Downloads )
G3fQXTCWKr.png ( 17 KB | 59 Downloads )
G3fQXTCWKr.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #1 - Jan 22nd, 2025 at 9:12am
Print Post  
Hi,

Our developer will investigate; we suspect SVG adds caps to the dashes (e.g. square instead of flat).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #2 - Jan 24th, 2025 at 12:32pm
Print Post  
Try new build here -

https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/4.1.6-beta2

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #3 - Jan 27th, 2025 at 5:42am
Print Post  
Thank you, now size of line segments is the same between svg and the diagram. Now I only see some sort of offset that covers line head in the SVG. Please compare these two pictures, in the diagram the arrow head is clearly seen, whereas in the SVG file it is overlapped by  the line. Judging by the start of this digram link you might guess that some sort of offset is applying when exporting to SVG.
  

DiagramLinkOffsetIssue.zip ( 437 KB | 53 Downloads )
F1p9PKo3B7.png ( 14 KB | 58 Downloads )
F1p9PKo3B7.png
msedge_5SLg2yFXuy.png ( 13 KB | 56 Downloads )
msedge_5SLg2yFXuy.png
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #4 - Jan 27th, 2025 at 5:43am
Print Post  
I also attach SVG here
  

resources.svg ( 1 KB | 64 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #5 - Jan 27th, 2025 at 1:09pm
Print Post  
If you look at top-left without scrolling, problem seems dashes starting from a different place (half of first dash missing in WPF), and so also not ending at same place of the dash array. Maybe there's some different dash-offset defaults in WPF vs SVG, our developer will check.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #6 - Feb 21st, 2025 at 9:51am
Print Post  
https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/4.1.7-beta1

also exports stroke-dashoffset to SVG for some implicit offset values of WPF DashStyles. However there's an added offset from caps where WPF allows different start/middle/end cap values and default are flat vs square, while SVG allows just a single stroke-linecap. To get same results on screen as in exported SVG, you'd have to assign same values to WPF's properties (SvgExporter writes link.StrokeDashCap to stroke-linecap):

Code
Select All
link.StrokeDashCap = PenLineCap.Flat;
link.StrokeStartLineCap = PenLineCap.Flat;
link.StrokeEndLineCap = PenLineCap.Flat;
 





Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #7 - Feb 24th, 2025 at 11:57am
Print Post  
This fix works perfectly, thank you. I use MeasureUnit.Pixel for the diagram so it has the same coordinates on different display scales. But what I noticed, is that the link is appearing thicker on the SVG if I set MeasureUnit.Pixel and have different display scale (125%, 150%). Is there a MeasureUnit I could use to properly display the same coordinates on different display scales and also be able to export diagram with links of the same size?
  

resources_001.svg ( 22 KB | 53 Downloads )
MindfusionNewVersionIssues_002.zip ( 438 KB | 48 Downloads )
MrOWbQ9khH.png ( 46 KB | 55 Downloads )
MrOWbQ9khH.png
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #8 - Feb 24th, 2025 at 11:58am
Print Post  
The deleted attachment(png)
  

MrOWbQ9khH.png ( 46 KB | 55 Downloads )
MrOWbQ9khH.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #9 - Feb 24th, 2025 at 2:20pm
Print Post  
Do you mean you want to prevent operating system's display scale applying to how SVG is rendered in the browser? I don't think SVG nor HTML have anything built-in to specify that. If the HTML page that displays the SVG drawings is under your control, you could try dividing the root <svg> element's width and height values by window.devicePixelRatio, to reverse the effect of the display scale:

https://stackoverflow.com/questions/46791052/detect-scale-settings-dpi-with-java...

Say at double display scale, that should halve drawing's width and height to map SVG's viewbox coordinates to a smaller area.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #10 - Feb 25th, 2025 at 6:13am
Print Post  
No, it is not about how the SVG file is rendered in the browser. It is about the size of the link when the diagram gets exported to SVG. If you set Scale in "Scale and Layouts" in Windows from 100% to, for instance, 150%, when the link in the exported SVG file will be thicker than how it is displayed in the app. Other controls have the same sizes. And if you set your scaling back from 150% to 100%, the SVG file will still display the same thicker line(please compare screen from the app and resources.svg file).
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #11 - Mar 4th, 2025 at 11:23am
Print Post  
Try this build for pixels -

https://www.nuget.org/packages/MindFusion.Diagramming.Wpf/4.1.8-beta1

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 124
Joined: Aug 25th, 2022
Re: Link display inconsistencies between diagram and SVG
Reply #12 - Mar 17th, 2025 at 12:23pm
Print Post  
Yes, it works correctly with big scales (150% and bigger), thank you. Could you please confirm if it works with a scale of 125%, because it looks like the line on the SVG is thicker that on the diagram.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: Link display inconsistencies between diagram and SVG
Reply #13 - Mar 17th, 2025 at 4:06pm
Print Post  
125% is correct too. Note that in old version line thickness wasn't matching other sizes when exporting pixels. Adding a small square with same thickness as the link:

Code
Select All
var testnode = diagram.Factory.CreateShapeNode(200, 190, 20, 20);
testnode.Brush = Brushes.Red;
testnode.Shape = Shapes.Rectangle;
testnode.Stroke = Brushes.Transparent;
testnode.ZTop(false); 



shows matching sizes now, with 125% exports being between 100 and 150:



Then it's up to browsers how they choose CSS pixel size, e.g. Firefox shows the svg bigger than Edge:

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint