Is it possible to configure a serial chart from multiple layers?

1386
4
01-11-2022 03:24 AM
Abdullah_AlFazari
Occasional Contributor

Hi friends,

So this post contains two things:

1. I have a serial chart in a dashboard, and I filtered the layer to just shows 2 subtypes, but when I configure the equation, it is not able to include more than one subtype, as per the below screenshots:

Abdullah_AlFazari_0-1641899282872.png

Abdullah_AlFazari_1-1641899301718.png

2. Is it possible to configure a serial chart from multiple layers, I actually have two layers (one have a main line and the other have laterals (subtypes) of the line), and want to create a serial chart to see the lengths of all lines (main + laterals) in one serial chart. Is this doable?

 

@JayantaPoddar
@jcarlson
@JohannesLindner

@DavidNyenhuis1

 

 

0 Kudos
4 Replies
JohannesLindner
MVP Frequent Contributor

Disclaimer: This is the first time I'm looking at Dashboard Serial Charts, it's possible I'm overlooking things here.

1.) If "Include" doesn't work, try chaining together multiple "Equals" with "Or". So instead of

WHERE Field IN (Value1, Value2)

you get

Where Field = Value1 OR Field = Value2

 

2.) Doesn't seem doable. You probably have to create a new database view with all the lines, share it and build your chart from that.

 


Have a great day!
Johannes
Abdullah_AlFazari
Occasional Contributor

Hi @JohannesLindner 

Thank you very much for the prompt response. Much appreciated.

So in this case will try to publish another layer that combines all (main + laterals).

 

 

0 Kudos
jcarlson
MVP Esteemed Contributor

You can definitely do this with a Data Expression. They can look a bit more complex, but they're really just longer than most Arcade expressions. Take a look at the examples repository for a good starting point.

The text version:

  1. Grab each layer by its itemID.
  2. Create an empty "features" array
  3. Go through each feature in both layers and push the features into said array
  4. Turn array into a FeatureSet

The code:

var portal = Portal('your url')

var lines1 = FeatureSetByPortalItem(
    portal,
    'itemid',
    0, // or whatever layer index applies
    ['fields', 'you', 'need'],
    false // unless you really need the geometry, leave it out for performance reasons
)

var lines2 = FeatureSetByPortalItem(
    portal,
    'itemid',
    0,
    ['fields', 'you', 'need'],
    false
)

var lyrs = [lines1, lines2]

var features = []
var feat;

for (var lyr in lyrs){
    for (var l in lyrs[lyr]){
        feat = {
            attributes: {
                some_attribute: l.some_attribute,
                another: l.another,
                ...
            }
        }
        
        Push(features, feat)
    }
}

var fs_dict = {
    fields: [
        {name: 'some_attribute', type: 'esriFieldTypeString'},
        {name: 'another', type: 'esriFieldTypeInteger'},
        ...
    ],
    geometryType: '',
    features: features
}

return FeatureSet(Text(fs_dict))

Note that this expression assumes you've got the same fields in each layer. If all you want is the length, you probably only need "shape__length" anyway, but some other type or identifier may be useful.

- Josh Carlson
Kendall County GIS
Abdullah_AlFazari
Occasional Contributor

Hi @jcarlson 

Thank you very much for the great support. I tried the code you provided but seems I need to be more familiar with the Data Expression. Much appreciate your response.

0 Kudos