1

不确定这是否是一个限制,但我不能让图表显示所有数据(我有 1500 条记录)。fitContent() 或 setVisibleRange() 没有帮助。

演示

var chart = LightweightCharts.createChart(document.body, {
    width: 600,
    height: 300,
    rightPriceScale: {
        scaleMargins: {
            top: 0.1,
            bottom: 0.1,
        },
    },
});

var areaSeries = chart.addAreaSeries({
    topColor: 'rgba(76, 175, 80, 0.56)',
    bottomColor: 'rgba(76, 175, 80, 0.04)',
    lineColor: 'rgba(76, 175, 80, 1)',
    lineWidth: 2,
    title: 'AAPL',
});

areaSeries.setData([{
    "time": 1629353327,
    "value": 19.97
}, {
    "time": 1629439727,
    "value": 19.67
},
....
}]);
chart.timeScale().fitContent();

这是预期的吗?如果图表宽度设置为 800 像素,它将起作用。

4

1 回答 1

0

默认情况下,最小条间距值(条之间的最小间距)为 0.5,这允许您每 1 个像素显示 2 个值。但是如果你想在一个小的视口中显示更多的数据,你需要把这个值改成一个更小的值,例如0.001。

您可以通过修改minBarSpacing选项timeScale来做到这一点- 只需添加timeScale: { minBarSpacing: 0.001 }到图表的选项中即可。演示

于 2021-08-18T09:45:50.360 回答