Chart - Scatter (Point)

A Scatter plot displaying the relationship between hours studied and exam scores. Scatter plots use the Point chart type and are ideal for showing correlations between two numeric variables.


Source Code

<Chart ChartWidth="600px" ChartHeight="400px">
    <ChartTitle Text="Hours Studied vs. Exam Score" />
    <ChartLegend Name="Default" />
    <ChartArea Name="ScatterArea"
        AxisX="@(new Axis { Title = "Hours Studied", Minimum = 0, Maximum = 12 })"
        AxisY="@(new Axis { Title = "Exam Score", Minimum = 40, Maximum = 100 })" />
    <ChartSeries Name="Students"
        ChartType="SeriesChartType.Point"
        ChartArea="ScatterArea"
        Points="@ScatterPoints" />
</Chart>

@code {

    private List<DataPoint> ScatterPoints = new()
    {
        new() { XValue = 1.0, YValues = new[] { 52.0 } },
        new() { XValue = 2.0, YValues = new[] { 58.0 } },
        new() { XValue = 3.0, YValues = new[] { 65.0 } },
        new() { XValue = 5.0, YValues = new[] { 74.0 } },
        new() { XValue = 7.0, YValues = new[] { 82.0 } },
        new() { XValue = 9.0, YValues = new[] { 90.0 } },
        new() { XValue = 10.0, YValues = new[] { 95.0 } }
    };

}