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.

Change stroke color of bar depending on bar size

See original GitHub issue

Hi,

I am trying to change the color of a bar (among many in the graph) if it’s bigger than 40. See picture below:

capture

I’ve been trying to change it inside the chart.on(‘draw’)

chart.on('draw', function(data) {
  if(data.type === 'bar') {
       data.element.attr({
        style: 'stroke: red'
       });
  }
)};

but I’m not sure how to or if it’s possible.

Any help is appreciated.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
gionkunzcommented, Oct 28, 2016

Yes, sorry. Value on line and bar charts are so called multi value objects (contains the value for X and Y axis depending on which axis configuration you’re using).

In your setup you’ll need to do this:

chart.on('draw', function(data) {
  if(data.type === 'bar' && data.value.y > 40) {
       data.element.attr({
        style: 'stroke: red'
       });
  }
)};
0reactions
kannan09commented, Jun 6, 2019

Hi,

I am trying to set each bar color different bar

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change color of bars in barplot in relation to bar length
First, we need to create color gradients for plotting. Let's use a resolution of 10 colors from black to either blue or green....
Read more >
Control the color of barplots built with matplotlib
You can change the color of bars in a barplot using color argument. RGB is a way of making colors. You have to...
Read more >
How to color chart bars based on their values - Get Digital Help
This chart example shows bars colored differently depending on the preceding value. ... 2.4 Change chart gap width and series overlap.
Read more >
Change Color of Bars in Barchart using ggplot2 in R
In this article, we are going to see various methods to change the color of a bar chart using ggplot2 in the R...
Read more >
Change the look of bars, wedges, and more in Numbers on Mac
Change the color of data symbols: Click the pop-up menu below Fill and choose an option. Choose Use Series Stroke Color to revert...
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