Articles in this section
Category / Section

How to fill an empty area with dotted lines in Blazor Chart?

7 mins read

This article explains how to fill the empty area with dotted lines in Blazor Chart Component

Creating stacking series chart with empty points

To demonstrate this, consider the two stacking area series. If it is populated data have a NaN or null, then it will be plotted as shown in the following image.

empty_points.png

Filling the empty points with dotted line

In order to fill this empty space with dotted lines, use Line Series with calculated data from two stacking area series’ s data collection as shown in the following code sample.

Index.razor


    public List<ChartData> LineData = new List<ChartData> { };

    protected override void OnInitialized()
    {
        for ( int i = 0; i < MedalDetails.Count; i++)
        {

            if (MedalDetails[i].Y == null && MedalDetails1[i].Y == null)
            {
                IsEmpty = true;
            }
            else
            {
                IsEmpty = false;
            }                

            if (IsEmpty)
            {
                if ((MedalDetails[i - 1].Y)!=null)
                {
                    LineData.Add(new ChartData{X = MedalDetails[i - 1].X,Y = 0});
                    LineData.Add(new ChartData { X = MedalDetails[i - 1].X, Y = (MedalDetails[i - 1].Y + MedalDetails1[i - 1].Y)});
                }

                if ( (MedalDetails1[i + 1].Y)!=null)
                {
                    LineData.Add(new ChartData { X = MedalDetails[i + 1].X, Y = (MedalDetails[i + 1].Y + MedalDetails1[i + 1].Y)});
                    LineData.Add(new ChartData { X = MedalDetails[i + 1].X, Y = 0 });
                    LineData.Add(new ChartData { X = MedalDetails[i + 1].X, Y = double.NaN });
                }
            }                                                                                               
        }
    }

Empty points with dotted line

empty_points_with_dotted_line.png

View the sample in GitHub

Conclusion

I hope you enjoyed learning how to fill the empty area with dotted line in Blazor Chart Component.

You can refer to our Blazor Chart 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 Chart 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