Using Dashboards I'm trying to create a serial chart that shows total count of features within each layer with the layer name on x-axis and count on y-axis. The individual layers come from the same hosted feature layer which is why the itemId is the same for each layer
// Access organization's ArcGIS Online URL
var portal = Portal("https.blank.maps.arcgis.com");
// Access each layer item as a feature set from the portal
var waterLine = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var sanLine = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var roads = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var waterPoly = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var sanPoly = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var other = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var building = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var bridge = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var boardwalk = FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false)
var totalCount = Count(waterLine) + Count(sanLine) + Count(roads) + Count(waterPoly) +
Count(sanPoly) + Count(other) + Count(building) + Count(bridge) + Count(boardwalk)
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}],
geometryType: '',
features: [{attributes: {total: totalCount}}],
};
//Return dictionary cast as a feature set
return FeatureSet(Text(Dict));
Any help would be much appreciated, I'm very new to Arcade.
Solved! Go to Solution.
I think you're very close!
Couple of things to check/try
var portalItem = Portal("https://blank.maps.arcgis.com");
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}}],
};
ght but might just have been from you swapping out your specific URL
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}}],
};
The Dict your building is based upon 9 layers, but these are all the same layers. Are 'building', 'bridge' etc sub layers in the 51dc078a4b35479fb975114ca4abf546 item or attributes in the 0 sub layer? If it's the latter, you may want to filter so you're getting counts of the individual categories, instead of the layer as a whole, for example
var building = Filter(FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false), "fieldName = 'building'");
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}, {total: totalCount, layername: "building"}}],
};
When you attempt to use this code, what kind of response do you get? I don't see any obvious errors in your code.
I think you're very close!
Couple of things to check/try
var portalItem = Portal("https://blank.maps.arcgis.com");
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}}],
};
ght but might just have been from you swapping out your specific URL
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}}],
};
The Dict your building is based upon 9 layers, but these are all the same layers. Are 'building', 'bridge' etc sub layers in the 51dc078a4b35479fb975114ca4abf546 item or attributes in the 0 sub layer? If it's the latter, you may want to filter so you're getting counts of the individual categories, instead of the layer as a whole, for example
var building = Filter(FeatureSetByPortalItem(portal, "51dc078a4b35479fb975114ca4abf546", 0, ["*"], false), "fieldName = 'building'");
var Dict = {
fields: [{name: 'total', type: 'esriFieldTypeInteger'}, {name: 'layername', type: 'esriFieldTypeString'}],
geometryType: '',
features: [{attributes: {total: totalCount, layername: "bridge"}, {total: totalCount, layername: "building"}}],
};