We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

(In .Net) Not able to assign color to aspose chart's property MarkerBackgroundColor and MarkerForegroundColor

Hi ,

I am trying to set the below propertie of aspose in .Net but unable to.

The seriesColor on the right hand side contains color in the format "{Color [A=255, R=230, G=0, B=40]}",However when the below two statement executes,the MarkerBackgroundColor and MarkerForegroundColor are not modified and always contain "{Color [A=0, R=0, G=0, B=0]}".

asposeChart.NSeries[asposeIndex].MarkerBackgroundColor = seriesColor;

asposeChart.NSeries[asposeIndex].MarkerForegroundColor = seriesColor;

Please advise.



Thanks for your inquiry.

Well, the colors you are applying for the markers might not present in the standard color palette (for MS Excel 97 - 2003 - xls files), so you need to either add those colors to the palette first before applying them to the markers or save the files as xlsx format.

(If you are using xls format)

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Defind custom colors.
Color color1, color2;
color1 = Color.FromArgb(230, 0, 40);
color2 = Color.FromArgb(0, 0, 128);
//Add to excel color palette.
workbook.ChangePalette(color1, 55);
workbook.ChangePalette(color2, 54);

chart.NSeries[1].MarkerForegroundColor = color1;
chart.NSeries[1].MarkerBackgroundColor = color2;

For complete reference, see the document: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/colors-and-palette.html

Thank you.