I have C# code (pasted below) that creates a chart from a standalone table. This chart appears in the table of contents, with my specified chart title, as intended:
Then, when I open the chart to view it, the chart title reverts to a default value as if I'd created a chart from a table and did not specify a title.
I can open Chart Properties and it indicates the correct title:
Then, as soon as I click in the 'Chart title' text area, the chart updates with the correct title.
I would think that the chart title should appear as intended without having to perform these extra steps. Is this a bug? Is there another step my code has to perform?
Is it possible to open the chart programmatically? I don't see any obvious methods.
Thanks!!!
public async static void MakeChart(Table table, string field1, string field2, CIMRGBColor lineColor = null, string tableTitle = "")
{
try
{
string tableName = table.GetName();
var stTable = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().Where((l) => l.Name == tableName).FirstOrDefault() as StandaloneTable;
CIMStandaloneTable cimTableDefinition = null;
await QueuedTask.Run(() =>
{
tableName = table.GetName();
cimTableDefinition = stTable.GetDefinition() as CIMStandaloneTable;
});
if (lineColor == null) { lineColor = (CIMRGBColor)CIMColor.CreateRGBColor(237, 28, 36); };
if (tableTitle == "")
{
tableTitle = $"Profile chart for {field1} ";
}
var lineChart = new CIMChart
{
Name = "lineChart",
GeneralProperties = new CIMChartGeneralProperties
{
Title = tableTitle,
},
Series = new CIMChartSeries[]
{
new CIMChartLineSeries {
UniqueName = "lineChartSeries",
Name = field1,
//Fields = new string[] { "distance" , field1},
Fields = new string[] { field2 , field1},
ColorType = ChartColorType.SingleColor, //.CustomColor,
LineSymbolProperties = new CIMChartLineSymbolProperties {
Style = ChartLineDashStyle.Solid,
//Color = lineColor2, // new CIMRGBColor { R = 250, G = 150, B = 20 }, //changing this does not have any effect - plots blue line regardless
Width = 1,
},
MarkerSymbolProperties = new CIMChartMarkerSymbolProperties
{
Color = lineColor
}
},
}
};
lineChart.GeneralProperties.Title = tableTitle;
lineChart.GeneralProperties.ShowTitle = true; //this is the default setting
var newChartsLine = new CIMChart[] { lineChart };
// Add CIM chart to layer defintion
cimTableDefinition.Charts = newChartsLine.ToArray();
stTable.SetDefinition(cimTableDefinition);
}
catch (Exception ex)
{
ErrorLog(ex.ToString());
GC.Collect();
return;
}
}