Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
krispenner opened this issue Apr 12, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@krispenner
Copy link

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.
@krispenner krispenner added the bug Something isn't working label Apr 12, 2021
@pgrimstrup
Copy link

Code execution errors: Are these being thrown as exceptions that you need to handle? There are a couple of places in the code where dynamic is being used and trying to access the Scale property, which is available on some of the Options classes, but these exceptions are caught and released. They should not be bubbling up. In other words, if you see them in the output window you can safely ignore them. There is a bit of technical debt there (a quick and dirty approach was taken) so I will see if there is a more elegant method of handling this (probably implement an internal interface or something).

404 error: Make sure the Package ID on the project is the same as the Project Name (or output file name, I can't remember which). I know from experience that changing the Package ID does cause this behavior. Revert to the Package ID to the default value. Also try setting a <base href='/'/> tag in the _Hosts page header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants