ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / KnowledgeGraphMappingExtensions Class / AppendToLinkChart Method
The link chart to append to.
The set of named object types and records.
Example

In This Topic
    AppendToLinkChart Method
    In This Topic
    Appends a set of named object types and their records to the link chart map. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Sub AppendToLinkChart( _
       ByVal linkChart As Map, _
       ByVal idSet As KnowledgeGraphLayerIDSet _
    ) 
    public static void AppendToLinkChart( 
       Map linkChart,
       KnowledgeGraphLayerIDSet idSet
    )

    Parameters

    linkChart
    The link chart to append to.
    idSet
    The set of named object types and records.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    idSet cannot be null.
    Map is not a link chart or does not contain a Knowledge Graph layer or an empty ID set is specified.
    idSet contains invalid Name Object types..
    Remarks
    You should use CanAppendToLinkChart prior to this method.
    Add an entry to the idSet for each Named Object type to be appended along with a list of their relevant record ids. Specify a null or empty list for a given entry to include 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
    Append to Link Chart
    {
      //We create an id set to contain the records to be appended
      var dict = new Dictionary<string, List<long>>();
      dict["Suspects"] = new List<long>();
    
      //In this case, via results from a query...
      var qry2 = "MATCH (s:Suspects) RETURN s";
    
      await QueuedTask.Run(async () =>
      {
        using (var kg_for_lc = kgLayer.GetDatastore())
        {
          var graphQuery = new KnowledgeGraphQueryFilter()
          {
            QueryText = qry2
          };
    
          using (var kg_rc = kg_for_lc.SubmitQuery(graphQuery))
          {
            while (await kg_rc.WaitForRowsAsync())
            {
              while (kg_rc.MoveNext())
              {
                using (var graphRow = kg_rc.Current)
                {
                  var obj_val = graphRow[0] as KnowledgeGraphNamedObjectValue;
                  var oid = (long)obj_val.GetObjectID();
                  dict["Suspects"].Add(oid);
                }
              }
            }
          }
    
          //make an ID Set to append to the LinkChart
          var idSet = KnowledgeGraphLayerIDSet.FromDictionary(kg_for_lc, dict);
          //Get the relevant link chart to which records will be
          //appended...in this case, from an open map pane in the
          //Pro application...
          var mapPanes = FrameworkApplication.Panes.OfType<IMapPane>().ToList();
          var mapPane = mapPanes.First(
            mp => mp.MapView.IsLinkChartView &&
            mp.MapView.Map.Name == "Acme Link Chart");
          var linkChartMap = mapPane.MapView.Map;
    
          //or get the link chart from an item in the catalog...etc.,etc.
          //var projectItem = Project.Current.GetItems<MapProjectItem>()
          //      .FirstOrDefault(pi => pi.Name == "Acme Link Chart");
          //var linkChartMap = projectItem?.GetMap();
    
          //Call AppendToLinkChart with the id set
          if (linkChartMap.CanAppendToLinkChart(idSet))
            linkChartMap.AppendToLinkChart(idSet);
        }
      });
    }
    Append to Link Chart from FFP Results
    {
      //using ArcGIS.Core.Data.Knowledge.Extensions;
    
      var linkChartView = MapView.Active;
    
      await QueuedTask.Run(async () =>
      {
        var ffp_config = new CIMFilteredFindPathsConfiguration();
        ffp_config.Name = "Append to Link Chart from FFP Results";
        //set up config
        //...
    
        var results = kg.RunFilteredFindPaths(ffp_config);
    
        var pathsEntitiesAndRelationships = results.ExtractPathsEntitiesAndRelationships(null);
    
        //Create a KG layer id set
        var kgLayerIdSet = KnowledgeGraphLayerIDSet.FromKnowledgeGraphIDSet(
          pathsEntitiesAndRelationships.ToKnowledgeGraphIDSet(
            KGResultContentFromFFP.EntitiesAndRelationships));
    
        var map = linkChartView.Map;
    
        if (!map.CanAppendToLinkChart(kgLayerIdSet))
          return;//not compatible
    
        map.AppendToLinkChart(kgLayerIdSet);
        //switch layout algo
        var algo = linkChartView.GetLinkChartLayout();
        if (algo != KnowledgeLinkChartLayoutAlgorithm.Hierarchical_TopToBottom)
        {
          //Change layout algo to match the default used by the UI after FFP
          await linkChartView.SetLinkChartLayoutAsync(
            KnowledgeLinkChartLayoutAlgorithm.Hierarchical_TopToBottom);
        }
    
        //To set link chart root nodes see 'Create Link Chart from FFP Results'
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.3 or higher.
    See Also