streamlit highcharts:如何显示汉堡菜单

0 投票
2 回答
50 浏览
提问于 2025-04-14 18:27

我正在尝试复现这里的代码:https://aalteirac-streamlit-highcharts-test-app-main-3vgde6.streamlit.app

我得到了图表,完全可以正常工作,只是我没有看到可以下载图表的汉堡菜单。

你能给我一些建议吗?

我在使用macOs,Python 3.11,streamlit 1.3和streamlit_highcharts 0.2。

2 个回答

0

这个“汉堡”菜单是和导出模块有关的。所以如果你想使用这个菜单,你只需要导入导出模块就可以了。

文档链接:https://www.highcharts.com/blog/tutorials/using-highcharts-for-python-basic-tutorial/#:~:text=Importing%20Highcharts%20for%20Python

1

我在我的电脑上也能复现这个问题,配置的版本和你的差不多。

看起来(原因我不太清楚),这个导出按钮是被库 streamlit-highcharts 故意隐藏的,使用了CSS样式(display 设置为 None)。

要显示这个 ham-button,你需要在 这个文件中注释掉第4到第6行(在本地):

streamlit_highcharts\frontend\style.css

text.highcharts-credits {
    display: none;
}
/* .highcharts-exporting-group {
    display: none;
} */
div[class*="chartMenu"] {
    display: none;
}

然后,你就可以构建你的图表了:

import streamlit_highcharts as hg

hg.streamlit_highcharts(hg.SAMPLE2, 640)

assert "exporting" in hg.SAMPLE2 # True

注意:确保你的图表定义(dict)中有一个 exporting 键。

在这里输入图片描述

撰写回答