Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Output plots to PDF/etc.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 32 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Corey Taylor  
View profile  
 More options Apr 12 2011, 10:24 pm
From: Corey Taylor <cjt.newtranslat...@gmail.com>
Date: Wed, 13 Apr 2011 11:54:51 +0930
Local: Tues, Apr 12 2011 10:24 pm
Subject: Output plots to PDF/etc.

Hi Chris.

Are there future plans to give the ability to output to external files to
JQPlot?

Thanks.

Corey.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Leonello  
View profile  
 More options Apr 12 2011, 10:39 pm
From: Chris Leonello <jqplot-us...@jqplot.com>
Date: Tue, 12 Apr 2011 22:39:50 -0400
Local: Tues, Apr 12 2011 10:39 pm
Subject: Re: [jqplot-users] Output plots to PDF/etc.

If you mean to save the plot to png/jpeg, that is on the list like many items. Realistically, it is probably a 2.0 feature. It is feasible but somewhat involved and probably fits in better with other optimizations ideas I have for 2.0.

--
Chris Leonello
http://www.jqplot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
golubev  
View profile  
 More options Apr 13 2011, 1:29 am
From: golubev <vgolu...@b1team.ru>
Date: Tue, 12 Apr 2011 22:29:34 -0700 (PDT)
Local: Wed, Apr 13 2011 1:29 am
Subject: Re: Output plots to PDF/etc.
//get the image data from the canvas
var imageData = canvas.toDataURL("image/png");

See also http://www.w3.org/TR/html5/the-canvas-element.html#dom-canvas-todataurl

On Apr 13, 6:24 am, Corey Taylor <cjt.newtranslat...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Leonello  
View profile  
 More options Apr 13 2011, 6:24 pm
From: Chris Leonello <jqplot-us...@jqplot.com>
Date: Wed, 13 Apr 2011 18:24:36 -0400
Local: Wed, Apr 13 2011 6:24 pm
Subject: Re: [jqplot-users] Re: Output plots to PDF/etc.

//get the image data from the canvas
var imageData = canvas.toDataURL("image/png");

This is correct. Plots are composed of a number of canvases plus div elements and possibly table elements, though. They need to be positioned and collapsed or otherwise rendered into one canvas to get a complete image of a plot. A number of details to take care of.

If anyone has ideas on PDF generation (maybe through SVG conversion?), let me know.
--
Chris Leonello
http://www.jqplot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
golubev  
View profile  
 More options Apr 14 2011, 3:31 am
From: golubev <vgolu...@b1team.ru>
Date: Thu, 14 Apr 2011 00:31:24 -0700 (PDT)
Local: Thurs, Apr 14 2011 3:31 am
Subject: Re: Output plots to PDF/etc.
This is my code:

function canvasToImage(canvas,backgroundColor)
    {

        //cache height and width
        var w = canvas[0].width;
        var h = canvas[0].height;

        j("#tempcanvas").attr('width',w).attr('height',h);
        var newCanvas = j("#tempcanvas")[0];
        var newContext = newCanvas.getContext("2d");

        newContext.clearRect(0,0,w,h);
        var allData = newContext.getImageData(0, 0, w, h);

        j(canvas).each(function(){
            var context = j(this)[0].getContext("2d");
            var imageData = context.getImageData(0, 0, w, h);

            var pixels = 4 * w * h;
            while (pixels--) {
                allData.data[pixels] = allData.data[pixels] +
imageData.data[pixels];
            }
        });

        newContext.putImageData(allData, 0,0);

        newContext.globalCompositeOperation = "destination-over";
        newContext.fillStyle = backgroundColor;
        newContext.fillRect(0,0,w,h);

       //get the image data from the canvas
       var imageData = newCanvas.toDataURL("image/png");
       //return the Base64 encoded data url string
       return imageData;
    }

var canvas = j(".jqplot-series-canvas");
var data = canvasToImage(canvas,"#ffffff");

-------

This "data" you can send to server and save in image file. After that
on the server side you can generate PDF with this image. For generate
PDF you can use http://www.tcpdf.org/  (PHP).

On Apr 14, 2:24 am, Chris Leonello <jqplot-us...@jqplot.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 16 2011, 6:42 pm
From: lsiden <lsi...@gmail.com>
Date: Mon, 16 May 2011 15:42:39 -0700 (PDT)
Local: Mon, May 16 2011 6:42 pm
Subject: Re: Output plots to PDF/etc.
@golubev, thank you!  This is exactly what I was looking for!

It almost works for me, but not quite.  In the resulting PNG, I can
see the grid lines, and the axis, but no plot lines and no labels of
any sort.  I wonder if the problem is that the new graphic context
does not have high enough resolution so nothing comes out clearly.
Would you know how to overcome this?

On Apr 14, 3:31 am, golubev <vgolu...@b1team.ru> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 16 2011, 7:00 pm
From: lsiden <lsi...@gmail.com>
Date: Mon, 16 May 2011 16:00:41 -0700 (PDT)
Local: Mon, May 16 2011 7:00 pm
Subject: Re: Output plots to PDF/etc.
FWIW, made a few "improvements": http://pastie.org/1913434  But still
getting nothing but the bare gridlines.

On May 16, 6:42 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 19 2011, 6:40 pm
From: lsiden <lsi...@gmail.com>
Date: Thu, 19 May 2011 15:40:36 -0700 (PDT)
Local: Thurs, May 19 2011 6:40 pm
Subject: Re: Output plots to PDF/etc.
My client, a major telecom company, wants me to provide a way to
extract a plot as a PNG.  Since they will pay me to do it, I would
like to propose that I do this as a plug-in.  Chris, what are the main
"gotchas" or obstacles to doing this that you are already aware of?
On my first attempt using @golubev's proposed code (see my
"pastie.org" link above), I found that the main problem was how to
merge the multiple canvases (one of my plots has over 50!) into a
single canvas without obscuring anything.  I think that the addition
operator is too crude.  Perhaps I need to try a bit-wise 'or'
operator.

The non-canvas div elements are a separate issue that I believe can be
handled.

On May 16, 7:00 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 19 2011, 7:14 pm
From: lsiden <lsi...@gmail.com>
Date: Thu, 19 May 2011 16:14:50 -0700 (PDT)
Local: Thurs, May 19 2011 7:14 pm
Subject: Re: Output plots to PDF/etc.
Bit-wise 'or' is no better than '+' at combining the multiple
canvases, but using '^' (xor), I was at least able to get some
outlines of the plot lines (edges only).  I think that the trick here
is figuring out and emulating how the browser displays these multiple
canvases in the page.

On May 19, 6:40 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 19 2011, 8:14 pm
From: lsiden <lsi...@gmail.com>
Date: Thu, 19 May 2011 17:14:27 -0700 (PDT)
Local: Thurs, May 19 2011 8:14 pm
Subject: Re: Output plots to PDF/etc.
OMG! - It's much easier than I thought!!!:

http://pastie.org/1929353

Then, "window.open($('#myCanvas').canvasToImage());"

On May 19, 7:14 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 27 2011, 1:28 pm
From: lsiden <lsi...@gmail.com>
Date: Fri, 27 May 2011 10:28:22 -0700 (PDT)
Local: Fri, May 27 2011 1:28 pm
Subject: Re: Output plots to PDF/etc.
I have some code (https://github.com/lsiden/export-jqplot-to-png) that
successfully exports a series of jqplot canvases and divs to a PNG,
preserving fonts.  I did it as a jQuery extension, so the usage is

      var img = $('#chartdiv').jqplotToImage(50, 0);
      if (img) {
        open(img.toDataURL("image/png"));
      }

The arguments (50, 0) are x and y offsets.  I found this necessary
because on my plot, the labels on the x-axis are rotated and the first
one was getting clipped by the edge of the drawing canvas while
exporting.  So I needed a way to tell it to move everything over by an
offset in order to accomodate the part of the label that would
otherwise get clipped.'

Here is a blog post for details:
http://westside-consulting.blogspot.com/2011/05/some-users-of-jqplot-...

On May 19, 8:14 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options May 27 2011, 1:31 pm
From: lsiden <lsi...@gmail.com>
Date: Fri, 27 May 2011 10:31:15 -0700 (PDT)
Local: Fri, May 27 2011 1:31 pm
Subject: Re: Output plots to PDF/etc.
PS - I haven't tested this for any plots other than my own, so it may
need refinement/further development to be useful to a wider
community.  But I think its a good start or at least a reference for
others who want to do the same.

On May 27, 1:28 pm, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jpgamaral  
View profile  
 More options Jun 25 2011, 12:09 pm
From: jpgamaral <jpgama...@gmail.com>
Date: Sat, 25 Jun 2011 09:09:22 -0700 (PDT)
Local: Sat, Jun 25 2011 12:09 pm
Subject: Re: Output plots to PDF/etc.
I get a blank image. I'm following your steps exactly. I even tweaked
the parameters for jqplotToImage() but I always get a blank image :/
Any ideas why?

$("#exportPNG").click(function() {
       var img = $('#chartdiv').jqplotToImage(50, 0);
        if (img) {
                open(img.toDataURL("image/png"));
        }

});

Best regards!

On 27 Maio, 18:31, lsiden <lsi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Siden  
View profile  
 More options Jun 25 2011, 4:27 pm
From: Larry Siden <lsi...@westside-consulting.com>
Date: Sat, 25 Jun 2011 16:27:16 -0400
Local: Sat, Jun 25 2011 4:27 pm
Subject: Re: [jqplot-users] Re: Output plots to PDF/etc.

@jpgamaral, What browser are you trying this with?  It will not work at all
in IE<9 (I haven't tested it with IE9 yet).

Also, did you check in the debugger whether something is getting returned
for var img?

Larry Siden,
Westside Consulting LLC
westside-consulting.com
734-926-9614


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jpgamaral  
View profile  
 More options Jun 25 2011, 7:01 pm
From: jpgamaral <jpgama...@gmail.com>
Date: Sat, 25 Jun 2011 16:01:24 -0700 (PDT)
Local: Sat, Jun 25 2011 7:01 pm
Subject: Re: Output plots to PDF/etc.
@Larry, actually I was using IE9 yes, because Chrome doesn't read the
CSS from ThemeRoller and IE9 does :/ I just tested in Chrome and it
works :D Any idea why it doesn't in IE9 tho?

On 25 Jun, 21:27, Larry Siden <lsi...@westside-consulting.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Siden  
View profile  
 More options Jun 25 2011, 7:43 pm
From: Larry Siden <lsi...@gmail.com>
Date: Sat, 25 Jun 2011 19:43:49 -0400
Local: Sat, Jun 25 2011 7:43 pm
Subject: Re: [jqplot-users] Re: Output plots to PDF/etc.

Well, I was trying to get stuff to work in IE7 yesterday before I found out
that canvas.imageToURL() is useless on IE<9 and there was a whole slew of
calls my code makes in order to get the positions of the elements that works
perfectly on Gecko and WebKit browser but need to be completely reworked in
order to function on IE.  True to its corporate sponsors, IE remains
stubbornly different from other browsers in many fine details that can dash
hopes and careers of the naive and unsuspecting who, like me, believe that
browsers should adhere to standards so that consumers will have a choice
when they access the web.

I can send you the modified code later tonight.  I got everything to work up
to the point where it tried to invoke imageToURL().  So I'm anxious to hear
whether IE9 will finally allow that bit to happen.

-Larry Siden

The United States is a nation of laws, badly written and randomly enforced.
--Frank Zappa 1940-1993

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lsiden  
View profile  
 More options Jun 27 2011, 11:51 am
From: lsiden <lsi...@gmail.com>
Date: Mon, 27 Jun 2011 08:51:48 -0700 (PDT)
Local: Mon, Jun 27 2011 11:51 am
Subject: Re: Output plots to PDF/etc.
@jpgamaral, I promised you that I would send you my code that handled
getting positions of items for drawing in IE.  Here is it:
http://pastie.org/2129617.  It begins with $.fn.jqplotToImage.  Hope
that helps!

On Jun 25, 7:43 pm, Larry Siden <lsi...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Compuwizard123  
View profile  
 More options Jul 7 2011, 4:55 pm
From: Compuwizard123 <compuwizard...@gmail.com>
Date: Thu, 7 Jul 2011 13:55:48 -0700 (PDT)
Local: Thurs, Jul 7 2011 4:55 pm
Subject: Re: Output plots to PDF/etc.
I was trying this out and it works really well for the plot areas. How
about for the legends? I noticed this didn't work. I'm willing to work
on it I just didn't know how to convert the table the legend resides
in into a possible canvas item.

Kevin Risden

On Jun 27, 10:51 am, lsiden <lsi...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vinod T G  
View profile  
 More options Jul 11 2011, 12:29 am
From: Vinod T G <vinod.t...@gmail.com>
Date: Sun, 10 Jul 2011 21:29:57 -0700 (PDT)
Local: Mon, Jul 11 2011 12:29 am
Subject: Re: Output plots to PDF/etc.
Hi,

I tried your code above. I got my jqplot as a canvas with vml tags
inside in IE < 9 as I am working with IE 8. But I getting only the
texts inside the jqplot, that means I am getting only the axis texts,
there was no drawings. Please help me in this issue. Thanks in
advance.

Regards,
Vinod

On Jun 27, 8:51 pm, lsiden <lsi...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Compuwizard123  
View profile  
 More options Jul 12 2011, 12:47 pm
From: Compuwizard123 <compuwizard...@gmail.com>
Date: Tue, 12 Jul 2011 09:47:42 -0700 (PDT)
Local: Tues, Jul 12 2011 12:47 pm
Subject: Re: Output plots to PDF/etc.
IE < 9 doesn't have support for toDataUrl() even with excanvas so that
makes it difficult if not impossible to save the image or display it I
think.

Kevin Risden

On Jul 10, 11:29 pm, Vinod T G <vinod.t...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vinod T G  
View profile  
 More options Jul 13 2011, 6:48 am
From: Vinod T G <vinod.t...@gmail.com>
Date: Wed, 13 Jul 2011 03:48:30 -0700 (PDT)
Local: Wed, Jul 13 2011 6:48 am
Subject: Re: Output plots to PDF/etc.
Hi,

Thanks for the reply Kevin. Is there any way to export jqplot to png
or pdf in IE 8 and less? When I used the exporting code posted by
lsiden, I got a canvas with g_vml_ tags inside. My issue is how to
convert it to image or how can get it as an image.

Cheers,
Vinod

On Jul 12, 9:47 pm, Compuwizard123 <compuwizard...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Siden  
View profile  
 More options Jul 21 2011, 12:56 pm
From: Larry Siden <lsi...@gmail.com>
Date: Thu, 21 Jul 2011 09:56:42 -0700 (PDT)
Local: Thurs, Jul 21 2011 12:56 pm
Subject: Re: Output plots to PDF/etc.
It won't work in either IE7 or IE8, because even with excanvas.js the
the canvas element doesn't support toDataUrl().  I also recall reading
that in IE7/8 it does not support fillText() so you won't be able to
draw the labels.  This page, http://code.google.com/p/explorercanvas/wiki/Instructions,
has some useful discussions and examples, but I haven't found any
workarounds for this particular issue.  Go figure.  Microsoft vs. the
Rest of the World!

On Jul 13, 6:48 am, Vinod T G <vinod.t...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
BB  
View profile  
 More options Aug 23 2011, 6:56 pm
From: BB <bbai...@compasslabs.com>
Date: Tue, 23 Aug 2011 15:56:43 -0700 (PDT)
Local: Tues, Aug 23 2011 6:56 pm
Subject: Re: Output plots to PDF/etc.
This is great stuff and I am using it with total success in all
browsers except IE. I would like to figure out how to make it work in
IE9. I'm using the code file that you wrote for IE9 and still no
worky.

Anyone else had this problem?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Siden  
View profile  
 More options Aug 23 2011, 11:14 pm
From: Larry Siden <lsi...@gmail.com>
Date: Tue, 23 Aug 2011 23:14:31 -0400
Local: Tues, Aug 23 2011 11:14 pm
Subject: Re: [jqplot-users] Re: Output plots to PDF/etc.

Glad too great you found it useful!  IE 9 is supposed to support the HTML 5
canvas but it's still IE!  Let its know if your able to feet anywhere.
On Aug 23, 2011 6:56 PM, "BB" <bbai...@compasslabs.com> wrote:

> This is great stuff and I am using it with total success in all
> browsers except IE. I would like to figure out how to make it work in
> IE9. I'm using the code file that you wrote for IE9 and still no
> worky.

> Anyone else had this problem?

> --
> You received this message because you are subscribed to the Google Groups

"jqplot-users" group.
> To post to this group, send email to jqplot-users@googlegroups.com.
> To unsubscribe from this group, send email to

jqplot-users+unsubscribe@googlegroups.com.
> For more options, visit this group at

http://groups.google.com/group/jqplot-users?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Leonello  
View profile  
 More options Aug 26 2011, 11:56 pm
From: Chris Leonello <jqplot-us...@jqplot.com>
Date: Fri, 26 Aug 2011 23:56:03 -0400
Local: Fri, Aug 26 2011 11:56 pm
Subject: Re: [jqplot-users] Re: Output plots to PDF/etc.

I've incorporated Larry's enhancement into jqPlot (thanks Larry!).

Note, as discussed earlier, IE 9 does have a problem, but it is not with canvas or with toDataUrl(). IE 9 has a problem with this:

open(img.toDataURL("image/png"));

and this:

window.location.href = imgData.replace("image/png", "image/octet-stream");

This is a known issue with IE 9 window.open() and window.location.href. The canvas image rendering is working properly and the solution to show the image is to do something like this:

var elem = document.createElement("img");;
elem.src = imgCanvas.toDataURL("image/png");

someDivInPage.append(elem);

So, on IE 9, instead of trying to force a download of the image, or open a new window and populate it with the image data, insert the image directly into the page as an image tag. This does require a little more work as you would probably have a hidden div that you would .show() once the image is created.

As far as I can tell, this work around is only needed for IE9. Other browsers (those that support canvas, anyway) handle window.open and window.location.href fine.

These changes are in the repository. A number of the samples in the "examples" folder have been updated with a "View Plot Image" button to slide open a div showing a png of the plot. The code performing this operation is actually in "examples/example.js", which is included by many of the sample pages.

For IE 7/8 (currently rendered through excanvas emulation), the situation is tricky. I'm experimenting with 2 work arounds right now, using flashcanvas and SVGKit.

--
Chris Leonello
http://www.jqplot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 32   Newer >
« Back to Discussions « Newer topic     Older topic »