Vary Chart Colour By Value

Hey guys,

So, I know we've covered this, but I'm picking up on the thread started by @Koichi_Tsuji on Radial Gauges using QuickChart.

 

CONCATENATE("https://quickchart.io/chart?c={
  type:'radialGauge',
  data:{
    datasets:[{
       data:[",NUMBER([Percentage]*100),"],
       backgroundColor:'rgb(0, 100, 0)'
      }]
    },
  options:{
    trackColor: 'rgb(220, 220, 220)',
    centerPercentage: 80,
    roundedCorners: true,
    centerArea:{text:' ",	
    NUMBER([Percentage]*100),	"%25'}
    }
  }"
)

 

I have this inspired expression that handles the generation of charts in my app perfectly. What I'd like to do is have the RGB change based on the [Percentage] value. Is this possible in AppScript?
Searching around, it appears that people have achieved the same in java here, but I honestly haven't a clue how to translate it.

 

Would be grateful for any help.

Solved Solved
0 7 113
1 ACCEPTED SOLUTION

Found a solution that works. It's not pretty, but it functions as expected:

The IF statement should not be in-line with the rest of the expression, instead, the CONCATENATED expression needs to be wrapped in an IF statement.

 

IF([Total Score] > 50,
CONCATENATE("https://quickchart.io/chart?c={
  type:'radialGauge',
  data:{
    datasets:[{
       data:[",NUMBER([Percentage]*100),"],
       backgroundColor:'rgb(0, 100, 0)'
      }]
    },
  options:{
    trackColor: 'rgb(220, 220, 220)',
    centerPercentage: 80,
    roundedCorners: false,
    centerArea:{text:' ",	
    NUMBER([Percentage]*100),	"%25'}
    }
  }"
),
CONCATENATE("https://quickchart.io/chart?c={
  type:'radialGauge',
  data:{
    datasets:[{
       data:[",NUMBER([Percentage]*100),"],
       backgroundColor:'rgb(100, 0, 0)'
      }]
    },
  options:{
    trackColor: 'rgb(220, 220, 220)',
    centerPercentage: 80,
    roundedCorners: false,
    centerArea:{text:' ",	
    NUMBER([Percentage]*100),	"%25'}
    }
  }"
))

There must be a better way, but I don't know what it is.

This expression just checks to see what the [Percentage] is and displays a static image based on the result.

 

View solution in original post

7 REPLIES 7
Top Labels in this Space