如何将Plotly“漏斗"仪表板转换为Dash仪表板? [英] How to convert a Plotly 'Funnel' Dashboard to Dash Dashboard?

查看:253
本文介绍了如何将Plotly“漏斗"仪表板转换为Dash仪表板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将这个简单的绘图漏斗仪表板转换为Dash仪表板:

I am trying to convert this simple plotly funnel dashboard to a Dash dashboard:

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]))

fig.show()

输出:

我已经为Dash编写了以下代码,但是没有运气.

I have written the following piece of code for Dash but no luck.

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

app = dash.Dash()


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

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

输出:

C:\Users\Test\Documents\Code>python Funnel_Dash.py
Traceback (most recent call last):
  File "Funnel_Dash.py", line 23, in <module>
    app.layout = html.Div([dcc.Figure(id='FunnelDashboard',
AttributeError: module 'dash_core_components' has no attribute 'Figure'

推荐答案

Figure不是dash_core_components的属性.

我们可以改用Graph.

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()

这篇关于如何将Plotly“漏斗"仪表板转换为Dash仪表板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆