【问题标题】:Plotly-Dash displays the wrong graph (line plot instead of funnel)Plotly-Dash 显示错误的图形(线图而不是漏斗图)
【发布时间】:2020-03-02 09:04:19
【问题描述】:

我正在尝试使用破折号和绘图显示一个简单的漏斗图。问题是它显示的是折线图。

我按照this答案的说明,也就是使用了代码:

app = dash.Dash()

app.layout = html.Div([dcc.Graph(id='FunnelDashboard',
                figure = {'data':[
                        go.Funnel(
                        y = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"],
                        x = [39, 27.4, 26.6, 11, 2])]
                        }
                        )])
if __name__ == '__main__':
    app.run_server()

但我得到的是this 线图。

我期望得到类似this

【问题讨论】:

  • 运行上面的代码,我确实得到了你描述的漏斗图。所以肯定有其他问题。

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


【解决方案1】:

更新破折号:

pip install -U dash

使用版本1.9.1,使用此代码:

import dash
import dash_html_components as html
import dash_core_components as dcc
from plotly import graph_objects as go

fig = go.Figure(go.Funnel(
    y = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"],
    x = [39, 27.4, 20.6, 11, 2]))


external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)


app.layout = html.Div([dcc.Graph(id='FunnelDashboard',
                    figure=fig)])

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

你得到:

【讨论】:

    猜你喜欢
    • 2019-06-25
    • 2022-07-30
    • 2022-08-14
    • 2020-10-20
    • 2021-11-14
    • 1970-01-01
    • 2021-11-04
    • 2020-08-25
    • 1970-01-01
    相关资源
    最近更新 更多