Is it possible to find a better/ modular way to assign the same color to paired rather than hard-coding them as I currently implement?
If objects fname
matches, then assign the same color.
The following is a subset of javascript objects.
data[0] = [{
"value": 29,
"series": 1,
"category": "Men",
"fname": "NY",
"valueColor": "red"
},
data[1] = [{
"value": 19,
"series": 4,
"category": "Women",
"fname": "NY",
"valueColor": "red"
},
data[2] = [{
"value": 9,
"series": 3,
"category": "LG",
"fname": "NY",
"valueColor": "red"
},
Here is the full implementation in FIDDLE
First I assume, all objects are different and assign a different color, then I will check if there are any paired objects, if yes, then assign the same color.
Therefore it would be nice to generate colorSpectrum
based on a number of objects in exists in datasets rather than assigning common colors such as red, green, yellow, etc.. because you cannot guess in advance how many different objects you would get. I might get around maybe 10 objects, maybe around 100 objects. Therefore, I am looking for a modular way to handle this difficulty.
Here is the colorSpectrum
method implementation in COLOR SPECTRUM FIDDLE