Articles in this section
Category / Section

How to add an axis dynamically to the Blazor Circular Gauge?

2 mins read

The Blazor Circular Gauge allows us to add axes dynamically during runtime. In this section, we will explain you how to add an axis dynamically in the Circular Gauge using a button click event.

You can create a list of numbers that indicate the maximum value of an axis. The value from this list must be set in the Maximum property of CircularGaugeAxis. The CircularGaugeAxis tag must be used within an iteration condition to add multiple axes. When a number is pushed into the list during the button click event, a new axis is dynamically added to the Circular Gauge component.

The below code example demonstrates how to add an axis dynamically in the Blazor Circular Gauge.

Index.razor


@using Syncfusion.Blazor.CircularGauge;
@using Syncfusion.Blazor.Buttons;

<SfButton CssClass="e-btn e-info" Content="Add Axis" @onclick="AddClick"></SfButton>
<SfCircularGauge>
    <CircularGaugeAxes>
        @foreach (var maximum in AxesMaximum)
        {
            <CircularGaugeAxis Maximum="maximum">
                <CircularGaugeAxisLineStyle Width="2" Color="#9E9E9E" />
                <CircularGaugeAxisMajorTicks Offset="5" />
                <CircularGaugeAxisMinorTicks Offset="5" />
            </CircularGaugeAxis>
        }
    </CircularGaugeAxes>
</SfCircularGauge>



@code {
    private List<int> AxesMaximum = new() { 100 };
   

    public void AddClick()
    {
        AxesMaximum.Add(200);
    }
}

The screenshots below show the output of the above code snippet.

Screenshot showing an initial rendering of the Circular Gauge:

Initial-Rendering-of-the-Circular-Gauge.png

Screenshot after dynamically adding an axis on a button click:

Adding-the-axis-dynamically.png

View the sample in GitHub

Conclusion

I hope you enjoyed learning how to add an axis dynamically in Blazor Circular Gauge component.

You can refer to our Blazor Circular Gauge feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Circular Gauge example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied