Creating PDF reports with flot graph

前端 未结 3 2076
无人共我
无人共我 2020-12-30 09:53

I am trying to implement an automatic report generation tool for my clients . I need to create reports in pdf format and i am very much comfortable in creating graphs using

3条回答
  •  北海茫月
    2020-12-30 10:48

    Flot draws its graph on HTML5 element. So the possible scenario might be as follows:

    1. Retrieve image data from canvas with toDataURL as described in this answer.
    2. Create a PDF with jsPDF, use addImage as in first example to embed the image into it.

    BUT note, in this scenario you will not see any axis labels in image, because they are not drawn on canvas, they are simple

    elements positioned with position:relative. I found this post where the author offers a Flot plugin which forces Flot to draw text on canvas, but I have no idea whether it works. UPD: Drawing labels on canvas is included in oncoming 0.8 release (see comments).

    BUT2 the legend is also not drawn on canvas, it is also a properly positioned

    . Seems like people in the Flot community are trying to do something with this, I have found two pull requests, the first modifying the core, the other introducing a plugin. Neither of them is merged for about 9 months, and they are marked for v. 0.9 milestone which is after-next and has no due date. At least it is possible to clone those people repos and test their work.

    Resume: many people around Flot are concerned with this issue, but sadly there is no stable, out-of-box way to do it yet — only the hope that 0.9 will finally come out sometimes with this issue addressed.

提交回复
热议问题