srexi / purecounterjs

A simple yet configurable native javascript counter which you can count on.
MIT License
122 stars 48 forks source link

Setting decimals to zero still shows a decimal point and digit #34

Open ModernHooman opened 2 years ago

ModernHooman commented 2 years ago

An strange behavior here is when you set currency symbol which I prefer to use a + sign and setting 0 for decimals, still you see a decimal point and a digit after it. Even in the documentation it's clearly obvious that it prints the result like $9.0k.

What I'm wondering is that, is it zero decimals mean a digit after decimal point?

rzlnhd commented 2 years ago

@hooman-limouee Ah yes, maybe the problem is on this line. https://github.com/srexi/purecounterjs/blob/a6d97cf7b12fdd2e45ec71902d41a63b9ad34b6d/js/purecounter.js#L235 setting the decimals to 0 will not possible because of this line. I'll find another way to fix this issue... thanks for your report.

srexi commented 2 years ago

An strange behavior here is when you set currency symbol which I prefer to use a + sign and setting 0 for decimals, still you see a decimal point and a digit after it. Even in the documentation it's clearly obvious that it prints the result like $9.0k.

What I'm wondering is that, is it zero decimals mean a digit after decimal point?

Can you please show me how you're setting the decimal to 0?

rzlnhd commented 2 years ago

@srexi the decimals will never possible to set to 0 on filesizing or currency for now, but it will be normal other than that.

edit: jsfiddle test

rasselmrh commented 2 years ago

I'm looking for setting up floating point number a counter value, such as 0.84 . , 10.34 without any currency or file size . Is there any option ? I couldn't find anything.

rzlnhd commented 2 years ago

@rasselmrh You can just intialize specific new PureCouter() with specific classId, and just add start and end value for your counter. Then set decimals to 2 (because you want 2 number behind the comma). Here!

Or, you can set the value on data-purecounter-start, data-purecounter-end attribute of your element, and set data-purecounter-decimals to 2. Here!

For decimals or float value, use period/dots . instead of comma ,.

enetc commented 2 years ago

using purecounter_vanilla.js. I have a weird issue when using value 999.9999 below it will output 999999 missing the point but when using a thousand(8200.2055.) value with decimal works fine but output will be 8200.2055

Chungmire commented 4 months ago

Custom initialization doesn't help. For example, I'm using the number "90.5" but it just displays as "905" with 1 decimal and as "91" with 0.