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

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

    Parameters

    linkChart
    The link chart to append to.
    idSet
    The set of named object types and records.

    Return Value

    True if the records can be appended. 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 AppendToLinkChart. An ID set can only be appended if the map is of type MapType.LinkChart, a Knowledge Graph layer already exists and the ID set is not null or empty and does not contain any invalid Named Object types.
    Note: Named Object names in a KnowledgeGraphLayerLinkChartIDSet are case-sensitive.
    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