0

Dynamic Print Layout Colour

Hi Guys, 

I have a print layout I created which pulls through a field called "percentage" is there a way to dynamically change the colour of this?

I've tried all sorts and nothing worked, last attempted was a formula which outputting HTML with a span inside and did inline styles but it didn't work

2 replies

null
    • Fred
    • 3 wk ago
    • Reported - view

    Here is the documentation for color in Carbone.

    Here is my example. Attached is the final output.

    Here is a sample of the JSON:

    {
      "leagueNum": 2,
      "league": "Major League Show Jumping",
      "season": 2024,
      "success": "#ffc505",
      "normal": "#000000",
      "mlsjGreen": "#C1F0C7",
      "events": {
        "e1is3K": [],
        "e2is3K": [
          true
        ],
        "e3is3K": [],
        "e4is3K": [
          true
        ],
        "e5is3K": [],
        "e6is3K": [
          true
        ],
        "e7is3K": [],
        "e8is3K": [],
        "e9is3K": [
          false
        ]
      },
      "teams": [
        {
          "teamName": "Roadrunners",
          "totals": 101,
          "standing": 1,
          "e1P": [
            5
          ],
          "e1Pl": [
            6
          ],
          "e1FR": [],
          "e1Is3K": [],

    To get the gold color numbers the code looks like:

    {d.teams[i].e1P}{d.teams[i].e1FR:ifNEM:show(..success):elseShow(..normal):color(p)}

    How to read Carbone code?

    The first { } tells Carbone which key I want to print (the key e1P).

    The second set of { } tells Carbone which key [e1FR] to check if it is empty [ifNEM] and if it is then use [show] the value from the success key (which sits one level (the two dots) up from teams). The success key has the hex value for a gold like color. Then at the end the color() function tells Carbone what to do with the color and here we tell it to change the paragraph.

    I also have other code that colors the background of the city names based on another key.

    If you haven't tried out Carbone Studio, then I would recommend you give it a try. I found it very helpful when testing out code because it allows you to run changes much faster then with in Ninox.

    Good luck and let us know how it goes.

      • Fred
      • 3 wk ago
      • Reported - view

      ooops, error in my writing:

      The second set of { } tells Carbone which key [e1FR] to check if it is not empty [ifNEM] and if it is then use [show] the value from the success key (which sits one level (the two dots) up from teams). The success key has the hex value for a gold like color. Then at the end the color() function tells Carbone what to do with the color and here we tell it to change the paragraph.