question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throw error for incorrect types passed into configuration object

See original GitHub issue

Expected Behavior

When setting options tooptions={ responsive: true, maintainAspectRatio: false, } and placing the canvas inside of a dedicated container with relative positioning width: 100vw; height: 50vh I expect the chart to be as wide as the screen and half the height of the window, even after a resize. I also expect that when I destroy and place a new chart on the same canvas that the new chart will also have the same dimensions and respond correctly to a resize

Current Behavior

The chart disappears. There is a tiny dot in the top left corner. I’m guessing this is my squished chart(?) The graph container has the correct dimensions, the iframe has the correct dimensions, as does the canvas. Which leads me to believe it is happening in the draw function. I’m not entirely sure when the chart is drawn. Maybe the draw happens before the iframe is ready? Edit* screen shot 2017-03-29 at 2 25 58 pm Ah! I found this. Where would it be getting those numbers? It would be nice to see an error for NaN inputs. Final Edit* I had set borderWidth to “5px” and everything exploded silently.

Steps to Reproduce (for bugs)

My JSBIN

Context

This is an internal app for our business division. I expect this will be viewed on many different devices. I have found dimensions that I like for just about all screens - except maybe a wearable - I’d love to have the ability to control the height and width of the graph when the container is resized.

Environment

  • Chart.js version: 2.5.0 - same error with 2.2
  • Browser name and version: 57.0.2987.98 (Official Build) (64-bit)
  • Link to your project: github.com/lfox91/ytanalytics

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
etimbergcommented, Oct 15, 2020

These days I think this is looking a lot better. We now ship Typescript types in the npm distribution as of v3.0.0-beta.1 and so editors/linters will catch this. Not sure if it’s enough to close this issue, but it’s an improvement

0reactions
etimbergcommented, Oct 20, 2022

Closing since we won’t move forward with this and TS is our solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What type of Exception should I throw if the wrong type ...
I'd probably throw an IllegalArgumentException with a proper message. Btw, might there be a way to not allow passing the wrong type of...
Read more >
Error - JavaScript - MDN Web Docs - Mozilla
Error objects are thrown when runtime errors occur. The Error object can also be used as a base object for user-defined exceptions.
Read more >
How to Throw Exceptions in JavaScript - Rollbar
All it takes is to instantiate an exception object—with the first parameter of the Error constructor being the error message—and then… "throw" ...
Read more >
Creating and Throwing Exceptions | Microsoft Learn
Learn about creating and throwing exceptions. Exceptions are used to indicate that an error has occurred while running a program.
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
However, most people tend to use the shorthand form which defines error objects while throwing them: throw TypeError("Wrong type found, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found