Get image of control (ChartJS)

0
0

I want to save a chart as pdf or image file. Is there any way to get that (similar or not to DrawToBitmap in winform applications)?

  • You must to post comments
0
0

Hi Adrian,

You can’t get the image without actually rendering the control, what you can do however is that you can set the ChartJs’s control Location to -10000, -10000. That way the control would be rendered but not visible on the screen.

Best regards,
Alaa

  • You must to post comments
0
0

By the way, maybe this sample could be useful for you.
Its about print from canvas or panel in a form

Regards

  • Adrian Zagar
    Thank you, Paul. Your sample is useful but not completely. Imagine this scenario: var f = new Form(); f.Size=…; var g = new myGraph(); //this is my userControl containing a ChartJS g.Dock = DockStyle.Fill; f.Controls.Add(g); g.Activate(); //that do the job, fill datasets, etc f.ShowDialog(); //that shows perfectly the graph on screen, and probably the code you suggested will work What I want is to get the Image without showing the graph on screen. Something like: var g = new myGraph(); //this is my userControl containing a ChartJS g.Size=new Size(800,600); //for example g.Activate(); //that do the job, fill datasets, etc Image img= ???? //get Image from g //that code return null; think I was stupid to even try it… Image b = null; Html2Canvas.Screenshot(g, (Image) => { b = Image; }); Can you give me a hint?
  • Luca (ITG)
    You don’t have to display the image. Html2Canvas returns an Image object, you can display it, save it, print it, etc. See System.Drawing.Image.
  • Adrian Zagar
    I don’t get the image. I don’t want to display the ChartJS object, I want to obtain the image on memory; the ChartJS is defined on code, populated on code. I want to get the image without adding the control to an existing form on screen. Is it possible?
  • You must to post comments
0
0

Hi Adrian

are you using some integration control like in this sample ?

All about integration – Part 1

Best regards

  • Adrian Zagar
    I’m using ChartJS. Basically, I want to capture the graph as an image.
  • Paul (ITG)
    Hi Adrian. Ill send you another sample that can be useful
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.