I found an issue if you add textboxes to a chart. Please find the sample attached. I arrange textboxes in different rows above the plot area. If I take a look at the excel file, it is conspicuous that the textboxes of the first row are higher than the other textboxes. But as you can see in the source code, each textbox has the same height. Additionally, the second and third row are placed too low. They should appear above the plot area. Remarkably, if you save the xls file in pdf format, everything looks as expected.
Finally, there are slight differences between the end points of the inserted lines if you compare the excel and the pdf file. In excel (where it is shown correctly), each line touches the category axis. In contrast, the pdf file shows a small gap between the line and the x-axis.
We have done some changes for the position of shapes. Please try the fix attached.
Please make sure that the code i.e., chart.Calculate() is called after changing the value of the plot area and set the TickLabelSpacing of category axis to 5.
Changing the height of the plot area has also an effect on the width of the plot area. It also seems, that the left margin between chart and plot area becomes bigger, when the height of the plot area decrease.
Using the TickLabelSpacing Property leads to an unexpected placement of the inserted textboxes. If I use this property five of the six textboxes become invisible and the position of the remaining one shifts to the right side.
Please find attached the used code to reproduce the problems. (It includes three different variants to show the problem. My aim is to change the height and the TickLabelSpacing property without side effects)
After implementing the initial report I started to roll out the new reporting system to other use cases. For this reason I had to change the scale of the category axis of some line charts. After adding the textboxes and lines to the chart I noticed that there are big differences between the position of the line and the tick labels. The further you move to the right (into the future) on the category axis, the bigger is the gap. It is possible to increase the precision to integrate the lines into the chart? In some cases it works fine, but there are also examples that look like the chart provided in the example files.
Would it be possible to get a solution by Friday? If the issue is fixed we would like to start our new reporting system on next Monday.
2/13-2/20 are Chinese New Year Holidays. All our developers for Aspose.Cells are from China so they are on their holidays. We will work on this issue when we are back to office. Thanks for your patience.
I guess you could consider this issue as fixed. After I did a workaround to ensure the correct position of the additional graphical elements I reviewed my code. Thereby I noticed that I calculated the unit value as an integer as shown by Nausherwan in his post.
int unit = (int)(width / (dataCount / (double)tickSpacing)+0,5);
chart.Shapes.AddShapeInChart(MsoDrawingType.Line, PlacementType.MoveAndSize, x + unit * 2, 0, x + unit * 2 + 1, 4000, null);
This method works fine for chart entries which are close to the value axis because rounding errors have only a small effect in this situation.
The following lines of code solve the issue
double unit = (width *1.0 / (dataCount) );
chart.Shapes.AddShapeInChart(MsoDrawingType.Line, PlacementType.MoveAndSize, x + (int)(unit * index),top + 80, x + (int)(unit * index) , 4000 - (4000 - y - height), null);
We have improved the related module. Please try the attached fix. We checked your code and found there are only 134 source data count and the last 2 cells of the source data are null. So, you need to modify your code to following.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.