Hello,
Thanks for your feedback.
After many tests, I found that the relative position of the legend and the plotting area will be affected by the chart width and height. For the Excel file you provided, if you manually adjust the chart size to an appropriate value in Microsoft Excel, then you can make the legend and plot area almost at the same horizontal height, as shown below. You can verify this on your side.
- screenshot.png (56.69 KiB) Viewed 889 times
Therefore, you can try to adjust the chart position in the code. I have verified that when setting like the following code, and the position of the legend in the resulting file is exactly what you expect.
- Code: Select all
chart.LeftColumn = 10;
chart.TopRow = 10;
chart.RightColumn = 16;
chart.BottomRow = 25;
Also, for the code I provided above, when changing the DataRange to A1:D7, you need to adjust the chart position as follows.
- Code: Select all
chart.LeftColumn = 1;
chart.TopRow = 10;
chart.RightColumn = 8;
chart.BottomRow = 29;
Sincerely,
Brian
E-iceblue support team