Hi,
We use on Aspose.Cells to move textboxes inside charts, in order to do this, we use the APIs to get the location of the plot area and move it accordingly.
However, it seems after Aspose migrated PlotArea.InnerX to chart.PlotArea.InnerXRatioToChart, this no longer works properly and consistently.
Below is an example code that attempts to move a textbox in the chart to the top left corner of the plot area:
var workbook = new Workbook(@".\test.xlsx"); Chart chart = workbook.Worksheets[0].Charts[0]; chart.Calculate(); Shape shapeToMove = chart.Shapes[0]; //int left = chart.PlotArea.InnerX; // cells 24.10.0 //int top = chart.PlotArea.InnerY; // cells 24.10.0 int left = (int)(chart.PlotArea.InnerXRatioToChart * 4000); // cells 25.6.0 -> same result in deprecated chart.PlotArea.InnerX in this version int top = (int)(chart.PlotArea.InnerYRatioToChart * 4000); // cells 25.6.0 -> same result in deprecated chart.PlotArea.InnerY in this version Console.WriteLine(left); // cells 24.10.0 - 202 / cells 25.6.0 - 245 Console.WriteLine(top); // cells 24.10.0 - 638 / cells 25.6.0 - 643 shapeToMove.LeftInShape = left; // move the text box to the left edge of the plot area shapeToMove.TopInShape = top; workbook.Save(@".\moved.xlsx");
The InnerX value of the plot area is significantly different from the actual value, which resulted in an extra gap between the moved textbox and the actual top left corner of the plot area. This did not happen in older version of Aspose.Cells (e.g. 24.10.0)
This does not seem to behave consistently, in some other charts the InnerX value was calculated properly even in the most recent version.
I’ve attached the test files from both versions and a screenshot for your reference. Could you please check if this is a regression or if there’s a more reliable way in this version to move the boxes to a location relative to the plot area?
test.zip (212.6 KB)
image.png (42.3 KB)
Thanks,