Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to use chart.js in blazor?

$
0
0

I am trying to follow this example from mariusmuntean/ChartJs.Blazor :

https://github.com/mariusmuntean/ChartJs.Blazor

The code runs but I am getting this error:

InvalidOperationException: Object of type 'Project.Shared.Chart' doesnot have a property matching the name '@Config'.

@page "/charts/bar/horizontal"@using ChartJs.Blazor.PieChart@using System.Drawing@* @layout SampleLayout *@@using ChartJs.Blazor.Util@using ChartJs.Blazor.Common@using ChartJs.Blazor.Common.Axes@using ChartJs.Blazor.Common.Axes.Ticks@using ChartJs.Blazor.Common.Enums@using ChartJs.Blazor.Common.Handlers@using ChartJs.Blazor.Common.Time@using ChartJs.Blazor.Interop<Chart Config="_config"></Chart>@code {private PieConfig _config;protected override void OnInitialized(){    _config = new PieConfig    {        Options = new PieOptions        {            Responsive = true,            Title = new OptionsTitle            {                Display = true,                Text = "ChartJs.Blazor Pie Chart"            }        }    };    foreach (string color in new[] { "Red", "Yellow", "Green", "Blue" })    {        _config.Data.Labels.Add(color);    }    PieDataset<int> dataset = new PieDataset<int>(new[] { 6, 5, 3, 7 })    {        BackgroundColor = new[]        {            ColorUtil.ColorHexString(255, 99, 132), // Slice 1 aka "Red"            ColorUtil.ColorHexString(255, 205, 86), // Slice 2 aka "Yellow"            ColorUtil.ColorHexString(75, 192, 192), // Slice 3 aka "Green"            ColorUtil.ColorHexString(54, 162, 235), // Slice 4 aka "Blue"        }    };    _config.Data.Datasets.Add(dataset);}}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>