I am trying to dinamicaly build a graphic exactly like the one thats in the file that i’ve attached.
I can’t seem to define the background color of the ChartArea, and the text color , althow i have the textfont property and color defined, dosen’t apply to all the text.
I have looked into your exemples in demo pages, but i couldn’t find exactly what i need.
Can you give me an help in this?
Is it possible to programmaticaly define a chart as i need it?
Since you are applying custom colors to the series area or so, so you need to add those custom colors to the MS Excel standard color palette first. For your information, Ms Excel standard color palette has only 56 colors. The colors are indexed 0-55. Please check document topic: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/aspose.cells.workbook.changepalette.html
If a color is not present on the palette, we have to add it to the palette, so that we may use use.
Also, please see the document for reference: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/colors-and-palette.html
I have tested with the following sample code using your template excel file, it works fine.
Workbook workbook = new Workbook();
//Add the custom color to the palette for the first series.
color1= Color.FromArgb(79, 129, 189);
//Add the custom color to the palette for the second series.
color2= Color.FromArgb(192, 80, 77);
//Add the custom color to the palette for the third series.
color3= Color.FromArgb(155, 187, 89);
Worksheet sheet = workbook.Worksheets;
int chartIndex = sheet.Charts.Add(ChartType.ColumnStacked, 5, 1, 29, 10);
Chart chart = sheet.Charts[chartIndex];
//Add the nseries collection to a chart
//Get or set the range of category axis values
chart.NSeries.CategoryData = “C27:E27”;
for (int i = 0; i < chart.NSeries.Count; i++)
chart.NSeries[i].Name = sheet.Cells[27+i, 1].Value.ToString();
//Set the custom color for the first data series.
chart.NSeries.Area.ForegroundColor = color1;
//Set the custom color for the second data series.
chart.NSeries.Area.ForegroundColor = color2;
//Set the custom color for the third data series.
chart.NSeries.Area.ForegroundColor = color3;
chart.IsDataTableShown = true;
chart.IsLegendShown = false;