Sharath
Posts: 49
Joined: Wed Dec 14, 2022 7:37 am

Usage of GapSize in stock chart

What is the usage of GapSize in stock chart?

For example what does this property gapSize:5 define when used in the stock chart? Also on what basis we decide the values for gapSize property?

I need a simple/understandable explanation please do not provide me the links of the gapSize property highchart documentation.

Regards,
Sharath MM
kamil
Posts: 93
Joined: Mon Mar 04, 2024 8:26 pm

Re: Usage of GapSize in stock chart

Hi there!
Thank you for contacting us.
I understand that gapSize property can be a little confusing. I've prepared a couple of demos to help you understand it.

gapSize property depends on gapUnit property which accepts 2 values only: 'relative' and 'value'.

But firstly, let's look at the chart without a gapSize and gapUnit: https://jsfiddle.net/BlackLabel/x4jqu8fk/

Now, let's check out a chart with gapUnit set to 'value' and gapSize set to amount of milliseconds in one day: https://jsfiddle.net/BlackLabel/joefysg4/
That configurartion says: if a distance between 2 subsequent points in a series is larger than one day, then create a gap there.

Here's a chart with gapUnit set to 'value' and gapSize set to amount of milliseconds in three days: https://jsfiddle.net/BlackLabel/48w3txoy/
That configurartion says: if a distance between 2 subsequent points in a series is larger than three days, then create a gap there. As we can see, there's no gap in the chart. That's because there are no 2 subsequent points in the chart that have at least 3 days span between each other.

Now, let's look at 2 charts which as gapUnit set to 'relative' (default value of that property).

Here's a chart with gapUnit set to 'relative' and gapSize set to 1.5: https://jsfiddle.net/BlackLabel/4520Lg6b/

To understand this example we need to find the smallest distance between 2 subsequent points in the series.
The distance between the first and second point is one day. The distance between the second and the third point is 2 days. The distance between the third and fourth point is one day. So the smallest distance between 2 subsequent points in this series is one day.

gapSize set to 1.5 tells that the gap should appear where the distance between two points is larger that 1.5 multiplied by the value that we found in the previous paragraph.

If we increase the gapSize to 3, there will be no gap at all: https://jsfiddle.net/BlackLabel/48w3txoy/

Please let me know if you have any further questions.
Best regards!
Kamil Kulig
Highcharts Developer

Return to “Highcharts Stock”