Hi Antoine,
You will need to use ApplyFormat() instead, like following:
void DataPlot_SetColorByCol_ex()
{
//wks with 3 columns
int nXCol = 0, nYCol = 1, nCCol = 2;
Worksheet wks = Project.ActiveLayer();
DataRange dr;
dr.Add(wks, nXCol, "X");
dr.Add(wks, nYCol, "Y");
//make a line plot
GraphPage gp;
gp.Create("Origin");
GraphLayer gl = gp.Layers();
gl.AddPlot(dr, IDM_PLOT_LINE);
DataPlot dp = gl.DataPlots(0);
if( !dp )
return;
//set line color by theme
OQCOLOR oqColor;
okutil_get_ocolor_by_col(&oqColor, nCCol, nYCol, COLTYPE_COLOR_COLORMAP);
Tree trFormat;
trFormat.Root.Line.Color.nVal = oqColor;
int iRet = dp.UpdateThemeIDs(trFormat.Root, "Error", "Unknown tag");
bool bRet = dp.ApplyFormat(trFormat, true, true);
gl.Rescale();
}
We will check how to improve the document, so it will be easier to find out okutil_get_ocolor_by_col().