ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / KnowledgeGraphMappingExtensions Class / CanSetLinkChartContent(Map,KnowledgeGraphLayerIDSet,IDSetCombinationMethod) Method
The link chart to have its content updated.
The set of named object types and records.
The combination method.
Example

In This Topic
    CanSetLinkChartContent(Map,KnowledgeGraphLayerIDSet,IDSetCombinationMethod) Method
    In This Topic
    Determines if the set of named object types and their records can be applied to the link chart map using the specified IDSetCombinationMethod. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Function CanSetLinkChartContent( _
       ByVal linkChart As Map, _
       ByVal idSet As KnowledgeGraphLayerIDSet, _
       ByVal combinationMethod As IDSetCombinationMethod _
    ) As Boolean

    Parameters

    linkChart
    The link chart to have its content updated.
    idSet
    The set of named object types and records.
    combinationMethod
    The combination method.

    Return Value

    True if the records can be applied to the link chart. False otherwise.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    You should use this method before calling SetLinkChartContent. An ID set can only be applied if the map is of type MapType.LinkChart, a Knowledge Graph layer already exists and the ID set does not contain any invalid Named Object types.
    Note: Named Object names in a KnowledgeGraphLayerLinkChartIDSet are case-sensitive.
    Example
    Set only the Selected Features as the Link Chart content
    {
      if (!MapView.Active?.Map?.IsLinkChart == true)
        return;
    
      await QueuedTask.Run(() =>
      {
        var map = MapView.Active.Map;
        var sel_set = map.GetSelection();
        if (sel_set.Count > 0)
        {
          var kg_layer_id_set = KnowledgeGraphLayerIDSet.FromSelectionSet(sel_set);
          //IDSetCombinationMethod can be New, Add, or Subtract
          if (map.CanSetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.New))
          {
            map.SetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.New);
          }
        }
      });
    }
    Append a set of records to a link chart
    {
      if (!MapView.Active?.Map?.IsLinkChart == true)
        return;
    
      //Assume we have a set of features in an entity type 'Species' and an entity
      //type 'Observation' that we want to append to an existing link chart...
      //Create a dictionary containing the entity uids to be added...
      var dict = new Dictionary<string, List<object>>();
      dict["Species"] = new List<object>();
      dict["Observation"] = new List<object>();
    
      dict["Species"].Add("{4478D960-A4D6-4930-A151-51A2C6140509}");
      dict["Species"].Add("{97E011A0-C140-4EA9-84E6-19413F6FCEE3}");
      dict["Observation"].Add("{18E1DB21-9F61-4CBE-A488-71AC8B24B605}");
      dict["Observation"].Add("{E378F1B1-FF5E-4EDD-808A-1C395A4857AD}");
    
      await QueuedTask.Run(() =>
      {
        var map = MapView.Active.Map;
    
        //Get the knowledge graph layer from the link chart
        var kg_layer = MapView.Active?.Map?.GetLayersAsFlattenedList()?
                                  .OfType<ArcGIS.Desktop.Mapping.KnowledgeGraphLayer>()?
                                  .First();
    
        //arbitrarily get the first feature layer that is a child of the kg layer
        var fl = kg_layer?.GetLayersAsFlattenedList()?
                    .OfType<FeatureLayer>()?.First();
    
        //Get the kg from the kg layer
        using (var kg = kg_layer.GetDatastore())
        {
    
          //Create a kg layer id set
          var id_set = KnowledgeGraphIDSet.FromDictionary(kg, dict);
          var kg_layer_id_set = KnowledgeGraphLayerIDSet.FromKnowledgeGraphIDSet(id_set);
    
          //set the content of the link chart using the id set and the Add combination method
          if (map.CanSetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.Add))
          {
            map.SetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.Add);
            //Set the newly added records selected...
            map.SetSelection(SelectionSet.FromKnowledgeGraphLayerIDSet(map, kg_layer_id_set));
          }
        }
      });
    }
    Remove the selected features from the link chart's content
    {
      if (!MapView.Active?.Map?.IsLinkChart == true)
        return;
    
      await QueuedTask.Run(() =>
      {
        var map = MapView.Active.Map;
        var sel_set = map.GetSelection();
        if (sel_set.Count > 0)
        {
          var kg_layer_id_set = KnowledgeGraphLayerIDSet.FromSelectionSet(sel_set);
          //IDSetCombinationMethod can be New, Add, or Subtract
          if (map.CanSetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.Subtract))
          {
            map.SetLinkChartContent(kg_layer_id_set, IDSetCombinationMethod.Subtract);
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.7 or higher.
    See Also