【问题标题】:python: dash live plot legendspython: dash 实况情节图例
【发布时间】:2021-11-08 11:37:27
【问题描述】:

我最近写了一个破折号程序 它正在刷新记录数并刷新或重绘无花果 问题是当我过滤 1 个或多个图例时,它不会显示任何点 但是当您将鼠标悬停在不可见的点上时,它会显示该点的数据 我的代码:

from threading import Event
import dash
from dash import dcc, Input, Output
from dash import html
from dash.dcc.Interval import Interval
import plotly.express as px
import pandas as pd
import sqlalchemy




app = dash.Dash(__name__)

# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options


connection = sqlalchemy.create_engine('mysql+pymysql://*:*@localhost:*')

df = pd.read_sql_table('rawdata_clean', connection)

fig = px.scatter(df, x="Size", y="Price", color="Neighbourhood_Per")


index = df.index
app.layout = html.Div(children=[
    
    html.H1(id='Numberofrecords', children= len(index)),
    dcc.Interval(id='up-Numberofrecords', interval=3000, n_intervals=0),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),
    
    dcc.Graph(
        id='grph',
        
        animate=True
        
    ),

    dcc.Interval(id='up-graph', interval=3000, n_intervals=0)
  
])


@app.callback(Output('grph', 'figure'),
              Input('up-graph', 'n_intervals'))

def update_graph (n):
    
    df = pd.read_sql_table('rawdata_clean', connection)
    

    fig = px.scatter(df, x="Size", y="Price", color="Neighbourhood_Per")
    
    return fig


@app.callback(Output('Numberofrecords', 'children'),
              Input('up-Numberofrecords', 'n_intervals'))

def up_Numberofrecords (n):
    
    df = pd.read_sql_table('rawdata_clean', connection)
    index = df.index
   
    print('up_Numberofrecords')
    return len(index)

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

这段代码有问题吗? 我是 dash 和 plotly 的新手:D

【问题讨论】:

    标签: python python-3.x plotly plotly-dash


    【解决方案1】:

    问题是:

    animate=True
    

    IDK 这段代码的作用,但通过删除它,它开始工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      • 2021-05-22
      • 2015-04-25
      相关资源
      最近更新 更多