Hi KhaiTD,
1. How to change the background color of the chart image?
2. How can I set the Category Axis label?
Well, you have to change the background / fill color in the designer chart in the template file using Aspose.Cells APIs. Similarly you may set the category axis labels and other objects related chart in the workbook before taking image of the final chart (shaped chart).
For reference, please check the source code of our online featured chart demos (The demos solutions are automatically installed on the system using Aspose.Cells msi installer, so you may open the solutions into VS.NET and check the source codes):
Here I write a sample code for your reference, I create a chart from the scratch and set plot area background color, set category axis and other valus, specify different other chart objects too and finally take the image of the chart (attached):
Workbook workbook = new Workbook();
workbook.ChangePalette(Color.Orange,55);
//Set default font
Style style = workbook.DefaultStyle;
style.Font.Name = "Tahoma";
workbook.DefaultStyle = style;
Cells cells = workbook.Worksheets[0].Cells;
//Put a string into a cell
cells["A1"].PutValue("Region");
cells["A2"].PutValue("France");
cells["A3"].PutValue("Germany");
cells["A4"].PutValue("England");
cells["B1"].PutValue("Marketing Costs");
cells["B2"].PutValue(70000);
cells["B3"].PutValue(55000);
cells["B4"].PutValue(30000);
Worksheet sheet = workbook.Worksheets[0];
//Set the name of the worksheet
sheet.Name = "Clustered Column";
sheet.IsGridlinesVisible = false;
//Create chart
int chartIndex = sheet.Charts.Add(ChartType.Column, 5, 1, 29, 10);
Chart chart = sheet.Charts[chartIndex];
//Add the nseries collection to a chart
chart.NSeries.Add("B2:B4", true);
//Get or set the range of category axis values
chart.NSeries.CategoryData = "A2:A4";
chart.NSeries.IsColorVaried = true;
for ( int i = 0; i < chart.NSeries.Count ; i ++ )
{
chart.NSeries[i].DataLabels.IsValueShown = true;
chart.NSeries[i].Area.ForegroundColor = Color.Orange;
}
//chart.IsDataTableShown = true;
//Set properties of chart
chart.PlotArea.Area.ForegroundColor = Color.Coral;
chart.PlotArea.Area.FillFormat.SetTwoColorGradient(Color.Yellow,Color.White,GradientStyleType.Vertical,2);
chart.PlotArea.Border.IsVisible = false;
//Set the legend position type
chart.Legend.Position = LegendPositionType.Top;
chart.GapWidth = int.Parse("100");
chart.MajorGridLines.IsVisible = false;
//Set properties of chart title
chart.Title.Text = "Marketing Costs by Region";
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Color = Color.Black;
chart.Title.TextFont.Size = 12;
//Set properties of categoryaxis title
chart.CategoryAxis.Title.Text = "Region";
chart.CategoryAxis.Title.TextFont.Color = Color.Black;
chart.CategoryAxis.TickLabels.AutoScaleFont = true;
chart.CategoryAxis.TickLabels.Rotation = 40;
chart.CategoryAxis.TickLabels.Font.Size =7;
chart.CategoryAxis.Title.TextFont.IsBold = true;
chart.CategoryAxis.Title.TextFont.Size = 10;
//Set properties of valueaxis title
chart.ValueAxis.Title.Text = "In Thousands";
chart.ValueAxis.Title.TextFont.Name = "Arial";
chart.ValueAxis.Title.TextFont.Color = Color.Black;
chart.ValueAxis.Title.TextFont.IsBold = true;
chart.ValueAxis.Title.TextFont.Size = 10;
chart.ValueAxis.Title.Rotation = 90;
chart.ValueAxis.MajorUnit = double.Parse("20000");
chart.ValueAxis.MaxValue = double.Parse("80000");
chart.ValueAxis.MinorUnit = double.Parse("5000");
chart.ValueAxis.MinValue = double.Parse("0");
chart = workbook.Worksheets[0].Charts[0];
Bitmap bitmap = chart.ToImage();
bitmap.Save(@"d:\Testchrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//workbook.Save("d:\\test\\out1_colchart_1.xls");
Thank you.