Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

javascript - How to calculate a coefficient of irregular set of numbers

I have been years away from my math class. Now I would like to figure out the following.
I am writing a simple javascript program where some tabular data is output to PDF file.
The program will automatically decide if to output the data in portrait or landscape layout.

User will have the ability to choose size of the font.
Based on the size of the font and the number of characters in the widest tabular data row,
the program will calculate whether portrait of landscape layout to apply.

I checked how many characters can be output per line under a specific font.
Here is the result:

Font size Characters Ratio Ratio calc Notes
4 200 50.0 (200 / 4)
6 130 21.7 (130 / 6)
8 100 12.5 (100 / 8)
10 80 8.0 (80 / 10)
12 65 5.4 (65 / 12)
14 56 4.0 (56 / 14)
16 50 3.1 (50 / 16)
18 43 2.4 (43 / 18)
20 38 1.9 (38 / 20)
22 35 1.6 (35 / 22)
24 32 1.3 (32 / 24)
26 30 1.2 (30 / 26)
28 28 1.0 (28 / 28)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Thanks to @Raymond Chen here is the logic for his answer in which he turned my thinking 180 degrees around.

Font size Characters Product Product calc Notes
4 200 800.0 (4 x 200)
6 130 780.0 (6 x 130)
8 100 800.0 (8 x 100)
10 80 800.0 (10 x 80)
12 65 780.0 (12 x 65)
14 56 784.0 (14 x 56)
16 50 800.0 (16 x 50)
18 43 774.0 (18 x 43)
20 38 760.0 (20 x 38)
22 35 770.0 (22 x 35)
24 32 768.0 (24 x 32)
26 30 780.0 (26 x 30)
28 28 784.0 (28 x 28)
etc etc etc etc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...