|
POST
|
Yes you would need to set layer.featureReduction.renderer. to incorporate the three field values, you can either use a UniqueValueRenderer (if all the values are categorical) OR write an Arcade expression to combine them into a composite score. Something like the example below. Note that since this is a cluster renderer the attributes in $feature come from featureReduction.fields NOT layer.fields. So you'll need to account for that. const clusterRenderer = new SimpleRenderer({
symbol: {
type: "simple-marker",
size: 8,
outline: {
width: 0.5,
color: "rgba(255,255,255,0.5)"
}
},
visualVariables: [{
type: "size",
field: "cluster_count",
minSize: 12,
maxSize: 60,
minDataValue: 1,
maxDataValue: 1000
}, {
type: "color",
valueExpression: `
// $feature gives you access to feature attributes.
var status = Decode($feature.status,
"U", 10,
"C", 5,
0
);
var alert = Number($feature.alert);
var priority = Decode($feature.priority,
"High", 10,
"Medium", 5,
"Low", 3,
0
);
var score = (status + alert + priority) / 3;
return score;
`,
stops: [
{ value: 0, color: "white" },
{ value: 3, color: "beige" },
{ value: 5, color: "yellow" },
{ value: 7, color: "orange" },
{ value: 10, color: "red" }
]
}]
});
layer.featureReduction.renderer = clusterRenderer; mposite score or level. for example...
... View more
02-01-2024
10:36 AM
|
0
|
0
|
1771
|
|
POST
|
I write about how you can do this in a few places. Basically, you can follow the pattern in this sample: https://developers.arcgis.com/javascript/latest/sample-code/visualization-update-data/ This is also described in this "Time styles" guide: https://developers.arcgis.com/javascript/latest/visualization/data-driven-styles/time/#attribute-animation Here are some blog posts that provide context and more examples: https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/six-ways-to-visualize-change-over-time-in-web-maps/ https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/animate-and-explore-covid-19-data-through-time/ https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/mapping-large-datasets-on-the-web/ If you get it working, I'd love to see how it turns out.
... View more
12-13-2023
09:11 AM
|
0
|
0
|
784
|
|
POST
|
I wrote a blog article about how to do this a few years ago. The live samples are using older versions of the API, but the pattern for coloring the bins should be the same. https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/make-your-histogram-legendary/
... View more
12-06-2023
02:52 PM
|
0
|
1
|
539
|
|
POST
|
fieldInfo.label doesn't take Arcade expressions. Arcade can only be defined in 2 places inside popups: expressionInfos, and ExpressionContent elements. To accomplish what you're attempting, you need an ExpressionContent element. This gives you full control over popup elements all within the scope of an Arcade expression. The expression itself needs to return the content type you want...in this case a chart. That chart's labels and values can be calculated using any Arcade function within the expression. Here's an example of the expression: var label = Text($feature.Field2);
var attributes = {
"Field 18 label": $feature.Field18
};
attributes[label] = $feature.Field25;
var fields = [];
for (var a in attributes){
Push(fields, a);
}
return {
type: "media",
attributes,
mediaInfos: [{
type: "piechart",
title: "Count by type",
value: {
fields
}
}]
}; And how you would reference it in your app: https://codepen.io/kekenes/pen/rNPqymw?editors=1000
... View more
11-30-2023
12:01 PM
|
1
|
1
|
1139
|
|
POST
|
Thanks for pointing this out. I can easily reproduce from your app. Can you contact Esri support and have them log an issue, so we can get this in our system to fix? That way you can also track the progress of the bug report.
... View more
11-27-2023
11:51 AM
|
0
|
1
|
751
|
|
POST
|
I would reach out to Esri support and show them the app where this is occurring. It appears to be originating in the rendering engine somewhere, but we won't know for sure until we see a live reproducible case. Once Support verifies it's an issue, it's submitted as a bug and the dev team will take a look at it.
... View more
11-27-2023
11:40 AM
|
0
|
1
|
643
|
|
POST
|
I suggest reaching out to Esri support if you suspect this is a bug. They will attempt to reproduce the issue independently then log a bug so the dev team can take a look at it.
... View more
11-27-2023
11:37 AM
|
0
|
0
|
551
|
|
POST
|
I'm not sure I follow the scenario 100%, but it sounds like you could just use the smart mapping functions for this: https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-renderers-type.html#createRenderer The smart mapping functions generate renderers based on the underlying data. The createRenderer function for unique values works for all "feature layer-like" types, including GeoJSON. Here's an example: https://codepen.io/kekenes/pen/wvNPGXJ?editors=100
... View more
11-15-2023
02:44 PM
|
0
|
1
|
954
|
|
POST
|
Not necessarily a performance benefit. Just an alternative that is fewer lines. I try to go with the shortest expression. Though I'd say the for loop version is more readable than the reduce approach.
... View more
11-06-2023
11:51 AM
|
0
|
0
|
3355
|
|
POST
|
@KenBuja is correct. You should use the Expects function for this case if using a for loop. The rendering engine for Online (JS API) is optimized for performance. So it only requests the data that's required by the layer's style by default. If you specify a field outside of an Arcade expression, the API knows to request data from that field for rendering. In the case of Arcade, the expression is evaluated for the fields required to make it work. When $feature.FIELDNAME is used, it's easy for the engine to figure out the required fields. That's why the alternative expression works. However, you can use Expects to directly tell the rendering engine which fields it should expect to request from the service. This can be a list of fields as Ken points out, or you can also define template strings like the following: Expects("*"); // requests all fields. Don't do this if you have a ton of attributes.
Expects("Year_*") // requests all fields that begin with "Year_". (e.g. "Year_2000", "Year_2010") would be requested, but "Y2004" wouldn't). On a side note, you could take advantage of the number function to condense the initial expression like this: Expects($feature,'*_20*');
var fieldList = ['Dorian_2019','Sally_2020','Ian_2022','Nicole_2022','Idalia_2023'];
var total = 0;
for (var f in fieldList) {
// adds 1 if "YES"
// adds 0 if not "YES"
total += Number($feature[fieldList[f]] == 'YES');
}
return total; Or use the reduce function to avoid a for loop altogether. You still need Expects for this to work... Expects($feature,'*_20*');
var fieldList = ['Dorian_2019','Sally_2020','Ian_2022','Nicole_2022','Idalia_2023'];
function add (total, fieldName){ total + Number($feature[fieldName] == 'YES') }
Reduce(fieldList, add, 0);
... View more
11-06-2023
09:05 AM
|
4
|
2
|
3373
|
|
IDEA
|
The UniqueValueInfo.description is intentionally left out of the documentation as it does not have a use in the current API. You should use the label property in stead of the description.
... View more
09-12-2023
08:31 AM
|
0
|
0
|
614
|
|
POST
|
> the still undocumented JSON structure for specifying it with uniqueValueGroups The JSON structure has actually been documented in the web map specification ever since the concept was introduced. You can find it here: https://developers.arcgis.com/web-map-specification/objects/uniqueValueRenderer/ https://developers.arcgis.com/web-map-specification/objects/uniqueValueGroup/ https://developers.arcgis.com/web-map-specification/objects/uniqueValueClass/ It includes examples with multiple scenarios. Perhaps we should improve the JS documentation to link to the web map specification.
... View more
08-31-2023
03:00 PM
|
0
|
1
|
1412
|
|
POST
|
I'm not observing this behavior. If you think you're encountering a bug, you should reach out to Esri support with a repro/test case so they can vet it and log it into our system to fix it more promptly. Here's the test case I tried that appeared to work: https://codepen.io/kekenes/pen/yLQMYPx?editors=100
... View more
06-27-2023
02:40 PM
|
1
|
0
|
550
|
|
POST
|
This sounds like a potential bug in the rendering engine. I advise reaching out to Esri Support so they can validate the issue and get it logged into our system.
... View more
06-23-2023
09:16 AM
|
0
|
0
|
2751
|
|
POST
|
It could be. I also don't think we save renderers directly to the service anymore (on the Online side anyway). It would be worth checking in with someone on the Pro/Enterprise side...
... View more
06-15-2023
11:55 AM
|
0
|
1
|
1720
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-06-2025 03:09 PM | |
| 1 | 04-29-2025 08:36 AM | |
| 1 | 08-20-2024 08:06 AM | |
| 1 | 08-13-2024 11:53 AM | |
| 1 | 07-22-2024 11:04 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-06-2025
03:01 PM
|