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.

Apply CSS classes to canvas

See original GitHub issue

I was wondering why my charts weren’t working will within my layout, and I realized that width and height are the canvas’ size, not the size of the element.

Traditionally, a className prop can be passed to React components so users can apply custom CSS classes to it. Would be nice to have that, and it’s a really trivial thing to add.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

1reaction
andremalta-devcommented, Jan 17, 2019

Try to use this:

options: { maintainAspectRatio: false }

It worked for me.

0reactions
dangreencommented, Oct 22, 2021

The latest version of react-chartjs-2 supports passing HTML props.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifying the Canvas with CSS - Apple Developer
Modifying the Canvas with CSS. Because the canvas is an HTML element, you can use CSS styles to modify its position, assign it...
Read more >
Applying CSS Class to Canvas - Stack Overflow
Applying CSS Class to Canvas ; I'm no expert but can't you just use "canvas.addClass("yourClass");". – Tim Gerhard. Mar 15, 2018 at 7:17...
Read more >
HTML canvas class Attribute - Dofactory
The class attribute assigns one or more classnames to the <canvas> tag. Classnames are defined in a stylesheet or in a local <style>...
Read more >
Course based CSS and JavaScript - Instructure Community
Every time my Canvas admin has asked me to put custom JavaScript ... Just allow me to apply my custom CSS to a...
Read more >
Apply CSS classes to canvas · Issue #287 - GitHub
I have wrapped the chart inside a div and applied style. But the height of canvas takes too long to update in DOM....
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