Anyone working on the flot widget?

36 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Jun 24, 2009, 4:15:21 AM6/24/09
to lif...@googlegroups.com
Hi,

We need to do quite a lot of charting in our app and after evaluating
several libraries we've settled on Flot (for now at least :-)

So I was happy to discover there was already some Flot integrations in
Lift. After having looked a bit at this, it seems there are some things
missing that we would need:

1) Better support for barcharts (ie specifying data series as (label, value))

2) Support for pie charts (patches exists for the JS part)

But before diving into this I thought to ask if anybody is already
working on the flot widget (or has other ideas for the Flot stuff)

/Jeppe

Timothy Perrett

unread,
Jun 24, 2009, 4:23:11 AM6/24/09
to lif...@googlegroups.com

I've not spoken with Francois for some time, but I'll ask him next time he's
online if he's able to make changes to the flot stuff. He's based in Chilli
so should be online later on.

Cheers, Tim

marius d.

unread,
Jun 24, 2009, 4:45:11 AM6/24/09
to Lift
One note ... the flot widget is in lift-widgets but I think it should
also be added into the test demo app along with the other widgets so
people can actually see it in action.

Br's,
Marius

Jeppe Nejsum Madsen

unread,
Jun 24, 2009, 4:49:40 AM6/24/09
to lif...@googlegroups.com
On 24 Jun 2009, Timothy Perrett wrote:

> I've not spoken with Francois for some time, but I'll ask him next
> time he's online if he's able to make changes to the flot stuff. He's
> based in Chilli so should be online later on.

Thanks. I'm more than willing to spend some time on this (and share the
results :-) since we need it, but having the original author on board
would be most helpful.

/Jeppe

Francois Bertrand

unread,
Jun 24, 2009, 6:48:50 PM6/24/09
to Lift
Hi Jeppe

Great to see you are interested in the flot widget.

My current to-do list for the flot widget, is:

- create more Lift JsExp and JsCmd to modify a already displayed flot
graph. They should be used in AJAX and Comet applications

- update to a more recent version of the javascrrit widget

- create the test demo app,

- make the creation of FlotOptions, FlotLinesOptions, etc, less
verbose. I hope that Scala 2.8 Named and Default Arguments will help.

- create a high level mechanism to display Lift's Record

I appreciate any help.

Francois

Jeppe Nejsum Madsen

unread,
Jun 25, 2009, 8:13:51 AM6/25/09
to lif...@googlegroups.com
On 25 Jun 2009, Francois Bertrand wrote:


> Hi Jeppe
>
> Great to see you are interested in the flot widget.
>
> My current to-do list for the flot widget, is:
>
> - create more Lift JsExp and JsCmd to modify a already displayed flot
> graph. They should be used in AJAX and Comet applications
>
> - update to a more recent version of the javascrrit widget

I need this as well, especially since there are some patches that
provides pie charts

>
> - create the test demo app,
>
> - make the creation of FlotOptions, FlotLinesOptions, etc, less
> verbose. I hope that Scala 2.8 Named and Default Arguments will help.

Yeah, this would be nice :-) We probably need some working code within
the next few weeks so probably can't wait for 2.8 though.

> - create a high level mechanism to display Lift's Record
>
> I appreciate any help.

What's the best way to coordinate this? Just fork the code on github or?

/Jeppe

Peter Robinett

unread,
Jun 25, 2009, 10:09:26 PM6/25/09
to Lift
Hi flot users,

I am trying to copy the basic Flot example into my own code. I have no
compile errors but the graph isn't rendered because /classpath/flot/
jquery.flot.js isn't found. Since I get no errors with the flot
methods in my snippet, I assume lift-widgets is loading correctly. Am
I missing something?

Thanks,
Peter

Jeppe Nejsum Madsen

unread,
Jun 26, 2009, 3:53:24 AM6/26/09
to lif...@googlegroups.com
On 26 Jun 2009, Peter Robinett wrote:


> Hi flot users,
>
> I am trying to copy the basic Flot example into my own code. I have no
> compile errors but the graph isn't rendered because /classpath/flot/
> jquery.flot.js isn't found. Since I get no errors with the flot
> methods in my snippet, I assume lift-widgets is loading correctly. Am
> I missing something?

Did you put a call to net.liftweb.widgets.flot.Flot.init in Boot?

This is needed to make the javascript resources available...


/Jeppe

Peter Robinett

unread,
Jun 26, 2009, 5:09:15 AM6/26/09
to Lift
Thanks, Jeppe, that's what I was missing.

To continue to hijack this thread with my own questions, I'm having a
problem creating the data List[(Double, Double)] that FlotSerie wants.
I have:
override val data = MyModel.findAll(By(MyMode.id, myId), OrderBy
(MyModel.datetime, Ascending)).map(m => (m.datetime.getTime.toDouble,
m.temperature.toDouble))

This gives me an error saying I'm missing arguments for toDouble in
class MappedDouble (this is MyModel.temperature) and suggests treating
it as a partially applied function. I'm not sure I want to do that
but, trying it anyway (with "m.temperature.toDouble _"), I got an new
error saying that List[(Double, (Any) => Double)] is an incompatible
type.

Any suggestions? I'm sure it's a REALLY simple fix.

Thanks,
Peter

Viktor Klang

unread,
Jun 26, 2009, 5:27:40 AM6/26/09
to lif...@googlegroups.com
What's the type of "temperature" and what's the signature of the toDouble method on it?
--
Viktor Klang
Scala Loudmouth

Jeppe Nejsum Madsen

unread,
Jun 26, 2009, 6:47:23 AM6/26/09
to lif...@googlegroups.com
Peter Robinett <pe...@bubblefoundry.com> writes:

> Thanks, Jeppe, that's what I was missing.
>
> To continue to hijack this thread with my own questions, I'm having a
> problem creating the data List[(Double, Double)] that FlotSerie wants.
> I have:
> override val data = MyModel.findAll(By(MyMode.id, myId), OrderBy
> (MyModel.datetime, Ascending)).map(m => (m.datetime.getTime.toDouble,
> m.temperature.toDouble))

If m.temperature is a MappedDouble you probably need m.temperature.is

The toDouble method converts an Any to a double, not the value of the
current mapped object.....

/Jeppe

Peter Robinett

unread,
Jun 26, 2009, 11:09:01 AM6/26/09
to Lift
Thanks, Jeppe, that was it. So 'is' will give you the native type of
any MappedType? Good to know!

Peter

Timothy Perrett

unread,
Jun 26, 2009, 11:33:53 AM6/26/09
to lif...@googlegroups.com

That's actually a common iddiom throughout lift - its the same for
RequestVar and SessionVar etc etc

Cheers, Tim

dflemstr

unread,
Jun 26, 2009, 6:00:12 PM6/26/09
to Lift
Hello everyone involved,
I am having a very annoying problem with the Flot widget: The
automatically generated legend's auto-sizing feature is broken (it
grows horizontally to the max allowed space while still adhering to
the margin values specified, and it's not possible to create an
external, custom legend) as demonstrated by this screenshot:
http://bit.ly/uKE9o

This bug is present in 1.1-M1 as well as 1.1-SNAPSHOT, isn't caused by
me (since it is present int he demo app) and seems to originate from
something on the client-side (obviously).

Does anyone have a solution to this problem, or if not, can I make a
fork of the widgets module, try to fix the problem, and commit it
back? This little inconvenience removes much of the visual quality of
plots, so a solution to it would be very much appreciated.

/dflemstr

Jeppe Nejsum Madsen

unread,
Jun 27, 2009, 3:50:53 AM6/27/09
to lif...@googlegroups.com
dflemstr <david.f...@gmail.com> writes:

> Hello everyone involved,
> I am having a very annoying problem with the Flot widget: The
> automatically generated legend's auto-sizing feature is broken (it
> grows horizontally to the max allowed space while still adhering to
> the margin values specified, and it's not possible to create an
> external, custom legend) as demonstrated by this screenshot:
> http://bit.ly/uKE9o
>
> This bug is present in 1.1-M1 as well as 1.1-SNAPSHOT, isn't caused by
> me (since it is present int he demo app) and seems to originate from
> something on the client-side (obviously).
>
> Does anyone have a solution to this problem, or if not, can I make a
> fork of the widgets module, try to fix the problem, and commit it
> back? This little inconvenience removes much of the visual quality of
> plots, so a solution to it would be very much appreciated.

I haven't looked in detail but: Is this a problem with the widget or the
Flot library? As far as I know, the widget is just a thin wrapper on top
of the Flot JS library. If it's a problem with the JS, you should
probably try to fix this upstream: http://code.google.com/p/flot/

/Jeppe

dflemstr

unread,
Jun 27, 2009, 4:40:01 AM6/27/09
to Lift
If this indeed is an upstream bug (I'll have to try to re-implement
the "Flot" object with an alternate resource file to check; annoying
that such things are hardcoded), then the only solution to it would be
to update the flot widget to a newer version anyways, so some work
needs to be done on the widget module whichever way you choose.

It appears, however, that you don't have the same problem? Is this the
case?

Oh, and by the way, is scala-tools.org down? Maven complains about it.

/dflemstr

On Jun 27, 9:50 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:

dflemstr

unread,
Jun 27, 2009, 5:10:13 AM6/27/09
to Lift
Follow-up on my other reply:
When using the latest Flot 0.5 version, the exact same bug appears
when using it with the widgets.flot module. I am absolutely certain
that I am loading the correct Flot JS files (I haven't shadowed the
old resource path, but instead forked the whole Flot widget library
and changed all of the paths in it). This bug appears in Firefox
(which is very serious) as well as in other browsers based on WebKit/
Gecko/KHTML.

As can be seen here: http://bit.ly/13EEnw , the bug isn't present in
the vanilla Flot library.

I am at a loss to find the bug causing all this. The whole Flot widget
seems to be very messy (it consists of 30% commented-away code, for
instance) and I would be happy to help improve it once and for all,
since I'm in need of the Flot library for a project.

On Jun 27, 9:50 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:

Jeppe Nejsum Madsen

unread,
Jun 27, 2009, 10:14:03 AM6/27/09
to lif...@googlegroups.com
On Sat, Jun 27, 2009 at 11:10 AM, dflemstr<david.f...@gmail.com> wrote:
> As can be seen here: http://bit.ly/13EEnw , the bug isn't present in
> the vanilla Flot library.

Make sure you're trying to plot the same data with the same plot options.....

> I am at a loss to find the bug causing all this. The whole Flot widget
> seems to be very messy (it consists of 30% commented-away code, for
> instance) and I would be happy to help improve it once and for all,
> since I'm in need of the Flot library for a project.

I'm basically in the same boat and will probably clone the
lift-widgets module on github and work from there (I'm not a Lift
committer). I hope Francois will then commit the changes to Lift at
some point :-) I think we should coordinate the effort to avoid
wasting resources. Let me know what you think....

/Jeppe

Timothy Perrett

unread,
Jun 27, 2009, 11:46:17 AM6/27/09
to lif...@googlegroups.com

Guys,

If you want changes made to the flot widgets, please let us know what
exactly needs changing and we'll get it done. By all means, please don't
feel you are out in the cold!

Cheers, Tim

dflemstr

unread,
Jun 27, 2009, 3:05:57 PM6/27/09
to Lift
> Make sure you're trying to plot the same data with the same plot options.....

Well, that's an easy one, since the bug appears in all graphs with
legends, everywhere.

> I'm basically in the same boat and will probably clone the
> lift-widgets module on github and work from there (I'm not a Lift
> committer). I hope Francois will then commit the changes to Lift at
> some point :-) I think we should coordinate the effort to avoid
> wasting resources. Let me know what you think....
>
> /Jeppe

The beauty of GitHub is that you can just fork the repository, and
send a fork merge request when you're done. No one who has commit
access needs to review your code, but instead simply accept your
request. I think that that's what I'll do.

Oh, and I have the solution to the problem (and it's something really,
really stupid):
The default Bluetype CSS theme, in the screen.css file, has a "width:
100%;" attribute in a raw "table" selector. This is what causes the
problem.
If I only had had FireBug earlier...
To fix the bug, we need to create a stylesheet for Flot that resets
some options. If someone with repository access will pull my fork
afterwards, I'll make one (and clean up a little of the Flot code
while I'm at it). Otherwise, I would be happy if someone simply would
fix this issue; it just requires adding this to a CSS file of choice
(where the-graph-id is inserted dynamically):

#the-graph-id .legend table {
width: auto !important;
}

Still, the bug remains with the legend issues; it's not possible to
have an external legend for some reason.

Jeppe Nejsum Madsen

unread,
Jun 28, 2009, 3:46:28 AM6/28/09
to lif...@googlegroups.com
On Sat, Jun 27, 2009 at 5:46 PM, Timothy Perrett<tim...@getintheloop.eu> wrote:
>
>
> Guys,
>
> If you want changes made to the flot widgets, please let us know what
> exactly needs changing and we'll get it done. By all means, please don't
> feel you are out in the cold!

Hi Tim,

Personally, I don't feel left out in the cold :-) On the contrary,
people in this community seem very willing to listen to (and
implement) requests for new functionality.

On the other hand, I realize that my issues are not necessarily top
priority for others. So I'm willing to spend some time to fix my
issues (since I need them fixed now) and share the changes back where
possible.......

/Jeppe

Francois Bertrand

unread,
Jun 28, 2009, 12:42:18 PM6/28/09
to Lift
David:

Thanks for reporting this. I will put your solution in:

- jquery.flot.css that defines a new CSS class named "flot_lww"

- Flot.scala where the Flot.render method will generate a call to
jQuery ("#idPlaceHolder").addClass ("flot_lww") to make the solution
transparent to the HTML designer

I agree that the code is messy: the commented part are mine and dpp
(the creator of lift) replaced it in a more LiftWeb oriented way.
Please don't delete the comments yet, it's a very good way for me to
learn Lift's JsExp and JsCmds and Scala!

I hope to commit the changes today (after some QA test in Windows
browsers) and then looked at why the rest of the flotDemo webapp is
broken.
Reply all
Reply to author
Forward
0 new messages