{
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));
}
}
});
}