简体   繁体   中英

Plotly-Dash displays the wrong graph (line plot instead of funnel)

I am trying to display a simple funnel graph using dash and plotly. The problem is that it displays a line graph instead.

I followed the instructions from this answer, that is, used the code:

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

but am getting this line plot instead.

What I expect to get is something like this .

Update dash:

pip install -U dash

With version 1.9.1 , using this code:

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

you get:

在此处输入图片说明

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