I know there are some similar questions, but non of them could not help me with my issue:
I have an Object:
var mapOptions = {
legend: {
data:[
{name: 'Europe', backgroundColor: 'RGB(228,101,41)'},
{name: 'APAC', backgroundColor: 'RGB(0,71,126)'},
{name: 'MENEAT', backgroundColor: 'RGB(145,0,73)'}
],
}
}
This object should be updated by this object:
var newOptions = {
legend: {
data: [
{name: 'Europe', backgroundColor: 'green'},
]
}
}
What should the update function be able to do:
Update attributes: From
'RGB(228,101,41)'to'green'Delete do not needed items: E.g. Only
'Europe'item should remain.
For now I use the jQuery extend/deep function:
$.extend(true, mapOptions, newOptions);
It works partly. Only the Attributes are updated.
Can anybody help me to achieve the second point, how to delete/add items?
Or should I split it in 2 functions better?
Thank you for any help!
Update attributes: From 'RGB(228,101,41)' to 'green'not all RGB values have english names. What do you want to do in that case?mapOptions.legend.data = newOptions.legend.datanewOptions.data. Other Items should be deleted