简体   繁体   中英

positional argument follows keyword argument graphics with dash python

This code graphs data obtained by sensors, uses the dash library to graph, when I try to run it sends me that error, apparently the error is in the "return".

This is the code:

def update_graph_scatter(interval):

    dataSQL = []
    X = deque(maxlen=10)    
    Y = deque(maxlen=10)

    sql_conn = MySQLdb.connect('localhost', 'root', 'pass', 'DB')
    cursor = sql_conn.cursor()
    cursor.execute("SELECT value,timestamp FROM sensorParser where sensor='TC'")
    #and timestamp >= timestamp()-4seg"
    rows = cursor.fetchall()
    for row in rows:
        dataSQL.append(list(row))
        labels = ['value','timestamp']
        df = pd.DataFrame.from_records(dataSQL, columns=labels)
        X = df['timestamp']
        Y = df['value'].astype(float)

        #if (float(df['value'][0]) > 25):

    data = plotly.graph_objs.Scatter(
            x=list(X),
            y=list(Y),
            name='TEMP',
            mode= 'lines+markers',

            )

    return {'data': [data],'layout':go.Layout(title="TEMPERATURA",xaxis=dict(range=[min(X),max(X)]),
                                            yaxis=dict(range=[min(Y),max(Y)]),MAX_POINTS_TO_SHOW,)}

Regards.

When calling a function you have positional arguments, eg - foo(1, 2, 3) and keyword arguments, eg foo(a=1, b=2, c=3) . Positional arguments cannot appear after keywords arguments and that the issue in you code when calling go.Layout . MAX_POINTS_TO_SHOW needs to have a the variable name before it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM