Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Live update table dash

I get the constant error of

import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import plotly.express as px
import pandas as pd
import numpy as np

#Custom
from assets.dashcumponents import dashcumps
from assets.exchangeWrappers.FTX.ftx_api import FtxApi
from assets.exchangeWrappers.FTX import ftx_client

#Disabling the god damm gay ass "meh copy slice" warning
pd.options.mode.chained_assignment = None

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

#Default vars that need to be filled in
positions_df = ftx_client.getGroupedPositions()

app.layout = html.Div(children=[
    dashcumps.Navbar(),    
    dashcumps.CreateTable(df=positions_df,table_id="positions-component"),
    dcc.Interval(id="interval-component",interval=1000,n_intervals=0)
])


@app.callback(dash.dependencies.Output("positions-component","data"),
              [dash.dependencies.Input("interval-component","n_intervals")])
def updatePositions():
    positions_df = ftx_client.getGroupedPositions()
    return positions_df


if __name__ == '__main__':
    app.run_server(debug=True)

the error i receive;
Callback error updating positions-component.data

the function i use in dashcumps.py:

def CreateTable(df,table_id):
        return dash_table.DataTable(
                id=table_id,
                columns=[{"name": i, "id": i} for i in df.columns],
                data=df.to_dict('records'))```

Hi @JonasVerhalen

Since I can’t run the code you posted, I’m not sure this will work… but try adding a variable name (like n or _ ) for the interval-component in the callback function.

Even if the value is not used in the function, it still needs to be defined as an input argument.

n_intervals=0

is already filled in
updatePositions() take 0 arguments but gets one is the main error