Add option to insert legend into canvas, instead. #36

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet

Setting options.legend.type to "canvas" (default is "html") will now draw the
whole legend into the canvas (and also not display the HTML version).

This allows the legend to be visible when converting the canvas into an image.

The code was mostly taken from the flotCanvasText plugin for flot by Andre
Lessa (http://lessaworld.com). The redundant parts were removed, and the code
was simplified.

The whole change is encapsulated within a single function. Apart from this, an
extra option has been added (options.legend.type), and the legend hooks updated
accordingly. (Note that the insertLegend method had to be moved to a later
stage of the drawing process, since the canvas legend was otherwise getting
overwritten.)

Signed-off-by: Rok Strnisa rok@strnisa.com

@rokstrnisa rokstrnisa Add option to insert legend into canvas, instead.
Setting options.legend.type to "canvas" (default is "html") will now draw the
whole legend into the canvas (and also not display the HTML version).

This allows the legend to be visible when converting the canvas into an image.

The code was mostly taken from the flotCanvasText plugin for flot by Andre
Lessa (http://lessaworld.com). The redundant parts were removed, and the code
was simplified.

The whole change is encapsulated within a single function. Apart from this, an
extra option has been added (options.legend.type), and the legend hooks updated
accordingly. (Note that the insertLegend method had to be moved to a later
stage of the drawing process, since the canvas legend was otherwise getting
overwritten.)

Signed-off-by: Rok Strnisa <rok@strnisa.com>
9e8e5b7
Contributor

bor commented Feb 20, 2012

vote for
very needed feature

We really need this!
Someone please merge this code into the master tree, thanks.

lupka commented Mar 10, 2012

Thanks for this. I think it's going to come in handy for what I'm doing.

Owner

OleLaursen commented Mar 20, 2012

Here's what I think based on a quick review:

  • Thanks for working on this! :)
  • Including that canvas text stuff with a hardcoded font is a no go. You should use the built in canvas routines, just like the trunk axis label code is doing.
  • I don't like the "html" switch. I think we should either do it with HTML or do it with canvas in the core, then perhaps add some kind of hook or callback so you can write a plugin to do the other thing.
  • How did you test it? What browsers etc?

I've added a pull request based on this one that addresses these concerns.

@lukesampson Thanks for this. I have been too busy to address this.

dnschnur was assigned Oct 19, 2012

jywarren referenced this pull request in jywarren/spectral-workbench Oct 22, 2012

Closed

print spectrum on a receipt printer #128

I'm dealing with this now...sounds good about adding the legend to the canvas.

It's possible to automate the adding of the axis label to?
I'm using this plug in to write them, right now: jquery.flot.axislabels.js

when will it be merged?

Owner

dnschnur commented Jul 24, 2013

It's assigned to the 0.9 milestone.

bbbales2 referenced this pull request in StochSS/stochss Feb 9, 2014

Closed

Flot cannot be saved as image with main Flot code #125

andig commented Mar 28, 2014

+1 I believe it would make sense to merge this with the canvas plugin. If I want canvas I would want all of it?

Owner

dnschnur commented Mar 29, 2014

That's exactly what I have planned; in fact (this isn't decided yet) this may even become part of the core.

Any news regarding this or has all development in this direction stopped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment