MarcSkovMadsen commited on
Commit
56abc4b
1 Parent(s): 44478f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -48,8 +48,13 @@ body {
48
 
49
  """
50
 
51
- DATA_A = pd.read_csv(DASHBOARD_A_PATH, index_col=0)
52
- DATA_B = pd.read_csv(DASHBOARD_B_PATH, index_col=0)
 
 
 
 
 
53
 
54
 
55
  class Dashboard(pn.viewable.Viewer):
@@ -160,7 +165,7 @@ class Dashboard(pn.viewable.Viewer):
160
 
161
  @pn.depends("tool", "variable", "color_map")
162
  def _get_insert_plot(self):
163
- plot_data = DATA_A.loc[self.tool]
164
  data = [(plot_data["Xo"], plot_data["Yo"], plot_data[self.variable])]
165
  return hv.Path(data, vdims=self.variable).opts(
166
  cmap=self.color_map, color=self.variable, line_width=4, colorbar=True, responsive=True
@@ -168,14 +173,14 @@ class Dashboard(pn.viewable.Viewer):
168
 
169
  @pn.depends("tool", "variable", "color_map")
170
  def _get_edge_plot(self):
171
- plot_data = DATA_A.loc[self.tool]
172
  return plot_data.hvplot(
173
  x="Number", y=self.variable, kind="area", alpha=0.6, color=self._color, responsive=True
174
  )
175
 
176
  @pn.depends("tool", "color_map")
177
  def _update_history_plot(self):
178
- plot_data = DATA_B.loc[self.tool]
179
  return plot_data.hvplot(
180
  x="Cut Distance", y="Feed", kind="line", line_width=4, responsive=True
181
  ).opts(color=self._color)
 
48
 
49
  """
50
 
51
+ @pn.cache
52
+ def _get_data_a():
53
+ return pd.read_csv(DASHBOARD_A_PATH, index_col=0)
54
+
55
+ @pn.cache
56
+ def _get_data_b():
57
+ return pd.read_csv(DASHBOARD_B_PATH, index_col=0)
58
 
59
 
60
  class Dashboard(pn.viewable.Viewer):
 
165
 
166
  @pn.depends("tool", "variable", "color_map")
167
  def _get_insert_plot(self):
168
+ plot_data = _get_data_a().loc[self.tool]
169
  data = [(plot_data["Xo"], plot_data["Yo"], plot_data[self.variable])]
170
  return hv.Path(data, vdims=self.variable).opts(
171
  cmap=self.color_map, color=self.variable, line_width=4, colorbar=True, responsive=True
 
173
 
174
  @pn.depends("tool", "variable", "color_map")
175
  def _get_edge_plot(self):
176
+ plot_data = _get_data_a().loc[self.tool]
177
  return plot_data.hvplot(
178
  x="Number", y=self.variable, kind="area", alpha=0.6, color=self._color, responsive=True
179
  )
180
 
181
  @pn.depends("tool", "color_map")
182
  def _update_history_plot(self):
183
+ plot_data = _get_data_b().loc[self.tool]
184
  return plot_data.hvplot(
185
  x="Cut Distance", y="Feed", kind="line", line_width=4, responsive=True
186
  ).opts(color=self._color)