CanSetLinkChartContent(Map,KnowledgeGraphLayerIDSet,IDSetCombinationMethod) Method
In This Topic
Determines if the set of named object types and their records can be applied to the link chart map using the specified
IDSetCombinationMethod. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Parameters
- linkChart
- The link chart to have its content updated.
- idSet
- The set of named object types and records.
- combinationMethod
- The combination method.
Return Value
True if the records can be applied to the link chart. False otherwise.
Exceptions
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