Search results

Scatter in Blazor Chart component

08 Apr 2021 / 2 minutes to read

Scatter

Scatter plot or scatter chart plots data with two numeric parameters. To render a scatter series, use series Type as Scatter.

scatter.razor
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfChart DataSource="@MedalDetails">
    <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>

    <ChartSeriesCollection>
        <ChartSeries XName="X" YName="YValue" Type="ChartSeriesType.Scatter">
        </ChartSeries>
        <ChartSeries XName="X" YName="YValue1" Type="ChartSeriesType.Scatter">
        </ChartSeries>
    </ChartSeriesCollection>
</SfChart>

@code{
    public class ChartData
    {
        public string X { get; set; }
        public double YValue { get; set; }
        public double YValue1 { get; set; }
    }
    public List<ChartData> MedalDetails = new List<ChartData>
{
        new ChartData { X= "USA", YValue= 46, YValue1=56 },
        new ChartData { X= "GBR", YValue= 27, YValue1=17 },
        new ChartData { X= "CHN", YValue= 26, YValue1=36 },
        new ChartData { X= "UK", YValue= 56,  YValue1=16 },
        new ChartData { X= "AUS", YValue= 12, YValue1=46 },
        new ChartData { X= "IND", YValue= 26, YValue1=16 },
        new ChartData { X= "DEN", YValue= 26, YValue1=12 },
        new ChartData { X= "MEX", YValue= 34, YValue1=32},
    };
}

Scatter Charts

Note: You can also explore our Blazor Scatter Chart Example to know how to plot data with two numeric parameters.

Customization

You can use the following properties to customize the scatter series.

  • Fill – used to change the color of the scatter.
  • Opacity – used to control the transparency of the chart series.
  • Shape - used to change the shape of the scatter series.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfChart DataSource="@MedalDetails">
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>

<ChartSeriesCollection>
    <ChartSeries XName="X" YName="YValue" Type="ChartSeriesType.Scatter" Fill="blue" >
    </ChartSeries>
    <ChartSeries XName="X" YName="YValue1" Type="ChartSeriesType.Scatter" Fill="red" >
    </ChartSeries>
</ChartSeriesCollection>
</SfChart>

@code{
public class ChartData
{
    public string X { get; set; }
    public double YValue { get; set; }
    public double YValue1 { get; set; }
}
public List<ChartData> MedalDetails = new List<ChartData>
{
    new ChartData { X= "USA", YValue= 46, YValue1=56 },
    new ChartData { X= "GBR", YValue= 27, YValue1=17 },
    new ChartData { X= "CHN", YValue= 26, YValue1=36 },
    new ChartData { X= "UK", YValue= 56,  YValue1=16 },
    new ChartData { X= "AUS", YValue= 12, YValue1=46 },
    new ChartData { X= "IND", YValue= 26, YValue1=16 },
    new ChartData { X= "DEN", YValue= 26, YValue1=12 },
    new ChartData { X= "MEX", YValue= 34, YValue1=32},
};
}

Custom Scatter Charts

Note: You can refer to our Blazor Charts feature tour page for its groundbreaking feature representations. You can also explore our Blazor Chart example to knows various chart types and how to represent time-dependent data, showing trends in data at equal intervals.

See Also