Select to view content in your preferred language

Arcade expression to set color of text in indicator widget

388
2
Jump to solution
06-29-2023 12:41 PM
dwold
by
Occasional Contributor III

Hello - I am trying to change the color of a value shown based on a range. For instance, numbers 4-5 red, 2-3.9 yellow, 0.1-1.9 green. My expression looks like this:

var color=When($datapoint.Score >=4, '#ff0000',$datapoint.Score >=2, 'ffff00',$datapoint.Score >=0, '#65a843','')

return {
  //textColor:'',
  //backgroundColor:'',
  topText: ' '+$datapoint.NAME+' Score',
  topTextColor: '#2c3648',
  topTextOutlineColor: '',
  topTextMaxSize: 'medium',
  middleText: $datapoint.Score,
  middleTextColor: 'color',
  middleTextOutlineColor: 'black',
  middleTextMaxSize: 'large',
  //bottomText: '',
  //bottomTextColor: '',
  //bottomTextOutlineColor: '',
  //bottomTextMaxSize: 'medium',
  //iconName:'',
  //iconAlign:'left',
  //iconColor:'',
  //iconOutlineColor:'',
  //noValue:false,
  //attributes: {
    // attribute1: '',
    // attribute2: ''
  // }
}
 
Any suggestions on what I am missing?
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Your middleTextColor is set to the string "color", because it is in quotes. Change it to color without quotes.

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Esteemed Contributor

Your middleTextColor is set to the string "color", because it is in quotes. Change it to color without quotes.

- Josh Carlson
Kendall County GIS
dwold
by
Occasional Contributor III

Awesome, thanks for the tip!

0 Kudos