Dynamic background color (callback)
See original GitHub issueHi there,
I got a case, where I need to dynamically set colors of single bars depending on the data value.
I would suggest to use a callback like this:
datasets: [{
label: '# of Votes',
data: [ 10, 21, 22 ],
backgroundColor: function( value ) { // Callback instead of static color
if ( value < 30 ) {
return 'red';
}
return 'green';
}
}]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to dynamically set backgroundColor and borderColor ...
So all you need to do is iterate over your dynamic data and build your data, backgroundColor, and borderColor arrays per your logic...
Read more >Learn a simple way to dynamically change the background ...
Learn a simple way to dynamically change the background color of your webpage without any fancy frameworks. What you will need: Text Editor;...
Read more >Dynamic colors - JavaScript Video Tutorial
Each button will represent a different color and we'll change the background color of the document body to the color value. Using a...
Read more >How to Make Background Color Range Dynamic ... - YouTube
How to Make Background Color Range Dynamic With Changing X Scale in Chart JSIn this video we will explore how to make background...
Read more >Client script to change the background color of a field
incident.company'). I will also suggest doing the script in an "onChange", as that will make it work dynamically when you change the value...
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
Turns out that, after diving more into it, using the plugin system is way more elegant.
For anybody who comes across the same problem, this does the job:
Sure, here you go: 🙂 https://plnkr.co/edit/1AbeNG74cpxo0FSsw93q?p=preview