46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
@rendermode InteractiveServer
|
|
|
|
<MudPaper Class="pa-5 ma-5 rounded-lg" Width="@Width">
|
|
<MudChart ChartType=@ChartType @bind-SelectedIndex="Index" InputData="@data" InputLabels="@labels" Width=@Width Height=@Height> </MudChart>
|
|
</MudPaper>
|
|
|
|
|
|
@code {
|
|
|
|
private int Index = -1;
|
|
private ChartOptions options = new ChartOptions();
|
|
public double[] data = { 50, 25, 20, 5 };
|
|
public string[] labels = { "Fossil", "Nuclear", "Solar", "Wind" };
|
|
|
|
|
|
[Parameter]
|
|
[Category("Behavior")]
|
|
public ChartType ChartType { get; set; } = ChartType.Donut;
|
|
|
|
[Parameter]
|
|
[Category("Appearance")]
|
|
public string Width { get; set; } = "80%";
|
|
|
|
[Parameter]
|
|
[Category("Appearance")]
|
|
public ChartOptions ChartOptions { get; set; } = new ChartOptions();
|
|
|
|
[Parameter]
|
|
[Category("Appearance")]
|
|
public string Height { get; set; } = "80%";
|
|
|
|
[Parameter]
|
|
public string XAxis { get; set; }
|
|
|
|
public string[] XAxisLabels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep" };
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
options.InterpolationOption = InterpolationOption.NaturalSpline;
|
|
options.YAxisFormat = "c2";
|
|
|
|
ChartOptions = options;
|
|
}
|
|
|
|
}
|