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.

Bar chart : onover on every bar

See original GitHub issue

It looks like a strange behavior to me : On a bar chart with multiple “columns”, the data.onclick event gives me the exact bar on which I clicked, but the data.onover gives me every bar of the tick/day, like if the onover was triggered for every bar at once… Is it possible to have the same behavior as for onclick ? I don’t use the tooltips if that can be of any help.

You can try and reproduce the “issue” on the examples here : https://naver.github.io/billboard.js/demo/#Chart.BarChart

And you add the onover on the code :

var chart = bb.generate({
  data: {
    columns: [
	["data1", 30, 200, 100, 400, 150, 250],
	["data2", 130, 100, 140, 200, 150, 50]
    ],
    type: "bar",
    onover: function(d) {
       console.log(d);
    }
  },
  bar: {
    width: {
      ratio: 0.5
    }
  },
  bindto: "#barChart"
});

Thanks in advance for any advice or tip !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
netilcommented, Mar 26, 2020

@ugoQ, data.onover works for entire data series for same x Axis datas.

If you need to update cursor depend the data, try this:

  tooltip: {
    grouped: false,
    onshown: function(ctx, d) {
        let cursor = null;

        if (d.length === 1) {
            if (d[0].id === "data1") {
                cursor = "zoom-in";
            } else {
                cursor = "zoom-out";
            } 

            ctx.$.chart.style("cursor", cursor);
        }
    },
    onhidden: function(ctx) {
        ctx.$.chart.style("cursor", null);
    }
  },
1reaction
netilcommented, Mar 25, 2020

Hi @ugoQ, try with below options.

onover: function(d) {
    // use 'd.id' to distinguish and implement different behavior for each data
    if (d.id === "data1") {
	console.log(1);       
    } else {
	console.log(2);
       }
    }
},
tooltip: {
    // using this option, will make displaying tooltip separately
    grouped: false
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chartjs : Can I overwrite bar value on hover for every bar chart
I am using a simple bar chart from chartJS representing time passed (in seconds). I was wondering if I could overwrite every bar's...
Read more >
How to Create Custom Element On Bar On Hover in Chart JS
The canvas tag, javascript, arrays and Chart JS all need to be combined to draw an eye catching bar chart or line chart....
Read more >
Bar Chart | Chart.js
The bar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a...
Read more >
show elements in all datasets on hover using bar chart-Chart.js
[Solved]-Chartjs - show elements in all datasets on hover using bar chart-Chart.js. Search. score:13. Accepted answer. The property is actually stored in ...
Read more >
Bar Chart Values Displayed on Hover | Infragistics Forums
However, I am developing a Lightswitch app which will be the prototype for a production Silverlight application. I do not want to write...
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