Articles in this section
Category / Section

How to render stacked line and scatter charts with multiple panes in Blazor Charts?

4 mins read

This article explains how to render stacked line and scatter with multiple panes in Blazor Charts.

Render Stacked Line and Scatter Charts with Multiple Panes

Blazor Charts provides an option to render stacked line and scatter with multiple panes.

This can be achieved by using the ChartRows property to divide the chart area vertically into any number of rows.

The below code example demonstrates how to render stacked line and scatter with multiple panes.

Index.razor

In this code snippet, the chart area is divided into multiple rows using the ChartRows property, allowing vertical segmentation. The Height property for each ChartRow specifies the allocation of space. Additionally, custom ChartAxis properties are configured for each row to display different series on distinct axes, and multiple ChartSeries are defined to show different types of charts with markers for visual representation.

@using Syncfusion.Blazor.Charts

<SfChart>
   <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Double" />

   <ChartPrimaryYAxis Minimum="0" Maximum="250" Interval="50" LabelFormat="${value}" />

   <ChartRows>
       <ChartRow Height="30%"></ChartRow>
       <ChartRow Height="30%"></ChartRow>
       <ChartRow Height="30%"></ChartRow>
   </ChartRows>


   <ChartAxes>
       <ChartAxis Minimum="0" Maximum="250" Interval="50" OpposedPosition="true" RowIndex="1" Name="YAxis" LabelFormat="${value}" />
       <ChartAxis Minimum="0" Maximum="250" Interval="50" RowIndex="2" Name="YAxis_2" LabelFormat="${value}" />
   </ChartAxes>

   <ChartSeriesCollection>

       <ChartSeries DataSource="@StackedLineDataPoints" XName="X" YName="Y" Type="ChartSeriesType.StackingLine" />

       <ChartSeries DataSource="@StackedLineDataPoints" XName="X" YName="Y1" YAxisName="YAxis" Type="ChartSeriesType.StackingLine" />

       <ChartSeries DataSource="@StackedLineDataPoints" XName="X" YName="Y2" YAxisName="YAxis_2" Type="ChartSeriesType.StackingLine" />

       <ChartSeries DataSource="@ScatterDataPoints" XName="X" YName="Y" Type="ChartSeriesType.Scatter">
           <ChartMarker Height="10" Width="10">
           </ChartMarker>
       </ChartSeries>

       <ChartSeries DataSource="@ScatterDataPoints" XName="X" YName="Y1" YAxisName="YAxis" Type="ChartSeriesType.Scatter">
           <ChartMarker Height="10" Width="10">
           </ChartMarker>
       </ChartSeries>

       <ChartSeries DataSource="@ScatterDataPoints" XName="X" YName="Y2" YAxisName="YAxis_2" Type="ChartSeriesType.Scatter">
           <ChartMarker Height="10" Width="10">
           </ChartMarker>
       </ChartSeries>

   </ChartSeriesCollection>
</SfChart>

@code {
   public class ChartData
   {
       public double X { get; set; }
       public double Y { get; set; }
       public double Y1 { get; set; }
       public double Y2 { get; set; }
   }


   public List<ChartData> StackedLineDataPoints = new List<ChartData>
   {
       new ChartData { X = 0 , Y = 90, Y1 = 40 , Y2= 70,},
       new ChartData { X = 500, Y = 80, Y1 = 90, Y2= 110},
       new ChartData { X = 1000,Y = 50, Y1 = 80, Y2= 120},
       new ChartData { X = 1500,Y = 70, Y1 = 30, Y2= 60},
       new ChartData { X = 2000, Y = 30, Y1 = 80, Y2= 80  },
       new ChartData { X = 2500, Y = 10, Y1 = 40, Y2= 30},
       new ChartData { X = 3000,Y = 100, Y1 = 30, Y2= 70 },
       new ChartData { X = 3500, Y = 55, Y1 = 95, Y2= 55},
       new ChartData { X = 4000, Y = 20, Y1 = 50, Y2= 40 },
       new ChartData { X = 4500, Y = 40, Y1 = 20, Y2= 80 },
       new ChartData { X = 5000, Y = 45, Y1 = 15, Y2= 45 },
       new ChartData { X = 5500, Y = 75, Y1 = 45, Y2= 65 }
   };

   public List<ChartData> ScatterDataPoints = new List<ChartData>
   {
       new ChartData { X = 1500,Y = 70 ,Y1 = 30, Y2= 60 },
       new ChartData { X = 3000, Y = 100,Y1 = 30, Y2= 70 }
   };
} 

The following screenshot illustrates the output of the code snippet.

msedge_lraxZsWILM.png

Live Sample for Stacked Line and Scatter with Multiple Panes

Conclusion

I hope you enjoyed learning how to render stacked line and scatter with multiple panes in Blazor Charts.

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