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

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

    Parameters

    linkChart
    The link chart to have its content updated.
    idSet
    The set of named object types and records.
    combinationMethod
    The combination method.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Map is not a link chart or does not contain a Knowledge Graph layer.
    Cannot clear link chart content.
    idSet contains invalid Name Object types..
    Remarks
    You should use CanSetLinkChartContent(Map,KnowledgeGraphLayerIDSet,IDSetCombinationMethod) prior to this method.
    Add an entry to the idSet for each Named Object type along with a list of their relevant record ids. if using a combinationMethod of IDSetCombinationMethod.Add or IDSetCombinationMethod.New you can specify a null or empty list for a given entry to add all the records for that particular type at the time of this operation.
    Note: Named Object names in an ID set entry are case-sensitive.
    If there are Named Object type names specified in the ID set that do not match a Named Object type name in the KnowledgeGraph then a KnowledgeGraphLayerException will be thrown. The exception will contain the list of invalid Named Object types.
    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