In my Add-In, I am able to create a table and make a chart from the data. I am unable to change the color of the line series. I modified my code from the sample found at
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic21212.html
I had to change several things to make it work with a standalone table.
The chart draws fine, and I am able to change the LineSymbolProperties.Style (e.g. dashed, solid), but changing the Color does not make any difference - it always plots with the default line series color, pale blue.
The entire function that I'm coding uses a MapTool, with which a user can define a line - points along that line are sampled from a raster (typically a DTM) and distance/raster values are added to the table. I ultimately want the line series on the plot to match the graphic line on the map.
private async static void MakeChart(Table table, string field1, string field2, CIMRGBColor lineColor)
{
string tableName = table.GetName();
var stTable = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().Where((l) => l.Name == tableName).FirstOrDefault() as StandaloneTable;
CIMStandaloneTable cimTableDefinition = null;
await QueuedTask.Run(() => {
cimTableDefinition = stTable.GetDefinition() as CIMStandaloneTable;
});
string[] fieldString = new string[] { "distance", field1 };
if (field2 != "")
{
fieldString = new string[] { "distance", field1, field2 };
}
var lineChart = new CIMChart
{
Name = "lineChart",
GeneralProperties = new CIMChartGeneralProperties
{
Title = $"Profile chart for {field1} ",
},
Series = new CIMChartSeries[]
{
new CIMChartLineSeries {
UniqueName = "lineChartSeries",
Name = field1,
Fields = new string[] { "distance" , field1,},
// Specify aggregation type
//FieldAggregation = new string[] { string.Empty, "SUM" },
// Specify custom time bin of 6 months
//TimeAggregationType = ChartTimeAggregationType.EqualIntervalsFromStartTime,
//TimeIntervalSize = 1.0,
//TimeIntervalUnits = esriTimeUnits.esriTimeUnitsDays,
// Define custom line color
ColorType = ChartColorType.CustomColor, //SingleColor makes no difference
LineSymbolProperties = new CIMChartLineSymbolProperties {
Style = ChartLineDashStyle.Solid, //can change this
Color = new CIMRGBColor { R = 0, G = 150, B = 20 }, //changing this does not have any effect - plots blue line regardless
}
},
}
};
// Add new chart to layer's existing list of charts (if any exist)
var newChartsLine = new CIMChart[] { lineChart };
// Add CIM chart to layer defintion
//vvar allChartsLine = (cimTableDefinition == null) ? newChartsLine : cimTableDefinition.Charts.Concat(newChartsLine); //value cannot be null error
cimTableDefinition.Charts = newChartsLine.ToArray();
stTable.SetDefinition(cimTableDefinition);
}