blazor-docs/blazor/diagram/ruler.md

4.3 KiB
Исходник Постоянная ссылка Ответственный История

layout title description platform control documentation
post Ruler in Blazor Diagram Component | Syncfusion Checkout and learn here all about Ruler in Syncfusion Blazor Diagram component and much more details. Blazor Diagram ug

Ruler in Blazor Diagram Component

The Ruler provides a horizontal and vertical guide for measuring in the Diagram control. The Ruler can be used to measure the diagram objects, indicate positions, and align diagram elements. This is especially useful in creating scale models.

Adding Rulers to the Diagram

  • The DiagramRulerSettingsproperty is used to control the visibility and appearance of the ruler in the diagram.

  • The RulerSettings ShowRulersproperty is used to show or hide the rulers in the diagram.

  • The RulerSettings HorizontalRuler and VerticalRuler properties are used to customize the rulers appearance in the diagram.

The following code shows how to add a ruler to the diagram.

@using Syncfusion.Blazor.Diagrams

<SfDiagram Width="600px" Height="600px">
    <DiagramRulerSettings ShowRulers="true">
    </DiagramRulerSettings>
</SfDiagram>

Ruler

Customizing the Ruler

By default, the ruler segments are arranged based on pixel values.

  • The HorizontalRulers Intervalproperty allows you to define the interval between ruler segments and the SegmentWidth property allows you to define the segment width of the ruler. Similarly, you can use the VerticalRulers Interval and SegmentWidth properties are used to define the interval and segment width of the vertical ruler.

  • The HorizontalRulers TickAlignment property is used to align the ruler tick either left or right side of the ruler. The VerticalRulers TickAlignment property is used to align the ruler tick either top or bottom side of the ruler.

  • The HorizontalRulers MarkerColor and VerticalRulers MarkerColor properties are used to define the ruler marker color and marker will be shown when performing the interaction in the diagram.

The following code shows how the diagram ruler can be customized.

@using Syncfusion.Blazor.Diagrams

<SfDiagram Width="600px" Height="600px">
    <DiagramRulerSettings ShowRulers="true">
        <HorizontalRuler Interval="8" SegmentWidth="100" Thickness="25" TickAlignment="@verticalTickAlignment"></HorizontalRuler>
        <VerticalRuler Interval="10" SegmentWidth="150" Thickness="35" TickAlignment="@horizontalTickAlignment"></VerticalRuler>
    </DiagramRulerSettings>
</SfDiagram>

@code{
    TickAlignment verticalTickAlignment = TickAlignment.LeftOrTop;
    TickAlignment horizontalTickAlignment = TickAlignment.RightOrBottom;
}

The MarkerColor property can be customized using the Marker CSS style.

Customize