I am looking to develop a function that maps different items to specific color thresholds. Here is an example of what I have in mind:
export const mapMetricsToValue: any = {
item1: {
0: 'green--text',
0.3: 'red--text',
0.45: 'orange--text',
},
item2:{
0: 'yellow--text',
0.5: 'blue--text',
0.65: 'purple--text',
}
};
export function getTextClass(metric: string, value: Number): string {
return mapMetricsToValue(metric,value);
}
The concept here is to have different items (like item1, item2, etc.) each with their own thresholds for color assignment. For instance, for item1:
-if (0<item1<0.3) it should return green,
-if(0.3<item1<0.45) it should return red,
-else it should return orange
Similarly, item2 would have a different set of thresholds and colors. The goal is to have a function (getTextClass) that returns the appropriate color based on the item and its threshold.
I would appreciate any assistance with this. Thank you!