英文:
How to remove non market hrs/time on trading view lightweight-chart?
问题
以下是翻译好的部分:
我是轻量级图表(lightweight-chart)的新手,每一行的数据间隔为5分钟。现在我需要删除非市场小时 - 请参见下文。有任何方法可以移除这部分吗?
当前图表选项:
const chart = createChart(chartContainerRef.current, {
crosshair: {
mode: 0, // CrosshairMode.Normal
},
layout: {
background: { type: ColorType.Solid, color: colors.backgroundColor },
textColor: colors.textColor,
},
timeScale: {
borderColor: "#fff000",
visible: true,
timeVisible: true,
secondsVisible: true,
},
width: chartContainerRef.current.clientWidth,
height: 500,
});
chart.timeScale().fitContent();
英文:
I'm new to lightweight-chart and have data that 5 minutes apart on each row. Now I need to remove the non market hours - See below. Any option to remove this?
Current chart option
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
const chart = createChart(chartContainerRef.current, {
crosshair: {
mode: 0, // CrosshairMode.Normal
},
layout: {
background: { type: ColorType.Solid, color: colors.backgroundColor },
textColor: colors.textColor,
},
timeScale: {
borderColor: "#fff000",
visible: true,
timeVisible: true,
secondsVisible: true,
},
width: chartContainerRef.current.clientWidth,
height: 500,
});
chart.timeScale().fitContent();
<!-- end snippet -->
答案1
得分: 1
该库只会为每个数据点在图表上添加一个点。所以如果数据不存在,它就不会被绘制。
例如:
-
如果你有数据点在:
9:00
,9:15
,9:30
,9:45
。
那么该库将绘制4
个点。 -
如果你在中间删除一个点:
9:00
,9:30
,9:45
。
那么该库只会绘制3
个点。在时间刻度上不会留下9:15
的间隙。
TLDR; 在将数据提供给库通过setData
之前,从数据中删除不想显示的点。
英文:
The library will only add a point on the chart for each data point. So if the data isn't there then it won't be plot.
For example:
-
If you had data points at:
9:00
,9:15
,9:30
,9:45
.
then the library would plot4
points. -
If you remove a point in the middle:
9:00
,9:30
,9:45
.
then the library would only plot3
points. There won't be a gap left on the time scale for9:15
.
TLDR; Remove the points you don't want to display from the data before providing it to the library via setData
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论