Y axis limit in JS Bar chart?

What is the y axis limit of js diagrams?

I used a 17-digit number and did not display anything on this chart.

+1
source share
1 answer

There are no restrictions on the y axis (with the possible exception of javascript restrictions for the type of number)

However, what you might see may be a LOSS of accuracy higher than 9007199254740992, which did not match the 17-digit number (see What is the maximum JavaScript integer value that Number can go without loss of accuracy? And related problems

Chart.js uses a range of values ​​to figure out how to scale bars. He does this by subtracting min from max and using the difference.

, , Chart.js (0.5), .

, 0.5 - , 9007199254740992, , 0 Chart.js y.

, 9007199254740992, ( → → 0.5 → )

/

// works because there is a (small) difference and the numbers are < 9007199254740992
var a = [9007199254740991, 9007199254740992];

// won't work because there is no difference and the numbers are > 9007199254740992 - 0.5
var b = [9007199254740992, 9007199254740992];

// won't work because there is no difference and the numbers are = 9007199254740992 - 0.5
var c = [9007199254740991.5, 9007199254740991.5];

// works because there is no difference and the numbers are < 9007199254740992 - 0.5
var d = [9007199254740991.4, 9007199254740991.4];

// works because there is a significant difference even though the numbers are > 9007199254740992
var e = [12345678901234567890, 12345678901434567891];

// works because there is a significant difference even though the numbers are > 9007199254740992
var f = [0, 12345678901434567891];

// won't work because there is only a small difference and the numbers are > 9007199254740992
var g = [9007199254740992, 9007199254740993];

, , , ( ) 9007199254740992 - 0,5 .

0, (, , 0 ), , - 17- , , , 1701 1705... 1 5, 170 .

0

Source: https://habr.com/ru/post/1619005/


All Articles