Skip to content

Commit

Permalink
added max time value checks
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkp committed Jun 23, 2021
1 parent a77bf59 commit 6e40855
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/tesla_ver/charting/charting.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ def update_figure(time_value, y_column_name, x_column_name, json_data, marks, md
if time_value == None:
time_value = int(mdata.get("time_min"))

if time_value == int(mdata.get("time_max")):
time_value

# Loads dataframe at specific time value by getting the time as a key from a dictionary,
# then evaluates it to turn it into a python dictionary, and then loads it as a dataframe
try:
df_by_time = pd.DataFrame.from_dict(literal_eval(json.loads(json_data).get(str(time_value))))
except ValueError:
server.logger.debug(f"❌ unable to load dataframe at time value: {str(time_value)}")
pass

server.logger.debug("✅ dataframe filtered by time")
Expand Down Expand Up @@ -244,12 +248,15 @@ def play_pause_switch(n_clicks):
return [play_status, play_bool]

@app.callback(
Output("time-slider", "value"), [Input("play-interval", "n_intervals")], [State("time-slider", "value")]
[Output("time-slider", "value"), Output("play-interval", "disabled")], [Input("play-interval", "n_intervals")], [State("time-slider", "value"), State("df-mdata", "data")]
)
def play_increment(n_intervals, time_value):
def play_increment(n_intervals, time_value, mdata):
if time_value is None:
raise PreventUpdate
return str(int(time_value) + 1)
if int(time_value) == int(mdata.get("time_max")):
server.logger.debug(f'Max time value reached, returning max value')
return [str(int(time_value)), True]
return [str(int(time_value) + 1), False]

@app.callback(
[Output("left-line-plot-graph", "figure"), Output("right-line-plot-graph", "figure")],
Expand Down

0 comments on commit 6e40855

Please sign in to comment.