如何在TradingView轻量级图表上移除非市场小时/时间?

huangapple go评论52阅读模式
英文:

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?

Screenshot

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: &quot;#fff000&quot;,
        visible: true,
        timeVisible: true,
        secondsVisible: true,
      },
      width: chartContainerRef.current.clientWidth,
      height: 500,
    });
    chart.timeScale().fitContent();

<!-- end snippet -->

答案1

得分: 1

该库只会为每个数据点在图表上添加一个点。所以如果数据不存在,它就不会被绘制。

例如:

  • 如果你有数据点在:9:009:159:309:45
    那么该库将绘制4个点。

  • 如果你在中间删除一个点:9:009:309: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 plot 4 points.

  • If you remove a point in the middle: 9:00, 9:30, 9:45.
    then the library would only plot 3 points. There won't be a gap left on the time scale for 9:15.

TLDR; Remove the points you don't want to display from the data before providing it to the library via setData.

huangapple
  • 本文由 发表于 2023年7月6日 11:49:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76625382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定