【发布时间】:2020-04-23 10:28:43
【问题描述】:
有没有办法在绘图饼图上显示实际值而不是百分比?
下面是views.py 文件中的示例代码。然后将图形变量传递给 HTML 文件以显示从 plotly 生成的交互式图像。
import plotly.express as px
import pandas as pd
def my_view(request):
esd = df.groupby('ProjectStatus', as_index=False).agg({"ProjectID": "count"})
fig = px.pie(esd, values=Tasks, names=my_labels, color_discrete_sequence=px.colors.sequential.Blugrn)
graph = fig.to_html(full_html=False, default_height=350, default_width=500)
context = {'graph': graph}
以上将生成附加的饼图。悬停时提到的值应显示在饼图或工具提示中。
【问题讨论】:
-
嗨Rishabh Aher,不需要共享所有的sql连接和查询。
-
您好 rpanai,我已经删除了 sql 连接和查询部分。谢谢!