diff --git a/API.txt b/API.txt index 6f72aec..133cb83 100644 --- a/API.txt +++ b/API.txt @@ -495,8 +495,9 @@ An example function might look like this: If you set "clickable" to true, the plot will listen for click events on the plot area and fire a "plotclick" event on the placeholder with -a position and a nearby data item object as parameters. The returned -coordinates are in the unit of the axes (not in pixels). +a position and a nearby data item object as parameters. The coordinates +are available both in the unit of the axes (not in pixels) and in +global screen coordinates. If you set "hoverable" to true, the plot will listen for mouse move events on the plot area and fire a "plothover" event with the same @@ -508,7 +509,8 @@ You can use "plotclick" and "plothover" events like this: $("#placeholder").bind("plotclick", function (event, pos, item) { alert("You clicked at " + pos.x + ", " + pos.y); - // secondary axis coordinates if present are in pos.x2, pos.y2 + // secondary axis coordinates if present are in pos.x2, pos.y2, + // if you need global screen coordinates, they are pos.pageX, pos.pageY }); The item object in this example is either null or a nearby object on the form: @@ -518,6 +520,7 @@ The item object in this example is either null or a nearby object on the form: dataIndex: the index of the point in the data array series: the series object seriesIndex: the index of the series + pageX, pageY: the global screen coordinates of the point } For instance, if you have specified the data like this diff --git a/NEWS.txt b/NEWS.txt index b0fff73..526d33b 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -8,7 +8,8 @@ compatibility hooks are in place). Interactivity: added a new "plothover" event and this and the "plotclick" event now returns the closest data item (based on patch by -/david). +/david). See the revamped "interacting with the data" example for +some hints on what you can do. Timestamps in time mode are now displayed according to UTC instead of the time zone of the visitor. This affects the way the diff --git a/TODO b/TODO index 1add33e..f58efdd 100644 --- a/TODO +++ b/TODO @@ -28,12 +28,13 @@ legend labels - labels on bars, data points - - plain "all points" option - - interactive "label this point" command + - interactive "label this point" command/tooltip support error margin indicators - for scientific/statistical purposes +hi-low bars + non-xy based graph types - figure out how to integrate them with the rest of the plugin - pie charts diff --git a/examples/interacting.html b/examples/interacting.html index 029b97a..82f4b0f 100644 --- a/examples/interacting.html +++ b/examples/interacting.html @@ -14,13 +14,15 @@

One of the goals of Flot is to support user interactions intelligently. - Try hovering over the graph above and clicking on the points (note that support for highlighting the points is still missing).

+ Try hovering over the graph above and clicking on the points. A + tooltip is easy to build with a bit of jQuery code and the data returned + from the plot. Note that support for highlighting the points is + currently missing.

+ (, ).