Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add the water level value to the interactive graph #237

Merged
merged 3 commits into from
Dec 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions gwhat/HydroCalc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ def __init_figure__(self):

offset = mpl.transforms.ScaledTranslation(-5/72, 5/72,
self.fig.dpi_scale_trans)
self.xcoord = ax0.text(1, 0, '', ha='right',
transform=ax0.transAxes + offset)
self.xcoord.set_visible(False)

# x and y coorrdinate labels displayed at the right-bottom corner
# of the graph
self.xycoord = ax0.text(
1, 0, '', ha='right', transform=ax0.transAxes + offset)
self.xycoord.set_visible(False)

# Peaks :
self._peaks_plt, = ax0.plot(
Expand Down Expand Up @@ -986,7 +989,7 @@ def setup_wl_style(self):
def draw(self):
"""Draw the canvas and save a snapshot of the background figure."""
self.vguide.set_visible(False)
self.xcoord.set_visible(False)
self.xycoord.set_visible(False)
self.xcross.set_visible(False)
self.canvas.draw()
self.__figbckground = self.fig.canvas.copy_from_bbox(self.fig.bbox)
Expand Down Expand Up @@ -1141,7 +1144,7 @@ def on_fig_leave(self, event):

def mouse_vguide(self, event):
"""
Draw the vertical mouse guideline and the x coordinate of the
Draw the vertical mouse guideline and the x and y coordinates of the
mouse cursor on the graph.
"""
if ((self.pan_is_active or self.zoom_is_active) and
Expand All @@ -1156,26 +1159,25 @@ def mouse_vguide(self, event):

# Trace a red vertical guide (line) that folows the mouse marker :

x = event.xdata
x, y = event.xdata, event.ydata
if x:
self.vguide.set_visible(
not self.pan_is_active and not self.zoom_is_active)
self.vguide.set_xdata(x)
ax0.draw_artist(self.vguide)

self.xcoord.set_visible(True)
self.xycoord.set_visible(True)
if self.dformat == 0:
self.xcoord.set_text('%d' % x)
self.xycoord.set_text(
'{:0.3f} mbgs\n{:0.1f} days'.format(y, x))
else:
date = xldate_as_tuple(x-self.dt4xls2mpl, 0)
yyyy = date[0]
mm = date[1]
dd = date[2]
self.xcoord.set_text('%02d/%02d/%d' % (dd, mm, yyyy))
ax0.draw_artist(self.xcoord)
self.xycoord.set_text('{:0.3f} mbgs\n{}/{}/{}'.format(
y, date[2], date[1], date[0]))
ax0.draw_artist(self.xycoord)
else:
self.vguide.set_visible(False)
self.xcoord.set_visible(False)
self.xycoord.set_visible(False)

# ---- Remove Peak Cursor

Expand Down