如何将图表背景颜色设置为黑色



我正在使用[lightweight charts]javascript库生成一些图表。在这个例子中,我使用的是实时模拟图表。

在本例中,背景颜色为白色。我想把背景颜色设置为黑色。我正在遵循文档,但我无法实现目标。

以下是我正在使用的代码,但它不起作用:

var chart = LightweightCharts.createChart(document.getElementById('chart'), {
width: 1200,
height: 800,
background: '#000000',
textColor: '#ffffff'
});

var candleSeries = chart.addCandlestickSeries();
var data = [...]

我错过了什么?

您需要同时包装背景&textlayout属性(如(内的颜色

var chart = LightweightCharts.createChart(document.getElementById('chart'), {
width: 1200,
height: 800,
layout: {
background: {
color: '#000000'
},
textColor: '#ffffff'
}
});

如本文档所示

最新更新