Hey ,
i have this code and i want to set the X and Y of PlotArea to be as that of ChartArea ,Also i want my chart Plotarea to start from the begining of the column .
the code is :
PresentationEx pres = new PresentationEx();
SlideEx sld = pres.Slides[0];
Workbook wk = new Workbook();
Worksheet sheet = wk.Worksheets[wk.Worksheets.Add()];
sheet.Name = “MyChart”;
sheet.IsGridlinesVisible = false;
int chartIndex = sheet.Charts.Add(ChartType.BarStacked, 1,2,18, 3);
Chart chart = sheet.Charts[chartIndex];
chart.ChartArea.Area.FillFormat.Type = Aspose.Cells.Drawing.FillType.None;
sheet.Cells[0, 0].PutValue(“Brands”);
Aspose.Cells.Cell chartRange = sheet.Cells[0,0];
Style style = sheet.Cells[“A1”].GetStyle();
style.ForegroundColor = Color.Gray;
style.Pattern = BackgroundType.Solid ;
sheet.Cells[“A1”].SetStyle(style);
Style style2 = sheet.Cells[“B1”].GetStyle();
style.ForegroundColor = Color.Gray;
style.Pattern = BackgroundType.Solid;
sheet.Cells[“B1”].SetStyle(style);
Style style3 = sheet.Cells[“C1”].GetStyle();
style.ForegroundColor = Color.Gray;
style.Pattern = BackgroundType.Solid;
sheet.Cells[“C1”].SetStyle(style);
//sheet.Cells.Columns[0].Style.ForegroundColor = System.Drawing.Color.FromArgb(192, 192, 192);
//sheet.Cells.Columns[0].Style.Pattern = BackgroundType.Solid;
sheet.Cells[1, 0].PutValue(“1) Mobil”);
sheet.Cells[2, 0].PutValue(“2) Shell”);
sheet.Cells[3, 0].PutValue(“3) Castrol”);
sheet.Cells[4, 0].PutValue(“4) Lukoil”);
sheet.Cells[5, 0].PutValue(“5) Esso”);
sheet.Cells[6, 0].PutValue(“6) TNK”);
sheet.Cells[7, 0].PutValue(“7) BP”);
sheet.Cells[8, 0].PutValue(“8) Zic”);
sheet.Cells[9, 0].PutValue(“9) Luxoil”);
sheet.Cells[10, 0].PutValue(“10) Total”);
sheet.Cells[11, 0].PutValue(“11) Mannol”);
sheet.Cells[12, 0].PutValue(“12) Texaco”);
sheet.Cells[13, 0].PutValue(“13) Elf”);
sheet.Cells[14, 0].PutValue(“14) Yukos”);
//sheet.Cells[0, 1].PutValue(“BES”);
//sheet.Cells[1, 1].PutValue(15.7);
//sheet.Cells[2, 1].PutValue(14.5);
//sheet.Cells[3, 1].PutValue(11.8);
//sheet.Cells[4, 1].PutValue(10.1);
//sheet.Cells[5, 1].PutValue(8.3);
//sheet.Cells[6, 1].PutValue(6.7);
//sheet.Cells[7, 1].PutValue(5.7);
//sheet.Cells[8, 1].PutValue(4.4);
//sheet.Cells[9, 1].PutValue(4.4);
//sheet.Cells[10, 1].PutValue(4.4);
//sheet.Cells[11, 1].PutValue(4.0);
//sheet.Cells[12, 1].PutValue(3.7);
//sheet.Cells[13, 1].PutValue(3.4);
//sheet.Cells[14, 1].PutValue(3.0);
//sheet.Cells[0, 10].PutValue(“HighBep”);
//sheet.Cells[1, 10].PutValue(2);
//sheet.Cells[2, 10].PutValue(5);
//sheet.Cells[3, 10].PutValue(6);
//sheet.Cells[4, 10].PutValue(7);
//sheet.Cells[5, 10].PutValue(5);
//sheet.Cells[6, 10].PutValue(2);
//sheet.Cells[7, 10].PutValue(3);
//sheet.Cells[8, 10].PutValue(1);
//sheet.Cells[9, 10].PutValue(3);
//sheet.Cells[10, 10].PutValue(3);
//sheet.Cells[11, 10].PutValue(1);
//sheet.Cells[12, 10].PutValue(0);
//sheet.Cells[13, 10].PutValue(3);
//sheet.Cells[14, 10].PutValue(3);
// chart.ValueAxis.MaxValue = 22;
sheet.Cells[0, 1].PutValue(“BES”);
sheet.Cells[1, 1].PutValue(0.157);
sheet.Cells[2, 1].PutValue(0.145);
sheet.Cells[3, 1].PutValue(0.118);
sheet.Cells[4, 1].PutValue(0.101);
sheet.Cells[5, 1].PutValue(0.083);
sheet.Cells[6, 1].PutValue(0.067);
sheet.Cells[7, 1].PutValue(0.057);
sheet.Cells[8, 1].PutValue(0.044);
sheet.Cells[9, 1].PutValue(0.044);
sheet.Cells[10, 1].PutValue(0.044);
sheet.Cells[11, 1].PutValue(0.04);
sheet.Cells[12, 1].PutValue(0.037);
sheet.Cells[13, 1].PutValue(0.034);
sheet.Cells[14, 1].PutValue(0.030);
//sheet.Cells[0, 10].PutValue(“HighBep”);
//sheet.Cells[1, 10].PutValue(2);
//sheet.Cells[2, 10].PutValue(5);
//sheet.Cells[3, 10].PutValue(6);
//sheet.Cells[4, 10].PutValue(7);
//sheet.Cells[5, 10].PutValue(5);
//sheet.Cells[6, 10].PutValue(2);
//sheet.Cells[7, 10].PutValue(3);
//sheet.Cells[8, 10].PutValue(1);
//sheet.Cells[9, 10].PutValue(3);
//sheet.Cells[10, 10].PutValue(3);
//sheet.Cells[11, 10].PutValue(1);
//sheet.Cells[12, 10].PutValue(0);
//sheet.Cells[13, 10].PutValue(3);
//sheet.Cells[14, 10].PutValue(3);
chart.ValueAxis.MaxValue = 0.22;
chart.ValueAxis.MinValue = 0;
chart.NSeries.Add(“B2:B15”, true);
chart.ShowLegend = false;
chart.PlotArea.Area.FillFormat.Type = Aspose.Cells.Drawing.FillType.None;
chart.ValueAxis.MajorGridLines.IsVisible = true;
chart.ValueAxis.MinorGridLines.IsVisible = false;
chart.ValueAxis.TickLabels.NumberFormat = “0%”;
chart.ValueAxis.MajorUnit = 0.02;
chart.ValueAxis.DisplayUnitLabel.Font.Color = System.Drawing.Color.FromArgb(192, 192, 192);
chart.ValueAxis.MajorGridLines.Color = System.Drawing.Color.FromArgb(192, 192, 192);
//5 chart.ValueAxis.MinorGridLines.Color = System.Drawing.Color.FromArgb(192, 192, 192);
chart.ChartArea.Border.IsVisible = false;
sheet.Cells.Columns[2].Width = 150;
//chart.ValueAxis.IsVisible = false;
Axis categoryAxis = chart.CategoryAxis;
categoryAxis.TickLabels.Font.Color = Color.Black;
categoryAxis.TickLabels.Font.Size = 12;
categoryAxis.TickLabels.Font.Name = “Arial”;
chart.ValueAxis.TickLabels.Font.Name = “Arial”;
chart.ValueAxis.TickLabels.Font.Size = 12;
categoryAxis.MajorGridLines.Color = System.Drawing.Color.FromArgb(192, 192, 192);
categoryAxis.MinorGridLines.IsVisible = false;
categoryAxis.MajorGridLines.IsVisible = true;
categoryAxis.TickLabelPosition = Aspose.Cells.Charts.TickLabelPositionType.None;
categoryAxis.AxisLine.Color = System.Drawing.Color.FromArgb(192, 192, 192);
chart.ValueAxis.AxisLine.Color = System.Drawing.Color.FromArgb(192, 192, 192);
chart.NSeries[0].Points[3].Area.FillFormat.Type = Aspose.Cells.Drawing.FillType.Solid;
chart.NSeries[0].Points[3].Area.FillFormat.SolidFill.Color = System.Drawing.Color.FromArgb(255, 192, 50);
//chart.NSeries[1].Points[3].Area.FillFormat.Type = Aspose.Cells.Drawing.FillType.Solid;
//chart.NSeries[1].Points[3].Area.FillFormat.SolidFill.Color = System.Drawing.Color.FromArgb(255, 192, 50);
for (int i = 1; i < 15; i++)
{
sheet.Cells.Rows[i].Height = 25;
}
//Set properties of Axis(categoryaxis) title
//Axis categoryAxis = chart.CategoryAxis;
//categoryAxis.TickLabels.Font.Color = Color.Black;
//categoryAxis.TickLabels.Font.Size = 12;
//categoryAxis.TickLabels.Font.Name = “Arial”;
//Set properties of valueaxis
//chart.ValueAxis.TickLabels.Font.Color = Color.Black;
//chart.ValueAxis.TickLabels.Font.Size = 12;
//chart.ValueAxis.TickLabels.Font.Name = “Arial”;
//chart.ValueAxis.MajorGridLines.IsVisible = true;
//chart.ValueAxis.MinorGridLines.IsVisible = false;
//chart.ValueAxis.MaxValue = 120;
//chart.ValueAxis.MinValue = 0;
//chart.ValueAxis.MajorUnit = 0.1;
//chart.ValueAxis.MinorUnit = 4;
//MessageBox.Show(" " + (chart.ChartArea.Y));
//MessageBox.Show(" " + chart.PlotArea.Y);
//chart.PlotArea.IsAutomaticSize = false;
chart.PlotArea.InnerY = 0;
chart.PlotArea.Y = 0;
//chart.PlotArea.InnerX = 0;
//chart.PlotArea.X = 0;
//chart.PlotArea.Width = 500;
wk.Save(“C:\outputcolumnclustered1.xls”);
You can find in the attachment 2 pictures , one for my output and the other for the desired one
Regards ,
Kamel