CDAT / vcs-js

3 stars 3 forks source link

Interaction popup gives wrong values #58

Open James-Crean opened 6 years ago

James-Crean commented 6 years ago

When clicking on a plot a small popup appears that lists the lat, lon, and value. The longitude values however, do not match up with the location on the plot. It looks as though there is a scaling issue, as values near 0 are much closer to where they should be, and the values reported near the edges can be 30 degrees off. For example clicking near zero reports '.4', clicking 30 reports '24' and clicking 150 reports '118'

Steps to recreate:

  1. Run the vcs-js demo
  2. Click anywhere on the plot and compare the reported longitude to the values shown on the axis.
doutriaux1 commented 6 years ago

@James-Crean are you using vcs nightly? I sort of remember correcting this issue before.

James-Crean commented 6 years ago

When I checked it I think I was using the same environment for vcs-js, and vcs. It worked fine in vcs when I just opened a variable and did .interact().

scottwittenburg commented 6 years ago

I was able to reproduce this issue. It seems that doing canvas.interact() locally does indeed give different results than interacting with a plot canvas in vcs-js. I'll look into it.

ping @aashish24 @danlipsa

scottwittenburg commented 6 years ago

It seems there's something funny going on in vcs-js. I have captured two screenshots, one from the vcs-js demo, and one from doing canvas.interact() locally. In both cases, the geometry is given to vcs as 800 x 600, and somehow the web layer results in an image where the plot itself is not stretched to the edge of the canvas to line up with the legend (scalar bar) and text. I'm guessing this is where the problem with the interaction pop-up lies.

boxfill-canvas-vcsjs

The image above was captured out of a browser running the vcs-js demo, while the one below was captured from a standalone vcs script running canvas.interact().

boxfill-canvas-interact

@danlipsa Does this ring any bells for you?

scottwittenburg commented 6 years ago

Ok, after quite some debugging, I think I have found the culprit:

https://github.com/CDAT/vcs-js/blob/fcf9f0f186f3fca337499ce393a054b60f9a4ba1/vcs_server/PlotManager.py#L95

If I change that line so that it does not pass ratio="autot", then the plot we see in the demo application matches the expectation (full width) and the interaction popup gives the correct values.

@doutriaux1 any idea why this might have been there, or what purpose that autot thingy is intended to serve in the web context? Or why interaction is wrong when autot is turned on? Here's a simple vcs script that will reproduce the problem completely outside of vcs-js:

import vcs, cdms2

cltfile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
clt = cltfile("clt")
canvas = vcs.init(geometry={'width': 800, 'height':600})
box = canvas.createboxfill()
canvas.plot(clt, box, ratio="autot")
canvas.interact()

Now what to do about it as far as vcs-js goes? I'm for just removing the ratio="autot" from the plot call unless you guys know why we're doing that.

ping @aashish24