You must be logged in to post your query.
Home › Forums › Chart Support › mouseover help
Tagged: mouseover
I have a specific <td id=”test”> element below the graph that I am trying to change the color when a specific line is highlighted.
Looking at the examples, I am trying something along the lines of
mouseover: function(){ document.getElementById("test").style.backgroundColor='red'; },
But it’s not working and I am afraid there is something that I don’t understand. hoping to see if I am doing something stupid, or perhaps this just isn’t possible.
Thanks!
@wstewart3,
The above code seems to be working fine at our end. Can you please create and share a JSFiddle reproducing the issue so that we can look into your code and help you out.
___________ Indranil Deo Team CanvasJS
So, I am getting a weird thing on my line graphs, where When I initially mouseover the line, it does nothing, but when I move to another point, then it fires off.
However, another part of my problem was I did not want ID, I needed to do this by the object class:
mouseover: function color() { var elements = document.getElementsByClassName(‘test’); // get all elements for(var i = 0; i < elements.length; i++){ elements[i].style.backgroundColor = “red”; } },
end result for your bar graph can be seen here: https://jsfiddle.net/h28xmnfy/
Will do some more testing and get back to everyone. Thanks for the quick response!
Looks like things are, in fact, mostly working as intended.
However, is it possible to make it so the “mouseover” function triggers anywhere on the line, not just the datapoint itself? https://jsfiddle.net/4uodvpf2/
My goal is to try and highlight the area of a table whose data is represented by said line. This would seem to work best whenever mousing over any part of the line.
@joran,
In case of line chat, each dataPoint is represented as a marker and a line connects them. Events (click, mouseover, mousemove, mouseout) binded for dataPoints get fired when mouse event is triggered on it and not on the connecting line.
Gotcha,
So currently it’s not possible?
Thanks for the replies! I have been enjoying CanvasJS.
Sorry, adding a mouse event to the line of a line chart is not available as of now.
You must be logged in to reply to this topic. Login/Register