Add Indian Number System support

Add the option to shift the comma placement like this:

International System: 1,000,000
Indian System: 10,00,000

Please see the comma placements in the chart for reference.

1 Like

Hi there @Shardul_Rawat :wave:

Interesting thought, thanks for sharing!

I see that our devs came up with a custom solution for your case, but we’ll try to think about adding this option in the settings :slightly_smiling_face:

No solution yet?

1 Like

Hi there, @Travoozo_India :wave:

We haven’t considered this feature as an option in the settings yet, but here is the custom solution from the devs:

const waitForElements = (selector, root = document) => new Promise(res => {
    let i = 0;

    const check = () => {
        const components = root.querySelectorAll(selector);

        if (components.length) {
            res([...components]);
        } else if (i !== 50) {
            setTimeout(check, 100);
            i++;
        }
    };

    check();
});

waitForElements("[class*='animated-number__Content-sc']").then(numbers => {
    const callback = (mutationList) => {
        mutationList.forEach(({ type, addedNodes: [addedNode] }) => {
            if (type === 'childList') {
                const formatter = new Intl.NumberFormat("hi", { style: "decimal" });
                const newNumber = formatter.format(addedNode.textContent.replace(/\D/g, ""));
                addedNode.textContent = addedNode.textContent.replace(/\,|\./g, "").replace(/\d+/g, newNumber);
            }
        });
    };

    const observer = new MutationObserver(callback);
    numbers.forEach(number => {
      observer.observe(number, { childList: true });
    });
});

Please add this code to the Custom JS field on the Settings tab of your widget’s settings and let me know if it helped :slightly_smiling_face:

Hey, it doesn’t work.

1 Like

I’d like to note that the JS code doesn’t work in the configurator and preview mode, only on the page where your widget is installed or via Share Link.

If the code doesn’t work on your website, please send me a link to the page, where your widget is installed :folded_hands: