最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - lightweight-charts - How to setup a chart background collor to black? - Stack Overflow

programmeradmin2浏览0评论

I am using the [lightweight-charts] javascript library to generate some charts. For this example I am using the Realtime emulation chart.

In this example the background color is white. I would like to set the background color to black. I am following the documentation but I can't achieve the goal.

Following is the code I am using but it is not working:

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


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

What am I missing?

I am using the [lightweight-charts] javascript library to generate some charts. For this example I am using the Realtime emulation chart.

In this example the background color is white. I would like to set the background color to black. I am following the documentation but I can't achieve the goal.

Following is the code I am using but it is not working:

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


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

What am I missing?

Share Improve this question asked Mar 28, 2022 at 20:38 IgorAlvesIgorAlves 5,56014 gold badges62 silver badges95 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You'll need to wrap both background & textColor within a layout property like

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

as seen in this doc

发布评论

评论列表(0)

  1. 暂无评论