I have two separate hosted feature layers. One with indoor temp and the other with outdoor temp. I am using an expression to bring them together as a featureset, but it seems I am not able bring in my timestamp field. No matter what I try it will error. If I convert the date/time to text, it will work as the category field, but then it will only chart the time using Day as the "Minimum Period" after parsing the dates...it will not chart if I choose "Hour" as the "Minimum Period".
Is it possible to have a date/time as the category field to view hourly line charts of indoor and outdoor temp? Or do I have to convert the date to something else?
Solved! Go to Solution.
Try changing the timestamp field to esriFieldTypeDate and in your loop, use Number(l.last_value_update) when you assign the value. That should give you a date field you can use as the category.
This seems possible. Can you share you expression, or are the layers private?
Remember, timestamps need to be turned into numbers in your expression.
Number(feature['timestamp_field'])
@jcarlson Here is my expression. last_value_update is my date/time | timestamp field.
var portal = Portal('https://www.arcgis.com')
var sensorHistory = FeatureSetByPortalItem(
portal,
'xxx',
0, // or whatever layer index applies
['humidity', text('last_value_update'), 'serial_chart_layer_type'],
false // unless you really need the geometry, leave it out for performance reasons
)
var outdoorWeatherHistory = FeatureSetByPortalItem(
portal,
'xxx',
0,
['humidity', text('last_value_update'), 'serial_chart_layer_type'],
false
)
var lyrs = [sensorHistory, outdoorWeatherHistory]
var features = []
var feat;
for (var lyr in lyrs){
for (var l in lyrs[lyr]){
feat = {
attributes: {
humidity: l.humidity,
last_value_update: Text(l.last_value_update),
serial_chart_layer_type: l.serial_chart_layer_type,
}
}
Push(features, feat)
}
}
var fs_dict = {
fields: [
{name: 'humidity', type: 'esriFieldTypeDouble'},
{name: 'last_value_update', type: 'esriFieldTypeText'},
{name: 'serial_chart_layer_type', type: 'esriFieldTypeString'},
],
geometryType: '',
features: features
}
return FeatureSet(Text(fs_dict))
Try changing the timestamp field to esriFieldTypeDate and in your loop, use Number(l.last_value_update) when you assign the value. That should give you a date field you can use as the category.
@jcarlson Josh, I have a follow-up question. If I have a list and have a filter action based on a unique id for that feature to filter the grouped line chart, as of right now it would only draw one of the lines because the other line doesn't have unique id's. How would I go about or what would be the best approach to have both lines in this scenario? Basically, I want to always bring in the outdoor temp line, while also bring in the indoor temp line of the feature selected in the list...
The only way to really do this is to rework the data in the expression to bring the ID into the other line as well, which doesn't sound simple.
Is there some kind of shared attribute you wanted to filter both lines by?