Skip to content

PieOptions does not contain a definition for 'Scale' and ChartJsBlazorInterop.js not found. #184

@krispenner

Description

@krispenner

Describe the bug

I am just starting with this, I setup my _Host file as you described in the readme and trying to make it as simple as possible based on your sample but I get two errors. First the server code executing throws RuntimeBinderException: ''ChartJs.Blazor.PieChart.PieOptions' does not contain a definition for 'Scale'' and secondly my browser tools show _content/ChartJs.Blazor.Fork/ChartJsBlazorInterop.js not found (404).

Any help would be much appreciated - thank you!

_Hosts

    <script src="_framework/blazor.server.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js"></script>
    <script src="_content/ChartJs.Blazor.Fork/ChartJsBlazorInterop.js"></script>

Which Blazor project type is your bug related to?

  • Server-Side

Which charts does this bug apply to?

PieChart

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ChartJSBlazor '2.0.2'.
  2. Run this code
<Chart Config="chartConfig"></Chart>

@code {
    private PieConfig chartConfig;

    protected override async Task OnInitializedAsync()
    {
        chartConfig = new PieConfig
        {
            Options = new PieOptions
            {
                Responsive = true,
                Title = new OptionsTitle
                {
                    Display = true,
                    Text = "Requests per Service"
                }
            }
        };

        foreach (string color in new[] { "Red", "Yellow", "Green", "Blue" })
        {
            chartConfig.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"
        }
        };

        chartConfig.Data.Datasets.Add(dataset);
}
  1. See these errors:
    Code execution: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''ChartJs.Blazor.PieChart.PieOptions' does not contain a definition for 'Scale''
    Chrome browser development tools: 404 _content/ChartJs.Blazor.Fork/ChartJsBlazorInterop.js not found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions