ArcGIS Pro 3.3 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 static void AppendToLinkChart( 
       Map linkChart,
       KnowledgeGraphLayerIDSet idSet
    )
    Public Shared Sub AppendToLinkChart( _
       ByVal linkChart As Map, _
       ByVal idSet As KnowledgeGraphLayerIDSet _
    ) 

    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 appeneded 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 when the layer is created. 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";
    
    QueuedTask.Run(async () =>
    {
      using (var kg = kg_layer.GetDatastore())
      {
        var graphQuery = new KnowledgeGraphQueryFilter()
        {
          QueryText = qry2
        };
    
        using (var kgRowCursor = kg.SubmitQuery(graphQuery))
        {
          while (await kgRowCursor.WaitForRowsAsync())
          {
            while (kgRowCursor.MoveNext())
            {
              using (var graphRow = kgRowCursor.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, 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);
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also