Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Setting Diagram.GridStyle to Points Results in No GridStyle being applied (Read 2530 times)
klaatutrout
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Oct 26th, 2021 at 10:16pm
Print Post  
Here's the code being used to set the GridStyle of our Diagram:

            if (!userMapPreferences.GridStyle.Equals("None"))
            {
                diagram.ShowGrid = true;
                diagram.AlignToGrid = userMapPreferences.SnapToGrid;
                diagram.GridColor = DecodeColor(userMapPreferences.GridLineColor);
                diagram.GridStyle = DecodeGridStyle(userMapPreferences.GridStyle);
                diagram.GridSizeX = userMapPreferences.HorizontalGridSpacing;
                diagram.GridSizeY = userMapPreferences.VerticalGridSpacing;
            }


        public GridStyle DecodeGridStyle(string lineStyle)
        {
            switch (lineStyle.ToLower())
            {
                case "points":
                    return GridStyle.Points;
                case "lines":
                default:
                    return GridStyle.Lines;
            }
        }


It works when the user has selected Lines, but if they select Points, no points appear on the Diagram canvas as expected.

Here's what the Canvas data-json looks like for the grid-related properties:

/* Lines (Works as expected - lines are displayed */
showGrid:true,
gridStyle:1,
gridColor:rgba(133,16,47,1),
gridSizeX:100,
gridSizeY:50,
gridOffsetX:0,
gridOffsetY:0,
alignToGrid:true,

/* Points - Doesn't work as expected; no points are displayed */
showGrid:true,
gridStyle:0,
gridColor:rgba(133,16,47,1),
gridSizeX:100,
gridSizeY:50,
gridOffsetX:0,
gridOffsetY:0,
alignToGrid:true,



Is there another setting that needs to be set somewhere else?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #1 - Oct 27th, 2021 at 7:57am
Print Post  
Hi,

That works in our test, however displaying a very sparse grid with hard to find points when grid size is 100x50. GridStyle.Points means displaying a single point at coordinates divisible by grid size as in attached 4x4 grid screenshot. Do you maybe need to set the dash-style for grid lines to display dotted lines instead?

Regards,
Slavcho
Mindfusion
  

grid.png ( 27 KB | 119 Downloads )
grid.png
Back to top
 
IP Logged
 
klaatutrout
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #2 - Oct 27th, 2021 at 3:10pm
Print Post  
Slavcho wrote on Oct 27th, 2021 at 7:57am:
Hi,

Do you maybe need to set the dash-style for grid lines to display dotted lines instead?



Could you clarify what you mean by setting the "dash-style for grid lines" above?

In looking at the documentation, I only see the grid styles for points and lines.  Is there something I'm missing?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #3 - Oct 27th, 2021 at 3:30pm
Print Post  
There's no support for drawing grid with dashed lines, I was asking if that's what you are trying to achieve. GridStyle.Points does not draw lines at all, but only a single pixel at each grid position.
  
Back to top
 
IP Logged
 
klaatutrout
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #4 - Oct 28th, 2021 at 1:40pm
Print Post  
Thanks for the clarification.  I went back and changed the X and Y grid size from 50/100 to 10/10 and can now make them out (although they're still very faint, even when I zoom in to the map).  Is there a way to increase the size of the point or is that a set size?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #5 - Oct 28th, 2021 at 2:52pm
Print Post  
What diagram.measureUnit are you using when seeing the faint grid points?

Here's a way to draw dashed GridStyle.Lines -

Code
Select All
var baseDrawGrid = Diagram.prototype.drawGrid;
Diagram.prototype.drawGrid = function (clipRect)
{
	this.context.setLineDash([1, 1]);
	baseDrawGrid.apply(this, [clipRect]);
	this.context.setLineDash([]);
}; 



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


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #6 - Oct 28th, 2021 at 8:53pm
Print Post  
I've tried all of them, but none of them made a positive difference.  The attached is when I made the grid 10x10 with a black color and a white background.

  

MindFusion_10_x_10_Points_Example.png ( 50 KB | 120 Downloads )
MindFusion_10_x_10_Points_Example.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Setting Diagram.GridStyle to Points Results in No GridStyle being applied
Reply #7 - Oct 29th, 2021 at 6:33am
Print Post  
It seems the canvas element applies some antialiasing that makes grid color appear lighter. The dots appear darker for us than what your screenshot shows though, maybe it's dependent on browser or display settings leading to more aggressive smoothing. Our developers will check if there's a way to prevent that for next release.

The JavaScript library supports one more grid style that's not defined on .NET side: Crosses. You could set it by calling setGridStyle(GridStyle.Crosses) from JavaScript code and should get larger grid shapes.

Code
Select All
//diagram.setGridStyle(MindFusion.Diagramming.GridStyle.Points);
//diagram.setGridColor("black");

diagram.setGridStyle(MindFusion.Diagramming.GridStyle.Crosses);
diagram.setGridColor("gray");
diagram.setGridPointSize(1.4); // works only for crosses
 

  

Untitled_026.png ( 24 KB | 116 Downloads )
Untitled_026.png
Untitled2.png ( 40 KB | 129 Downloads )
Untitled2.png
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint