Assuming I have the following:
http://www.highcharts.com/stock/demo/basic-line
Notice that when you hover on the chart, you can see a vertical line through the "column" where your mouse is hovered over.
Is there some function or method I can call so that I can click a button and have the vertical column/selected datapoint be triggered programatically without having to hover the mouse over the graph itself?
Related
I have a nvd3 chart and a html table. I need to update table values as the user moves the mouse over the chart. Is there an event I can use to catch a nvd3 tooltip change and get the date value at the current mouse position?
My first idea was to get the nv.tooltip values on mousemove over the chart element. Not of much help.
$('#chart').mousemove(function(e) {
console.log(nv.tooltip);
});
How could I implement such mouseover effect that whenever mouse is over the linechart it shows every lines Y-value in an tooltip on hovered X?
So, in the end by moving mouse over the chart it should always show a tooltip that is updated constantly with Y value based on changed X? Now it shows tooltip only on X-scales steps e.g. 2010,2011,2012,2013,2014...
I don't have time at this very moment to write a complete solution, but I can try to point you in the right direction in terms of the part you will need that is directly related to the Google Charts API.
There Is Not A Simple Solution
First off, I'd like to make it very clear that there is not, to my knowledge, a simply solution built into the Google Charts API for this. Anything you right for this will involve rendering your own tooltip element, positioning it to the mouse location, and filling the tooltip with data yourself.
A JavaScript Framework of your choice will probably help a lot. Most have plugins or modules to handle mouseover and mouse position detection, though I can't recommend any specifically because I haven't tried this.
Chart Layout Interface
What you need to get the data values belonging to the mouse location is the Chart Layout Interface. You can get this as follows:
// create a line chart and set up a variable to store your interface
// on outside the scope of your ready handler, so you can use the
// interface in your mouse event code.
var layoutInterface;
var chart = new google.visualization.LineChart(document.getElementById('container-id'));
// set up a handler for the chart's ready event
// the chart layout interface is not available until the chart has
// been drawn
var readyHandler = function(){
layoutInterface = chart.getChartLayoutInterface();
};
// register the event handler
google.visualization.events.addListener(chart, 'ready', readyHandler);
I learned this from the demo here.
You will be using the getHAxisValue(xCoordinate) and getVAxisValue(yCoordinate) methods on the layout interface to get the data values corresponding to the x and y coordinates of the chart. The coordinates are relative to the chart's container element. See the Line Chart Documentation for information on methods available on the layout interface.
Mouse Event Handling
The mouse handling part of this is beyond the scope of my knowledge, but I do know that it is possible. I think you need to register a mouse enter event handler on your chart's container element, which would then register a mouse move, and mouse exit on the same element. The mouse exit would set display:none on your tooltip element and de-register the mouse move handler. The mouse move handler would set the absolute position of your tooltip element to the mouse location, and set it's content to the values retrieved from the chart layout interface.
Good Luck!
In Highcharts, is there a way to dynamically apply "halo" effect to points in scatter type charts without triggering hover event?
This is what I mean by halo:
http://api.highcharts.com/highcharts#plotOptions.series.states.hover.halo
You can call setState function on point and then apply SELECT / HOVER.
$('#btn').click(function(){
chart.series[0].data[2].setState('hover'); //alternatively SELECT state.
});
Example: http://jsfiddle.net/74s1cbmq/1/
I need to make a polygon highlight on mouse hover and restore its color and appearance once the mouse is moved out of the polygon.
I tried this with ScreenSpaceEventType.MOUSE_MOVE event handler but I am not able to restore the appearance when mouse is moved out of polygon in this case.
I tried https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/Sandcastle/gallery/Polygons.html (http://cesiumjs.org/Cesium/Apps/Sandcastle/gallery/polygons.html)
This file in Sancastle. It has inline comments like // For highlighting on mouseover in Sandcastle.
But it is not working as expected.
Is there any way in cesium to achieve this? or am I missing something?
Take a look at the "Picking" example in Sandcastle, and click on the button that says "Drill-down picking."
There are different ways to accomplish what you describe, but the above demo makes use of a Cesium CallbackProperty and provides a callback that will return either the polygon's normal color or the highlight color, depending on the "picked" status. Note that multiple overlapping polygons can be picked at the same time with this method.
The mouse move handler then just controls membership of the pickedEntities list, and the polygons choose appropriate colors for themselves based on their membership in that list.
I would like to know,
how can I move a gridLine up/down dynamically with the mouse in d3.js ?
Thanks a lot :)
The way I have done this in the past is to add an extra horizontal or vertical line to your graph and mark it as hidden.
Then whenever an element is moused-over show the line, whenever the element is moused-out hide the line again. You would need to set the X and Y values of the line such that it matches the location of the element the cursor is hovering over.
This is similar to the way showing/hiding tooltips work: https://gist.github.com/biovisualize/1016860 except you would not use a div (you would use a line) and would not use the location of the mouse pointer (you would use the x and y of the element).