Chart.ToImage - Leader Lines are not included

When calling Chart.ToImage(), the resulting image is missing the leader lines displayed in Excel.

Excel-Aspose-Comparison.png (147.3 KB)

Excel on the left, Aspose.Cells 25.6 on the right.

@DTS_Barry

It appears that the leader lines in your chart are not being included when you call the Chart.ToImage() method in Aspose.Cells. This issue may arise because the leader lines are not automatically rendered in the image output.

To address this, you can utilize the GetLeaderLines() method associated with the series in your chart. This method retrieves the leader lines for the data labels, which you can then manually draw onto the image after generating it. Unfortunately, the context does not provide a direct code example for this, but here’s a general approach you can follow:

  1. Generate the chart image using Chart.ToImage().
  2. Retrieve the leader lines using the GetLeaderLines() method.
  3. Draw the leader lines on the generated image using a graphics library.

Here’s a simplified code example to illustrate the concept:

// Assuming you have a Chart object 'chart'
BufferedImage chartImage = chart.toImage();

// Retrieve leader lines
Line leaderLines = chart.getSeries().getLeaderLines();

// Use a Graphics2D object to draw leader lines on the chartImage
Graphics2D g2d = chartImage.createGraphics();
for (Line line : leaderLines) {
    // Draw each leader line on the image
    g2d.drawLine(line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY());
}
g2d.dispose();

You may need to adjust the drawing logic based on the actual properties of the leader lines and your specific requirements.

If you continue to experience issues, consider checking the Aspose.Cells documentation or forums for any updates or patches related to rendering leader lines in images.

Sources:
[1]: GetLeaderLines Method | Aspose.Cells for Go via C++ API Reference

@DTS_Barry
Would you like to provide your sample file? Please compress the Excel file into zip format and upload it here. We will check it soon.

budgetoverviewparent-repro.zip (45.5 KB)

Here is the sample Excel file.

@DTS_Barry
By testing on the latest version v25.6 using sample file, we can reproduce the issue. The result image is missing the title of chart displayed in excel when saving chart to image.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-58573

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The larger issue for us is the missing leader lines (circled in the attached picture).
Excel-Aspose-Comparison2.png (151.4 KB)

@DTS_Barry
Thank you for your feedback. We have noticed the issue you mentioned. The result image is missing the title and leader lines of chart displayed in excel when saving chart to image. We will fix the issues mentioned. Once there is an update, we will notify you promptly.

Hi @DTS_Barry
For this issue, our optimized result is as follows, and it will take effect in version 25.7.
250626.png (22.0 KB)

1 Like

The issues you have found earlier (filed as CELLSNET-58573) have been fixed in this update. This message was posted using Bugs notification tool by leoluo