Okay
  Public Ticket #242448
Counter Rounding Decimals
Closed

Comments

  • Gibson started the conversation

    Hey Team, 

    The theme is great. 

    I am using the big counter, and I am hoping to allow it to use decimals for one of the entries. Right now it is rounding 3.55 to 4.

    Is there a way to do this?

  •  1,973
    Support replied

    Hi there,

    which counters radial (circle) or normal counters?

    Thanks

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Gibson replied

    It is the normal, big counter.

  •  1,973
    Support replied

    Try setting

    step=0.1

    where the counter is initialized

    /js/scripts.js , line 216

    https://github.com/aterrien/jQuery-Knob

    for a list of options

    Thanks

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Gibson replied

    Alas, I can't seem to figure it out. I tried to add "size: 0.1" after line 216 (so I suppose I made it line 217), and then uploaded the file to my server, but no change. I am using the big normal counters, so it seems wrong to add the code to the section labeled "Radial Counter." More likely than not, I'm just doing something wrong.

  •  1,973
    Support replied

    In /js/scripts.js look for

    // Radial Counters

    jQuery(".knob").knob({

    width: 140,

    height: 140,

    fgColor: '#222',

    inputColor: '#999',

    dynamicDraw: true,

    thickness: 0.15,

    tickColorizeValues: true,

    skin:'tron',

    readOnly:true,

    });

    and add 

    step=0.1 so it will look like

    // Radial Counters

    jQuery(".knob").knob({

    width: 140,

    height: 140,

    fgColor: '#222',

    inputColor: '#999',

    dynamicDraw: true,

    thickness: 0.15,

    tickColorizeValues: true,

    skin:'tron',

    readOnly:true,

    step: 0.1,

    });

    So step not size

    And make sure you refresh the page to avoid any cached content.

    Thanks

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  •   Gibson replied privately
  • Gibson replied

    Looks like my previous comment didn't reopen the ticket. Hope you can help. 

  •  1,973
    Support replied

    Hi, I get an empty page... (?)

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Gibson replied

    In the upper left corner, there should be an asterisk. If you click on it and enter 123456, you should be able to access the full site.

  •  1,973
    Support replied

    One last step is to replace this line

    $this.val(Math.ceil(this.value)).trigger('change');

    with

    $this.val(this.value).trigger('change');

    line 234

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Gibson replied

    Hmmm. Still not working. What's weird to me is that Math.ceil is supposed to round the decimals up regardless of their value. Right now, the entered value is 3.45, but it is rounding down to 3. When I bump it up to 3.55 it rounds up to 4.

    The changes that I have currently made are step:0.1 and deleting Math.ceil.

    Is there anything else? I looked up Math.round, and it seemed that this site had something that would help, but when I tried it, it didn't do anything (https://developer.mozilla.org/en-US/docs/Web/JavaS...

    Thank you for all of your help! I'm learning quite a bit about javascript.

  •  1,973
    Support replied

    Hi, I tested it with a brand new page (just inserted the radial counter shortcode) not exactly sure what goes wrong. can you make the same test?

    Thanks

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Gibson replied

    When I use the radial counter shortcode with the number 3.45, I get a radial counter with 3.400000000, when I try 3.459, I get 3.5. But the counters that I am using, the big, normal counters, still don't work.

  •  1,973
    Support replied

    Yes, it's related with the step.

    Regarding the big counters, it's a bit unclear for me why they wouldn't work.

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy