We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart.ToImage prints yaxis incorrectly and does not print trendlines

I am using designer worksheets to populate a scatter chart with a trendline.
When I tried to create a image for the chart, the yaxis is plotted as it crosses at value 1 instead of 0. When I set yaxis crossat property to max it creates the image correctly.
There’s a trendline on the chart and it does not show up at the image created using chart.toimage(), either the trendline is set at the designer chart or set by cells.addtrendline.

Hi,

Could you post your template file, we will check it soon.

And by the way could you try the fix / version attached @: <A href="</A> if it works fine.</P> <P>Thank youl.</P>

Thanks for the quick response.

The version of the aspose.cells dll I’am using is 4.4.3.1. I am currently evaluating the product before purchasing it, so I do not have a license (if it makes a difference in its behaviour).

Here’s the code that opens the attached template, changes some values, adds a trendline, creates a image of the chart and then saves a copy of the modified template.

Issues:

  • Trendline does not show on the image (shows in the saved copy test2.xls)
  • On the image y axis crosses x axis at value 1 (it crosses at 0 on the template and the saved copy)


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wb As New Workbook
wb.Open(Server.MapPath(“excels\testtemplate.xls”), FileFormatType.Default)
Dim chart As Chart = wb.Worksheets(0).Charts(0)

chart.NSeries(0).TrendLines.Add(TrendlineType.Polynomial, “tre”)
With wb.Worksheets(2)
.Cells(2, 0).PutValue(“Item Major”)
.Cells(2, 1).PutValue(4.5)
.Cells(2, 2).PutValue(47.8)


.Cells(3, 0).PutValue(“Item minor”)
.Cells(3, 1).PutValue(2.5)
.Cells(3, 2).PutValue(87.8)
End With



'Convert the chart to an image file.
'chart.CategoryAxis.Crosses = CrossType.Maximum


Dim bitmap As System.Drawing.Bitmap = chart.ToImage()
’ chart.CategoryAxis.Crosses = CrossType.Automatic

'Save the chart image (jpg) file to disk.

bitmap.Save(Server.MapPath(“excels/test.jpg”), System.Drawing.Imaging.ImageFormat.Jpeg)

With Image1
.ImageUrl = “excels/test.jpg”
.Visible = True
End With

wb.Save(Server.MapPath(“excels/test2.xls”))

End Sub

Hi,

Thanks for the template file with sample code,

We found the issue and will fix it soon.

Thank you.

Hi,

Please try the fix in <A href="wlmailhtml:{AF3FBF61-BA42-45F4-88B5-63096A803E39}mid://00000084/!x-usc:</A><BR>1,We are still working on printing trendline in Charts2Image.</P> <P>2,We have fixed this bug.</P>