Hello,
I am working on an ArcGIS Online dashboard, and want to add color formatting to a column of text values. I've looked over all the settings tabs, but could not find any button or anything to do it simply. I've tried to put it into the code for the table, which at start looks like this:
Solved! Go to Solution.
Here's one way to do it. This uses a function to return the color, which can be used in multiple columns. This shows how it can be used to change the textColor and the backgroundColor attributes.
function setColor(value) {
When(
value < 20, "#dedede",
value < 30, "#C1C1C1",
value < 60, "#D18E8E",
"#f00000"
);
}
return {
cells:
{
//Other cells
"First Choice":
{
displayText: Text($datapoint["First Choice"]),
textColor: setColor($datapoint["First Choice"]),
//backgroundColor: setColor($datapoint["First Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
"Second Choice":
{
displayText: Text($datapoint["Second Choice"]),
textColor: "",
backgroundColor: setColor($datapoint["Second Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
// More cells
}
};
Here's one way to do it. This uses a function to return the color, which can be used in multiple columns. This shows how it can be used to change the textColor and the backgroundColor attributes.
function setColor(value) {
When(
value < 20, "#dedede",
value < 30, "#C1C1C1",
value < 60, "#D18E8E",
"#f00000"
);
}
return {
cells:
{
//Other cells
"First Choice":
{
displayText: Text($datapoint["First Choice"]),
textColor: setColor($datapoint["First Choice"]),
//backgroundColor: setColor($datapoint["First Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
"Second Choice":
{
displayText: Text($datapoint["Second Choice"]),
textColor: "",
backgroundColor: setColor($datapoint["Second Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
// More cells
}
};
Thank you! I actually used the solution you posted here which gave me the following code: