{
// get active field, active field name
var activeFieldIdx = tableView.ActiveFieldIndex;
var fldDesc = tableView.GetField(activeFieldIdx);
var fldName = fldDesc.Name;
// set active field by name
tableView.SetActiveField("STATE_NAME");
// or set active field by index
tableView.SetActiveField(3);
}
{
// For more information on the chart CIM specification:
// https://github.com/Esri/cim-spec/blob/main/docs/v3/CIMCharts.md
var lyrDefHistogram = featureLayer.GetDefinition();
// Get list names for fields of type Double
var doubleFields = featureLayer.GetFieldDescriptions().Where(f => f.Type == FieldType.Double).Select(f => f.Name);
// Create list that will contain all histograms
var histograms = new List<CIMChart>();
// Create histogram for each Double field
foreach (var field in doubleFields)
{
// Define histogram CIM properties
var histogram = new CIMChart
{
Name = $"histogram_{field}",
GeneralProperties = new CIMChartGeneralProperties
{
Title = $"Histogram for {field}",
UseAutomaticTitle = false
},
Series =
[
new CIMChartHistogramSeries {
UniqueName = "histogramSeries",
Name = $"histogram_{field}",
BinCount = 15,
// Specify the number field
Fields = new string[] { field },
}
]
};
histograms.Add(histogram);
}
;
// Add new chart to layer's existing list of charts (if any exist)
var allChartsHistogram = (lyrDefHistogram == null) ? histograms : lyrDefHistogram.Charts.Concat(histograms);
// Add CIM chart to layer definition
lyrDefHistogram.Charts = allChartsHistogram.ToArray();
featureLayer.SetDefinition(lyrDefHistogram);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)