You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Streamlit中实现Highcharts圆柱图表失败求助

圆柱图表无法显示的排查与修复

问题出在Highcharts的圆柱图属于非核心扩展模块,默认不会被streamlit_highcharts加载,而瀑布图、面积图属于核心图表类型,所以能正常显示。修复只需显式指定加载所需的3D和圆柱模块:

修改后的完整代码

import streamlit as st
import streamlit_highcharts as hct

chart_week_day={
    "chart": {
        "type": "cylinder",
        "options3d": {
            "enabled": True,
            "alpha": 8,
            "beta": 15,
            "depth": 50,
            "viewDistance": 150
        }
    },
    "title": {
        "text": "Return by Weekday"
    },
    "xAxis": {
        "categories": ["Monday","Tuesday","Wednesday","Thursday","Friday"],
        "title": {
            "text": ''
        }
    },
    "yAxis": {
        "title": {
            "margin": 40,
            "text": '$'
        }
    },
    "plotOptions": {
        "series": {
            "depth": 300,
            "colorByPoint": False,
            "negativeColor": 'pink'
        }
    },
    "series": [{
        "data": [200,300,400,500,600],
        "name": '$',
        "showInLegend": False
    }]
}

# 关键:添加modules参数,加载3D和圆柱模块
hct.streamlit_highcharts(chart_week_day, 500, key="week_day", modules=["highcharts-3d", "cylinder"])

核心说明

  • Highcharts的cylinder图表类型依赖highcharts-3d基础模块和cylinder扩展模块,必须在调用组件时通过modules参数明确指定加载。
  • 其他核心图表类型(如瀑布图、面积图)无需额外加载模块,因此之前能正常渲染。

内容的提问来源于stack exchange,提问作者Andrew Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 05:20:49