{
// note that the template link chart MUST use the same KG server
await QueuedTask.Run(() =>
{
// find the existing link chart by name
var projectItem = Project.Current.GetItems<MapProjectItem>()
.FirstOrDefault(pi => pi.Name == "Acme Link Chart");
var linkChartMap = projectItem?.GetMap();
if (linkChartMap == null)
return;
//Create a connection properties
var kg_props2 =
new KnowledgeGraphConnectionProperties(new Uri(url));
try
{
//Open a connection
using (var kg_for_lc = new KnowledgeGraph(kg_props2))
{
//Add all entities to the link chart
var idSet = KnowledgeGraphLayerIDSet.FromKnowledgeGraph(
kg_for_lc, KnowledgeGraphFilterType.AllEntities);
//Create the new link chart and show it
var newLinkChart = MapFactory.Instance.CreateLinkChart(
"KG from Template", kg_for_lc, idSet, linkChartMap.URI);
FrameworkApplication.Panes.CreateMapPaneAsync(newLinkChart);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
});
}