Chart Plot Area Issue

Hi Aspose support team,
My requirement is to show the value axis in the top of the chart with 45 degree rotation. It is working fine with one minor issue. The issue is, value of the value axis is littlebit removed(Top Right Corner) from the chart area. I have used the following code:

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts.Add(ChartType.BarStacked, 2, 0, 25, 10);
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PivotSource = "Berth Performance!PivotTable";
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].RefreshPivotData();
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.Transparency = 1;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ChartArea.Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Title.Text = "";
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ShowLegend = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Legend.Position = LegendPositionType.Top;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Rotation = 45;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Font.IsBold = false;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MajorTickMark = TickMarkType.Outside;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MinorTickMark = TickMarkType.None;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.IsPlotOrderReversed = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.HasMultiLevelLabels = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MajorTickMark = TickMarkType.Inside;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MinorTickMark = TickMarkType.None;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;

Please refer the attached PlotArea1.Xlsx and PlotArea1.Jpeg.

Thats why i changed the code like belew. this time Legends are overwritten in the value axis.

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts.Add(ChartType.BarStacked, 2, 0, 25, 10);
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PivotSource = "Berth Performance!PivotTable";
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].RefreshPivotData();
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.Transparency = 1;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ChartArea.Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Width = 3500;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Height = 2500;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Area.ForegroundColor = Color.White;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Title.Text = "";
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ShowLegend = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Legend.Position = LegendPositionType.Top;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Rotation = 45;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Font.IsBold = false;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MajorTickMark = TickMarkType.Outside;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MinorTickMark = TickMarkType.None;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.IsPlotOrderReversed = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.HasMultiLevelLabels = true;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MajorTickMark = TickMarkType.Inside;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MinorTickMark = TickMarkType.None;
obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;

Please refer the attached PlotArea2.Xlsx and PlotArea2.Jpeg.

But my requirement is like Expected.Xlsx

Please help me to achive to feature and provide the sample piece of code.

Thanks
Saravanan

Hi,


Please call Chart.Calculate() after adjusting the width/height or other attributes accordingly.

e.g
//…
ExcelWorkBook.Worksheets[“Berth Performance”].Charts[0].PlotArea.Width = 3800;
ExcelWorkBook.Worksheets[“Berth Performance”].Charts[0].PlotArea.X = 5;
ExcelWorkBook.Worksheets[“Berth Performance”].Charts[0].Calculate();

//…


Thank you.

Hi Support team,

Thank you for your reply, still i am getting the same issue(Overwritten the legends). Please find the attached image for your kind reference and see the below sample code.

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts.Add(ChartType.BarStacked, 2, 0, 25, 10);

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PivotSource = "Berth Performance!PivotTable";

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].RefreshPivotData();

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.ForegroundColor = Color.White;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].NSeries[0].Area.Transparency = 1;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ChartArea.Area.ForegroundColor = Color.White;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.X = 200;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Y = 300;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Width = 3500;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].PlotArea.Area.ForegroundColor = Color.White;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Calculate();

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Title.Text = "";

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ShowLegend = true;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].Legend.Position = LegendPositionType.Top;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Rotation = 45;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabels.Font.IsBold = false;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MajorTickMark = TickMarkType.Outside;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].ValueAxis.MinorTickMark = TickMarkType.None;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.IsPlotOrderReversed = true;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.HasMultiLevelLabels = true;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MajorTickMark = TickMarkType.Inside;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.MinorTickMark = TickMarkType.None;

obj.ExcelWorkBook.Worksheets["Berth Performance"].Charts[0].CategoryAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;

Please help me to achive this feature.

Thanks,

Saravanan

Hi,


We cannot run/evaluate your sample code accurately. We request you to kindly create a sample project (with template files), zip it and post it here to reproduce the issue on our end. We will look into your issue soon.

Thank you.

Hi Aspose Support team,

Thank you for the reply. i have attached the sample Project(solution) and the ChartPlotArea1.xlsx(For source, Please put this file in C drive).

Please let me know if you need additional information regarding this.

Thank you
Saravanan

Hi,


Thanks for the project with template file.

I have logged a ticket with an id: CELLSNET-40146. We will evaluate your issue and look into it soon.

Thank you.
Hi,

Please try as the attachment(code.txt) demonstrates. We tested the code can work fine. The code segment on how to set the position of chart objects (legend, plot area, chart title and so on…) is not perfect. It only solves this sample for you. We have a plan i.e. within about 2 months or so, we will provide a solution to set position issues completely. In the future versions, we can get position information after calling Calculate() method of Chart. Then, according to the position information, we can set chart objects again exactly to what the position we want.

Thanks for your understanding!