I have 3 editable fields, each of which is related to a 4th, 5th and 6th field. The idea is that field 4,5,6 are the held quantities of fields 1,2,3. I want to base the layer style on the highest held quantity of whatever item.
Eg.
Feature 1: Style based on Grapes=60
Field 1: Oranges ------------ Field 4: 45
Field 2: Apples ------------- Field 5: 10
Field 3: Grapes ------------- Field 6: 60
Feature 2: Style based on Bananas = 80
Field 1: Apples ------------- Field 4: 15
Field 2: Bananas ------------- Field 5: 80
I've got the following code together which logically functions (finds and returns the appropriate pair of values), but I think I have an incorrect format being returned.
var fields = [
{ name: $feature.item1 , value: $feature.quantity1 },
{ name: $feature.item2 , value: $feature.quantity2 },
{ name: $feature.item3 , value: $feature.quantity3 },
];
function comparevalue(a,b){
if (a['value']>b['value'])
return -1;
if (a['value']<b['value'])
return 1;
return 0;
};
return First(Sort(fields,comparevalue))
The above code returns:
dictionary
name: Grapes
value: 60
but this is not usable to set a style apparrently.