Simple way to color bar chart
See original GitHub issueHi. I’m trying to color a stacked bar chart, and I’ve looked at some other complicated solutions, but I need something simple!
I am trying this which seems to be a hotch-potch of code. I’ve tried the selectAll with about every combination: rect.bar, rect.stack, g.rect.bar etc.
.renderlet(function(chart){
chart.selectAll("g.rect.stack").attr("fill", function(d){
if(d.key == "a) Free")
return "green-bar";
else if(d.key == "b) Partly Free")
return "yellow-bar";
else if(d.key == "c) Not Free")
return "red-bar";
});})
Anyone help me get over this?
Issue Analytics
- State:
- Created 10 years ago
- Comments:17 (3 by maintainers)
Top Results From Across the Web
Vary the colors of same-series data markers in a chart
In a chart, click to select the data series for which you want to change the colors. · Click the Format tab and...
Read more >How to color chart bars based on their values
How to color chart bars based on their values · Press with right mouse button on on a column on the chart. ·...
Read more >How to create a Bar Chart with color ranges in Excel
One of the design strategies to enhance the dimensionality of bar charts is to use color to encode another dimension in the data....
Read more >Create a color grouping chart (color bars by value) in Excel
In some cases, you may need to create a column or bar chart with different colors for the bars based on values. As...
Read more >How to Color Bar Chart by Category in Excel (2 Easy Methods)
1. Using IF Function to Color a Bar Chart by Category in Excel · It opens the Format Axis task pane. Now, click...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
Here’s the solution for clicking on a bar not dimming the other unselected stackedbars.
The renderlet solution should work however you need to set the fill to color instead of css class:
Also make sure remove fill setting in your css class since in some browser the css class take precedence over fill attribute.