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

RadarChart with LinearRadialTicks: convertTicksToLabels is undefined #170

Closed
ipax77 opened this issue Dec 17, 2020 · 1 comment · Fixed by #171
Closed

RadarChart with LinearRadialTicks: convertTicksToLabels is undefined #170

ipax77 opened this issue Dec 17, 2020 · 1 comment · Fixed by #171
Labels
bug Something isn't working

Comments

@ipax77
Copy link
Contributor

ipax77 commented Dec 17, 2020

Describe the bug

When defining RadarOptions with LinearRadialAxis with LinearRadialTicks an error occures.

Which Blazor project type is your bug related to?

  • Client-Side
  • Server-Side

Which charts does this bug apply to?

RadarChart

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ChartJSBlazor '2.0.0'.
  2. Create a RadarChart with RadarOptions with LinearRadialAxis with LinearRadialTicks
  3. See error

Expected behavior

Show RadarChart

Additional context / logging

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: undefined is not a function
      TypeError: undefined is not a function
          at Array.map (<anonymous>)
          at n.convertTicksToLabels

Code example

            RadarConfig _config = new RadarConfig()
            {
                Options = new RadarOptions
                {
                    Responsive = true,
                    Title = new OptionsTitle
                    {
                        Display = true,
                        Padding = 0,
                        FontSize = 20,
                        FontColor = "white",
                        Text = "Loading ..."
                    },
                    Scale = new LinearRadialAxis()
                    {
                        Ticks = new LinearRadialTicks
                        {
                        }
                    }
                }
            };

Fix:

Add following code to ChartJsInterop.ts after line 248

            if (!config.options.scale.ticks.callback) {
                delete config.options.scale.ticks.callback; // undefined != deleted, Chart.js throws an error if it's undefined so we have to delete it
            }
@ipax77 ipax77 added the bug Something isn't working label Dec 17, 2020
@Joelius300
Copy link
Contributor

Good catch! Thanks for reporting.

With this null vs undefined vs deleted hell, it's really easy to miss bugs like that. I have very little time at the moment but I'll make sure to release a patch when I do get time.

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

Successfully merging a pull request may close this issue.

2 participants