2

Possible Duplicate:
How to save a jQuery FLOT Graph to a .png or orther image formate?

Is it possible to save graphs build with flot as images? If yes, how?

Community
  • 1
  • 1
Claude Schlesser
  • 849
  • 6
  • 15

1 Answers1

4

When working with HTML5-capable browsers, flot outputs graphs to a <canvas> element. The canvas element has a fairly widely-supported ToDataURL() method that you can use to write the canvas to a URI scheme string to use as an image source. What you do from the string from there is up to you, but MDN provides an example of saving the image, at least in the case of Firefox. At the very least you can create a new image element on your document and set its src to the result string, then allow a user to save the image.

Coming down the pipe as of this May is a new HTML 5 specification for canvas.ToBlob() but that will take quite some time before it's supported. Last I read, no one has yet implemented it, as there's a bit of a waiting game until the specification is clearer and more finalized.

lsuarez
  • 4,952
  • 1
  • 29
  • 51
  • works great! in python, I can use base64.b64decode([chart data]) to get the image, then save it. It comes out as a nice png with alpha. – Matt Feifarek Sep 21 '11 at 18:09
  • what about a bar graph that has a legend that HTML? – pcproff Aug 20 '12 at 20:06
  • You should start a new question for your issue. This question is for discussion of saving graphs built with the flot library. – lsuarez Aug 20 '12 at 20:12