mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 17:06:18 +00:00
Merge pull request #45 from jlayec/add-chargetable
add charge table to dashboard
This commit is contained in:
+17
-1
@@ -50,10 +50,11 @@ table_fig = None
|
||||
pandas_options.display.float_format = '${:.2f}'.format
|
||||
info = ""
|
||||
battery_info = dbc.Alert("No data to show", color="danger")
|
||||
battery_table = None
|
||||
|
||||
|
||||
def get_figures(trips: Trips, charging: List[dict]):
|
||||
global consumption_fig, consumption_df, trips_map, consumption_fig_by_speed, table_fig, info, battery_info
|
||||
global consumption_fig, consumption_df, trips_map, consumption_fig_by_speed, table_fig, info, battery_info, battery_table
|
||||
lats = []
|
||||
lons = []
|
||||
names = []
|
||||
@@ -149,3 +150,18 @@ def get_figures(trips: Trips, charging: List[dict]):
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
battery_table = dash_table.DataTable(
|
||||
id='battery-table',
|
||||
sort_action='native',
|
||||
sort_by=[{'column_id': 'start_at', 'direction': 'desc'}],
|
||||
columns=[{'id': 'start_at', 'name': 'start at', 'type': 'datetime'},
|
||||
{'id': 'stop_at', 'name': 'stop at', 'type': 'datetime'},
|
||||
{'id': 'start_level', 'name': 'start level', 'type': 'numeric'},
|
||||
{'id': 'end_level', 'name': 'end level', 'type': 'numeric'},
|
||||
{'id': 'co2', 'name': 'CO2', 'type': 'numeric',
|
||||
'format': deepcopy(nb_format).symbol_suffix(" g/kWh").precision(1)},
|
||||
{'id': 'kw', 'name': 'consumption', 'type': 'numeric',
|
||||
'format': deepcopy(nb_format).symbol_suffix(" kWh").precision(3)}],
|
||||
data=charging,
|
||||
)
|
||||
|
||||
+4
-2
@@ -27,6 +27,7 @@ min_date = max_date = min_millis = max_millis = step = marks = None
|
||||
Output('consumption', 'children'),
|
||||
Output('tab_trips', 'children'),
|
||||
Output('tab_battery', 'children'),
|
||||
Output('tab_charge', 'children'),
|
||||
Output('date-slider', 'max'),
|
||||
Output('date-slider', 'step'),
|
||||
Output('date-slider', 'marks'),
|
||||
@@ -41,8 +42,8 @@ def display_value(value):
|
||||
filtered_chargings = MyPSACC.get_chargings(mini, maxi)
|
||||
figures.get_figures(filtered_trips, filtered_chargings)
|
||||
consumption = "Average consumption: {:.1f} kWh/100km".format(float(figures.consumption_df.mean(numeric_only=True)))
|
||||
return figures.trips_map, figures.consumption_fig, figures.consumption_fig_by_speed, consumption, figures.table_fig, figures.battery_info, \
|
||||
max_millis, step, marks
|
||||
return figures.trips_map, figures.consumption_fig, figures.consumption_fig_by_speed, consumption, figures.table_fig, \
|
||||
figures.battery_info, figures.battery_table, max_millis, step, marks
|
||||
|
||||
|
||||
@app.route('/getvehicles')
|
||||
@@ -167,6 +168,7 @@ try:
|
||||
]),
|
||||
dbc.Tab(label="Trips", tab_id="trips", id="tab_trips", children=[figures.table_fig]),
|
||||
dbc.Tab(label="Battery", tab_id="battery", id="tab_battery", children=[figures.battery_info]),
|
||||
dbc.Tab(label="Charge", tab_id="charge", id="tab_charge", children=[figures.battery_table]),
|
||||
dbc.Tab(label="Map", tab_id="map", children=[
|
||||
dcc.Graph(figure=figures.trips_map, id="trips_map", style={"height": '90vh'})]),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user