Skip to content

Add option to export graph data to table, csv, Excel #580

dnschnur opened this Issue Sep 28, 2012 · 9 comments

1 participant

Flot member

Original author: (April 01, 2011 20:17:25)

It would be great to be able to export the data from the graph into an inline HTML table, or csv, or Excel. The use-case is that while graphs are great for a bigger picture, people sometimes need to inspect individual data points, and making it possible to get a "dump" of them would make this possible.

Original Q on the ML:

Original issue:

Flot member

From on April 02, 2011 04:12:54
Flotr has this functionality and it looks great. See . Flotr's home page is at .

Flot member

From on April 04, 2011 12:02:20

It seems valuable. However, this is definitely something that should be done either in a plugin or outside Flot, in the interest of not complicating things too much. If you're interested in working on it and gain eternal fame, I suggest you go ahead and post your results to the mailing list.

Flot member

From on April 04, 2011 16:40:13
Right. Marking this as WontFix may not be good for building a community of contributors, though. I think WontFix will hide this issue, so anyone looking to gain the fame you speak of by implementing the missing features will not see this issue, which is an opportunity to build something that people are asking for. Maybe you can leave it open or change the status to something that signals "community wants this, but it has to be a plugin, and not in the core".

Flot member

From on April 04, 2011 17:27:59
Sorry. I tend to agree with you, and as you can see, there are indeed quite a bunch of issues open in the issue tracker - it's mostly that as long as nobody is backing them up somehow, they do tend to clutter the whole thing. People generally mostly work on what they need themselves, so if you don't do it, this issue could sit here for many years.

But never mind, I'll reopen it for now. Maybe someone will pick it up. Thanks for reporting it anyway, forgot to say that before.

Flot member

From on April 04, 2011 21:08:23
Thank you for being open to suggestions like this. +1.

Flot member

From on July 27, 2012 19:45:15
I can export as a PDF. It works on IE 9, Firefox and Chrome. If u want more information u can ask me.

Flot member

From on July 28, 2012 00:31:13
Yes, I'm curious how you are doing it?

Flot member

From on August 13, 2012 19:16:00
;) ok here we go... hope this can help u (IT WORKS FOR ME):
First of all i edit the jquery.flot.js file and add it the line: = 'canvas_'+cls;

this goes into the function: function makeCanvas(skipPositioning, cls)---->

function makeCanvas(skipPositioning, cls) {
var c = document.createElement('canvas');
c.className = cls;
c.width = canvasWidth;
c.height = canvasHeight;

---> = 'canvas_'+cls;

This is very important because flot doesnt generate the canvas with an ID...

The next step:
include this on your html page->

U can obtain those files in ->

So now we have the id of the canvas that we want to convert to an image... Make a function like:

function print(){
var oCanvas = document.getElementById("canvas_base");
var strDataURI = oCanvas.toDataURL();
var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true);

        //insert the image in the div PLACEHOLDER...

        //submit your form for exporting to pdf..
        document.getElementById("id_pagina").value = document.getElementById("grafico").innerHTML;


so thats it... my html for example looks like this..

and in impime_graf.php i have something like this:

require '../inc/pdfcrowd/pdfcrowd.php';
$grafico = $_POST["id_pagina"];

// create an API client instance
$client = new Pdfcrowd("...", "...");
// THIS STR_REPLACE is neccesary if the image is out of range...
$html = str_replace("');
$pdf = $client->convertHtml($html);

// set HTTP response headers
header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=\"grafico_pareto.pdf\"");

// send the generated PDF
echo $pdf;

catch(PdfcrowdException $why)
echo "Pdfcrowd Error: " . $why;

Valdivia, Chile

Flot member

From on August 13, 2012 19:19:47
it works with dompdf too... i have some problems with accents and special characters, so if u can help me with would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.