Opened 11 years ago

Closed 4 years ago

#8518 closed enhancement (patchwelcome)

Charting Events on Lines

Reported by: ryangroth5 Owned by: Eugene Lazutkin
Priority: high Milestone: 1.13
Component: Charting Version: 1.2.3
Keywords: charting lines events Cc: dojo@…
Blocked By: Blocking:

Description

Eugene,

I ran into a use-case where I am plotting several lines on a graph, where each has a different scale and thus a different plot. I wanted to extract the X/Y pairs from the line model and display them externally in a tooltip (similiar to google finance charts). I hooked up the event listener to my plots and no event fired except plot reset (this is 1.3pre).

I would like to propose the following quickie changes:

  1. Hook up event listeners to the plot lines.
  1. Provide some abstraction from the scalers within the plot2d object to transform between plot-relative x/y's and the model x/y's.

Here are what you have to decide:

  1. I don't know exactly what the event params should be for a relative line position. I understand that this position could be interpolated, which is not an issue for me.
  1. I made a couple assumptions in _connectEvents, I am not sure they are accurate.
  1. I added a modelXY2PlotXY and plotXY2ModelXY, you probably want to use dojo.coords or something like that. This is just for fun.
  1. I'm not sure all the performance implications. I was kinda surprised to see such a general connectEventToPlot without parameters for event type. Adding an event listener to a line doesn't seem to have such a big performance implication, but I don't know.

IN THE FUTURE...

  1. Consider chart-wide onMouseMove events, so that in the future you can hook up the legend and get google finance like X/Y's on all plots.

Thanks,

Ryan

Thanks for the consideration

Attachments (2)

charting.diff (3.4 KB) - added by ryangroth5 11 years ago.
Charting changes for line events.
charting2.diff (3.6 KB) - added by ryangroth5 11 years ago.
Update (disregard 1st diff) that fixes windowing issue, and fixes estimates on "XY" functions. Some remaining issues described below.

Download all attachments as: .zip

Change History (8)

Changed 11 years ago by ryangroth5

Attachment: charting.diff added

Charting changes for line events.

comment:1 Changed 11 years ago by ryangroth5

Oh. Did I mention that I attached a code sample and have a CLA on file.

comment:2 Changed 11 years ago by ryangroth5

Err...OK, so plotXY2ModelXY doesn't take into account the window function and/or the chart axis offsets. I think the way to fix this is to add in the appropriate window function offsets before plotEvent and make transform work with the size of the chart to translate correctly. Anyway, it would be great to be able to get out the original coordinates of a plot given an XY offset in the chart.

Thanks

Changed 11 years ago by ryangroth5

Attachment: charting2.diff added

Update (disregard 1st diff) that fixes windowing issue, and fixes estimates on "XY" functions. Some remaining issues described below.

comment:3 Changed 11 years ago by ryangroth5

The only issue I have is a scroll-offset issue with the major browsers. As far as I understand the dojo.coords calls dojo.abs with the scroll-accountable flag set to true, which should give an absolute offset, but that is not happening somewhere down the line. I also don't understand the difference between cx, cy and x,y as far as lines are concerned.

comment:4 Changed 11 years ago by dante

Milestone: 1.31.4

punting all 1.3 enhancements.

comment:5 Changed 10 years ago by bill

Milestone: 1.4future

comment:6 Changed 4 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: newclosed

I have no idea why this never got attention 7 years ago. At this point, this is way out of date. If there's still this issue, and interest, I'm happy to work with you on a pull request. For now, I'm closing as patchwelcome.

Note: See TracTickets for help on using tickets.