Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Comma instead of dot – javascript

  • Comma instead of dot – javascript

    Posted by Tiberiu Stefanescu on March 19, 2023 at 12:01 am

    Hello,

    I need to transform the “dot” in a “comma” in this expresion used in a Bar Graph.

    I’ve tried to put “.toLocaleString(‘de-DE’)” before and after this line – “.toFixed(textNumOfDecimals” but it doesn’t work – or i don’t do it correctly.

    If i change “.toFixed(textNumOfDecimals” to “.toLocaleString(‘de-DE’)” it works but i’ve lost decimals… so it doesn’t help me.

    Sorry for my english is not my first language, and thanks in advance for help!

    const textValue = thisComp.layer(“CONTROLS”).effect(“Text – Animated Value”)(1).value;

    const textNumOfDecimals = thisComp.layer(“CONTROLS”).effect(“Text – Number of Decimals”)(1).value;

    const textHigh = thisComp.layer(“CONTROLS”).effect(“Text – High Limit”)(1).value;

    const textLow = thisComp.layer(“CONTROLS”).effect(“Text – Low Limit”)(1).value;

    const textSize = thisComp.layer(“CONTROLS”).effect(“Text – Size”)(1).value;

    thisLayer.text.sourceText.style

    .setText(thisLayer.clamp(textValue, textLow, textHigh).toFixed(textNumOfDecimals) + “%”)

    .setFontSize(textSize)

    Brie Clayton replied 2 months, 2 weeks ago 3 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    March 20, 2023 at 1:38 pm

    Hi Tiberiu,

    try this:

    .setText((thisLayer.clamp(textValue, textLow, textHigh)/100).toLocaleString("de-DE", {style: "percent", minimumFractionDigits: textNumOfDecimals, maximumFractionDigits: textNumOfDecimals}))
  • Filip Vandueren

    March 20, 2023 at 4:12 pm

    BTW, the German convention is to use a space between the number and the %: “12,34 %”, if you don’t want that, nl_NL has the convention to not use a space: “12,34%”

  • Tiberiu Stefanescu

    March 22, 2023 at 8:17 am

    Thank you Filip!!
    It work very well. Also thanks for the nl_NL convention.

  • Tiberiu Stefanescu

    March 22, 2023 at 3:10 pm

    Help me with something else:

    Let’s say i want to get rid of “percent” and instead to fill with some text that i enter in another “guide layer” .

    Someting like this:

    const textValue = thisComp.layer(“CONTROLS”).effect(“Text – Animated Value”)(1).value;

    const textNumOfDecimals = thisComp.layer(“CONTROLS”).effect(“Text – Number of Decimals”)(1).value;

    const textHigh = thisComp.layer(“CONTROLS”).effect(“Text – High Limit”)(1).value;

    const textLow = thisComp.layer(“CONTROLS”).effect(“Text – Low Limit”)(1).value;

    const textSize = thisComp.layer(“CONTROLS”).effect(“Text – Size”)(1).value;

    thisLayer.text.sourceText.style

    .setText((thisLayer.clamp(textValue, textLow, textHigh)/100).toLocaleString(“nl-NL”, {style: “percent”, minimumFractionDigits: textNumOfDecimals, maximumFractionDigits: textNumOfDecimals}) + thisComp.layer(“Text”).text.sourceText)

    .setFontSize(textSize)

    P.S.: i really need an java/ae expression course…

    Thx!

  • Brie Clayton

    March 22, 2023 at 5:02 pm

    Filip Vandueren

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy