When I initialize a Chart, I get an error
Closed this issue · 1 comments
erossini-chi commented
I have a simple Razor page
@page "/test"
<Chart Config="_config1" @ref="_chart1" Height="400px"></Chart>
@code {
private BarChartConfig? _config1;
private Chart? _chart1;
protected override async Task OnInitializedAsync()
{
_config1 = new BarChartConfig()
{
Options = new Options()
{
IndexAxis = "y",
Responsive = true,
MaintainAspectRatio = false,
Plugins = new Plugins()
{
Legend = new Legend()
{
Align = Align.Center,
Display = false,
Position = LegendPosition.Right
}
},
Scales = new Dictionary<string, Axis>()
{
{
Scales.XAxisId, new Axis()
{
Stacked = true,
Ticks = new Ticks()
{
MaxRotation = 0,
MinRotation = 0
}
}
},
{
Scales.YAxisId, new Axis()
{
Stacked = true
}
}
}
}
};
_config1.Data.Labels = new List<string>() { "1900", "1950", "1999", "2050" };
_config1.Data.Datasets.Add(new BarDataset()
{
Label = "Value",
Data = new List<decimal>() { 408, 547, 675, 734 },
BackgroundColor = ColorPalettes.MainPalette,
BorderColor = ColorPalettes.MainPalette,
BorderWidth = 1
});
}
}
The error I get is
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
erossini commented
I can't replicate the issue