如何修改TradingView顶部工具栏颜色?现有配置未生效
问题:TradingView图表顶部工具栏颜色无法通过现有样式覆盖修改
我为TradingView图表配置了以下样式覆盖设置:
let chartStyleOverrides = { 'scalesProperties.bgColor': bgColor, 'paneProperties.background': bgColor, 'paneProperties.backgroundType': 'solid', 'paneProperties.legendProperties.showBackground': false, };
这些设置能修改图表其他所有区域的颜色,但最顶部的工具栏仍为白色(未变为灰色),如图所示:

请问如何修改该顶部工具栏的颜色?
解决方案
要修改顶部工具栏的颜色,只需在样式覆盖配置中添加headerProperties.background项即可,示例代码如下:
let bgColor = '#你的目标颜色值'; // 替换为你需要的灰色或自定义颜色 let chartStyleOverrides = { 'scalesProperties.bgColor': bgColor, 'paneProperties.background': bgColor, 'paneProperties.backgroundType': 'solid', 'paneProperties.legendProperties.showBackground': false, 'headerProperties.background': bgColor, // 新增该行修改工具栏背景色 };
如果需要调整工具栏的配套元素颜色,还可以补充以下配置:
headerProperties.fontColor: 设置工具栏文字颜色headerProperties.borderColor: 设置工具栏底部边框颜色
内容的提问来源于stack exchange,提问作者ilmoi
相关产品推荐
相关产品推荐

