Thank you both for the response! I created a js called ChartColorMapping. This is the query:
const reasons = Distinct_Reasons.data.map(item => item.reason.trim()); // Trim whitespace from the reason values
const colorMap = {
"Blank": "#0892D0",
"Accidental Alert": "#010F0C",
"Accidental button press": "#010F0C",
"Accidental Button Press": "#010F0C",
"Drill Alert": "#D9D9D9",
"Duplicate": "#777777",
"Duplicate Alert": "#777777",
"Duplicate event": "#777777",
"Duplicate Event": "#777777",
"Duress / handled by security": "#335AF1",
"Duress Incident": "#335AF1",
"Duress incident / handled by security": "#335AF1",
"Duress incident/handled by security": "#335AF1",
"Duress incident/Handled by Security": "#335AF1",
"Duress Incident/Handled by security": "#335AF1",
"Duress Incident/Handled by Security": "#335AF1",
"Duress Incident/ Handled By Security": "#335AF1",
"Duress Incident/Handled By Security": "#335AF1",
"Duress Incident/Handled before arrival": "#A8F4FF",
"Duress incident / resolved before arrival": "#A8F4FF",
"Duress incident/resolved before arrival": "#A8F4FF",
"Duress incident/Resolved before arrival": "#A8F4FF",
"Duress Incident/Resolved before arrival": "#A8F4FF",
"Duress Incident/Resolved Before Arrival": "#A8F4FF",
"Duress Incident Resolved Before Arrival (Physical Violence and Agression)": "#A8F4FF",
"Duress Incident Resolved Before Arrival (Verbal Violence and Agression)": "#A8F4FF",
"Duress / resolved before arrival": "#A8F4FF",
"Emergency": "#00DAFF",
"Intentional test": "#D9D9D9",
"Intentional Test": "#D9D9D9",
"Intentional Test ": "#D9D9D9",
"Non-Duress Incident": "#BFDBFE",
"Non-duress situation": "#BFDBFE",
"Non-duress Situation": "#BFDBFE",
"Non Duress Situation": "#BFDBFE",
"Non-Duress Situation": "#BFDBFE",
"Other Activity": "#70AFFF",
"Other Criminal Activity": "#70AFFF",
"Other reason": "#70AFFF",
"Other Reason": "#70AFFF",
"Other Reason . . . ": "#70AFFF",
"Patient Assist": "#98AFC7",
"Physical Violence and Aggression": "#0095FD",
"Physical Violence and Aggression - Patient": "#B3EBF2",
"Safety β Facility Management": "#0E98BA",
"Security Assist": "#6495ED",
"Test": "#D9D9D9",
"Test Alert": "#D9D9D9",
"Test Alert ": "#D9D9D9",
"TESTING": "#D9D9D9",
"Verbal Violence and Aggression": "#1E90FF",
"Verbal Violence and Aggression - Patient": "#82CAFF",
};
const colorArray = reasons.map(reason => {
const trimmedReason = reason.trim();
const color = colorMap[trimmedReason];
console.log(Reason: "${trimmedReason}", Color: "${color}"
);
return color || "#CCCCCC";
});
console.log('Color Array:', colorArray);
return colorArray;
The chart still does not seem to be showing the correct color values. I also tried a variable and that didn't work either.