Replace Plotly graph-based tables with Dash DataTable
This commit is contained in:
@@ -19,7 +19,7 @@ from stats.id_viewer import _format_can_id_vec, plot_bits
|
||||
from stats.frequency import calculate_frequency, plot_frequency
|
||||
from stats.correlation import calculate_correlation, plot_correlation_heatmap
|
||||
from stats.entropy import calculate_byte_entropy, plot_entropy_heatmap
|
||||
from logs import render_logs_table
|
||||
from logs.view import prepare_logs_data, get_logs_table_component
|
||||
|
||||
RAW_LOG_DIR = "data/logs"
|
||||
|
||||
@@ -86,6 +86,7 @@ for log_file in Path(RAW_LOG_DIR).glob("*.txt"):
|
||||
PRECOMPUTED_FIGURES = {}
|
||||
DATA_BY_ID = {}
|
||||
CORR_CACHE = {}
|
||||
LOGS_CACHE = {}
|
||||
|
||||
def process_bus_data(vehicle, bus, df):
|
||||
precomp = {}
|
||||
@@ -146,7 +147,7 @@ app.layout = dbc.Container([
|
||||
clearable=False
|
||||
), width=2),
|
||||
], className="mb-3 mt-3", align="end"),
|
||||
html.Div(id='logs-table-container')
|
||||
get_logs_table_component()
|
||||
]),
|
||||
dbc.Tab(label="Statistics", tab_id="statistics", children=[
|
||||
dbc.Row([
|
||||
@@ -177,14 +178,30 @@ app.layout = dbc.Container([
|
||||
], fluid=True)
|
||||
|
||||
@app.callback(
|
||||
Output('logs-table-container', 'children'),
|
||||
[Output('logs-table', 'data'),
|
||||
Output('logs-table', 'columns'),
|
||||
Output('logs-info-text', 'children')],
|
||||
Input('logs-vehicle-selector', 'value'),
|
||||
Input('logs-bus-selector', 'value')
|
||||
)
|
||||
def update_logs_table(vehicle, bus):
|
||||
if not vehicle or not bus or vehicle not in DATA or bus not in DATA[vehicle]:
|
||||
return html.Div("No data available")
|
||||
return render_logs_table(DATA[vehicle][bus])
|
||||
return [], [], "No data available"
|
||||
|
||||
cache_key = (vehicle, bus)
|
||||
if cache_key not in LOGS_CACHE:
|
||||
display_df = prepare_logs_data(DATA[vehicle][bus])
|
||||
LOGS_CACHE[cache_key] = display_df
|
||||
else:
|
||||
display_df = LOGS_CACHE[cache_key]
|
||||
|
||||
total_rows = len(display_df)
|
||||
columns = [{"name": col, "id": col} for col in display_df.columns]
|
||||
data = display_df.to_dict('records')
|
||||
|
||||
info_text = f"Displaying {total_rows} frames."
|
||||
|
||||
return data, columns, info_text
|
||||
|
||||
@app.callback(
|
||||
Output('tab-content', 'children'),
|
||||
|
||||
Reference in New Issue
Block a user