+ output.set_values({
+ "graph-tput-figure": self.NO_GRAPH,
+ "graph-lat-figure": self.NO_GRAPH,
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests()
+ })
+
+ return output.value()
+
+ @app.callback(
+ Output("metadata-tput-lat", "children"),
+ Output("metadata-hdrh-graph", "children"),
+ Output("offcanvas-metadata", "is_open"),
+ Input("graph-tput", "clickData"),
+ Input("graph-latency", "clickData")
+ )
+ def _show_tput_metadata(tput_data, lat_data) -> dbc.Card:
+ """
+ """
+ if not (tput_data or lat_data):
+ raise PreventUpdate
+
+ metadata = no_update
+ graph = list()
+
+ trigger_id = callback_context.triggered[0]["prop_id"].split(".")[0]
+ if trigger_id == "graph-tput":
+ title = "Throughput"
+ txt = tput_data["points"][0]["text"].replace("<br>", "\n")
+ elif trigger_id == "graph-latency":
+ title = "Latency"
+ txt = lat_data["points"][0]["text"].replace("<br>", "\n")
+ hdrh_data = lat_data["points"][0].get("customdata", None)
+ if hdrh_data:
+ graph = [dcc.Graph(
+ id="hdrh-latency-graph",
+ figure=graph_hdrh_latency(hdrh_data, self.layout)
+ ), ]
+
+ metadata = [
+ dbc.Card(
+ children=[
+ dbc.CardHeader(children=[
+ dcc.Clipboard(
+ target_id="tput-lat-metadata",
+ title="Copy",
+ style={"display": "inline-block"}
+ ),
+ title
+ ]),
+ dbc.CardBody(
+ id="tput-lat-metadata",
+ children=[txt]
+ )
+ ]
+ )
+ ]
+
+ return metadata, graph, True
+
+ @app.callback(
+ Output("download-data", "data"),
+ State("selected-tests", "data"),
+ Input("btn-download-data", "n_clicks"),
+ prevent_initial_call=True
+ )
+ def _download_data(store_sel, n_clicks):
+ """
+ """
+
+ if not n_clicks:
+ raise PreventUpdate
+
+ df = pd.DataFrame()
+ for itm in store_sel:
+ sel_data = select_trending_data(self.data, itm)
+ if sel_data is None:
+ continue
+ df = pd.concat([df, sel_data], ignore_index=True)
+
+ return dcc.send_data_frame(df.to_csv, "trending_data.csv")