1

I want to set a width between vertical grid or time interval, in my case I wish to set it to 15 seconds per grid on lightweight chart.

I have gone through the documentation thoroughly and tried manipulating between barSpacing, minBarSpacing with

// Create the Main Series (Candlesticks)
const mainSeries = chart.addAreaSeries({
  topColor: "rgba(47, 150, 240, 0.56)",
  bottomColor: "rgba(47, 150, 240, 0.04)",
  lineColor: "#2f96f0",
  lineWidth: 3,
  crosshairMarkerVisible: false,
});
chart.timeScale().applyOptions({
  barSpacing: 5.5,
  minBarSpacing: 0.5,
});

I have also tried manipulating the setVisibleRange. With Data with time value of Every Second.

chart.timeScale().setVisibleRange({
  from: 1681961040,
  to: 1681961140,
});`

So with properly setting everything up right, I can get it to be in a 10 seconds interval with a reasonable width between each grid. Whenever I try to get anything more or less the width between vertical grid lines do not change. Is there any way to customly achieve this outside the lightweight chart settings available. Any assitance or point in the right direction will be appreciated.

Feshibaba
  • 89
  • 1
  • 6

1 Answers1

0

Currently it is not possible to control where the library decides to draw the vertical grid lines (and tick marks). The library determines where it thinks the grid lines should be drawn using a heuristic which prioritises certain times over others (for example timestamps on the hour are more important than timestamps for 3 minutes past the hour).

We are working on an update for the library which makes this behaviour customisable, but it isn't ready for release yet.

If this is needed now then you could create a fork of the library and modify the weighting of the TickMarks to suit your needs. You could start by looking here.

SlicedSilver
  • 381
  • 1
  • 4
  • Thank you so much for your answer. Especially the last paragraph you added. I am already on it. Could you also give me a hint on how to set my priorities (tickmark weight) to either 10 seconds, 15 seconds or at most 30 seconds interval per gridline. All my data are 1 second interval. – Feshibaba Apr 20 '23 at 14:33