Save ChartJS Chart to Image

Answered
0
0

How can i save a chartjs chart to image (in vb.net)

  • You must to post comments
Best Answer
0
0

Here is some sample code in Visual Basic:

Dim imageData As Image = Await ChartJS1.GetImageAsync()
imageData.Save(".\Images\image.png", ImageFormat.Png)
AlertBox.Show("image saved")

I’ve also attached a sample.

  • Nicholas
    Thanks so much Julie. This now works fine. So grateful to the entire team for the help.
  • You must to post comments
0
0

Hi Nicholas,

you can use the GetImage or GetImageAsync functions to get the chart as an image:

https://docs.wisej.com/extensions/extensions/chartjs/api/wisej.web.ext.chartjs.chartjs

Best regards
Frank

  • Nicholas
    Thanks Frank for the link. I have however tried both but not successful with the code below: ‘Dim chartx As Wisej.Web.DataVisualization.ChartJS3 = chtMain Dim imageData As Byte() = Await chtMain.GetImageAsync() If imageData IsNot Nothing Then Dim currentDate As String = DateTime.Now.ToString(“dd-MM-yy HHmmss”) Dim fileName As String = $”chart_{currentDate}.png” IO.File.WriteAllBytes(fileName, imageData) End If
  • Luca (ITG)
    Not successful how?
  • Nicholas
    The code I pasted up there doesn’t work. I have been trying several options since but cant get any of them to work to export the chart to an image. Is it possible to get a sample code that i can use to export a chartjs chart to an image?
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.