Apply CSS classes to canvas
See original GitHub issueI 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:
- Created 5 years ago
- Reactions:7
- Comments:8
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try to use this:
options: { maintainAspectRatio: false }
It worked for me.
The latest version of react-chartjs-2 supports passing HTML props.