Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Issue formatting datetime data on plot

$
0
0

Hello all, I’m new to Dash and have what is probably a simple question. I’m plotting data pulled from an SQL server as a function of time. Having trouble with the axis formatting as can be seen here:

I want the time data to show up as hour:minute:seconds instead of the current format. How would I go about fixing this?

def update_graph_scatter(n):

    dataSQL = []
    conn = pymysql.connect("localhost","root","abc123","db")
    sql_select_Query = "select Time,Value4 from Weather"
    cursor = conn.cursor()
    cursor.execute(sql_select_Query)
    records = cursor.fetchall()
    X = deque(maxlen=10)
    Y = deque(maxlen=10)
    for row in records:
        dataSQL.append(list(row))
        labels = ['Time','Value-4']
        df = pd.DataFrame.from_records(dataSQL, columns=labels)
        X = df['Time']
        Y = df['Value-4']

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

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

if __name__ == "__main__":

    app.run_server(debug=True)

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles