Improving lift-flot

2 views
Skip to first unread message

Peter Robinett

unread,
Nov 23, 2009, 4:06:14 PM11/23/09
to Lift
I've been working with lift-flot a lot recently and I'd like to share
some thoughts and suggest some improvements. It's a very useful
interface to a great Javascript plotting library, so consider these as
small suggestions from a fan.

First, the fact that FlotSerie's data property is a List[Pair[Double,
Double]] means that detail about what you're charting can get lost. If
you're plotting more than one line and want to refer to a certain
FlotSerie later, you have to rely upon the FlotSerie's label and the
order of the List[FlotSerie] used by Flot.render and JsFlotAppendData.
This can be addressed either by having a parallel list of your own
more expressive data instances, which is what I'm doing, or by only
having this more expressive list and having an implicit conversion to
a Pair[Double, Double] (I just thought of this and haven't tested it).
I can't think of a better way to do this, since everyone's data source
will be different and so the generic Pair[Double, Double] is needed –
this is just a comment on how the library works.

There is a general reliance on List[Pair[Double, Double]] throughout
lift-flot and it is an actual annoyance when you are updating an
existing graph, for instance via a Comet actor. Speaking of the List
[FlotSerie] I mentioned earlier, if you are updating your chart you
need to keep this list of series around and update it as you have new
data to plot. This is fine except for the fact that JsFlotAppendData
requires you to pass it both the updated List[FlotSerie] and a List
[Pair[Double, Double]] with one and only one new data point for each
FlotSerie. This means that you need to hard-code the list order so
that the order of the List[Pair[Double, Double]] matches that of the
List[FlotSerie], so that the correct series is updated with the
correct new point. I assume you need to give it the new data twice so
it knows which FlotSeries have new points and which don't, but this is
something the library could do behind the scenes to make the
developers' lives easier. More importantly, I don't like the fact that
the method replies upon two lists being in the exact same order.

So, what would I like to see with lift-flot? Mainly I'd like to see
the whole situation with the List[Pair[Double, Double]]'s improved. I
don't know if another Flot class, such as a FlotPoint, would help or
maybe just making better use of the List[FlotSeries], but I think
there definitely is room for improvement. If someone else has been
using lift-flot I'd love to hear their suggestions, as perhaps I've
been making it more complicated than it actually is.

I think a lot of the annoyances I described only crop up when using
the JsFlotAppendData method, so I don't won't to propose anything that
ends up being a regression for the majority of the library's users.
Please let me know if you're doing static charts and anything
suggested would make your work more complicated.

Since I am using lift-flot a lot (perhaps more than anyone else,
seeing how little it's been discussed here recently), I'm more than
happy to take the lead and contribute some code if others agree that
my suggestions are reasonable (please convince me otherwise!). I guess
that the first thing I could do would be to write a tutorial on using
the library. Would that be appreciated?

Peter Robinett

PS I've been working with 1.1-M5 and 1.1-M6, but I don't think there
have been any changes to lift-flot since then, let alone any that
would invalidate my comments.

Jeppe Nejsum Madsen

unread,
Nov 24, 2009, 3:57:01 AM11/24/09
to lif...@googlegroups.com
Peter Robinett <pe...@bubblefoundry.com> writes:

> I've been working with lift-flot a lot recently and I'd like to share
> some thoughts and suggest some improvements. It's a very useful
> interface to a great Javascript plotting library, so consider these as
> small suggestions from a fan.
>

I had some of the same concerns as you a while back. I ended up writing
a wrapper to the JqPlot library instead since it better matched the
features we needed.

But the inner workings are about the same, so maybe you can use some of
the ideas. I'm mainly using category plots with name/value pairs.

I have basic structure for a single series:

class CategorySeries[T](val categories : List[T], val values :
List[Double], val name : Option[String])

And a complete dataset:

class CategoryDataset[T](val series : List[CategorySeries[T]], val name:
Option[String])

I then defined several different plot types that "do the right thing"
with respect to the dataset:

class BarChart[T] (dataset: CategoryDataset[T])
class StackedBarChart[T] (dataset: CategoryDataset[T])
class PieChart[T] (dataset: CategoryDataset[T])

etc

I haven't made any partial updates so don't know how well this works
here :-)

/Jeppe

David Pollak

unread,
Nov 24, 2009, 5:26:00 PM11/24/09
to lif...@googlegroups.com
I'm all for enhancing the flot stuff.

Do I see anyone raising their hand to own the changes?


--

You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.





--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Peter Robinett

unread,
Nov 24, 2009, 5:28:39 PM11/24/09
to Lift
Thanks, Jeppe, it's interesting to see how you've approached it.

Peter

Peter Robinett

unread,
Nov 24, 2009, 6:59:34 PM11/24/09
to Lift
I'd be happy to but I'd appreciate some advice and guidance.

Peter

On Nov 24, 2:26 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890

Timothy Perrett

unread,
Nov 25, 2009, 5:10:33 AM11/25/09
to lif...@googlegroups.com
David,

Francois is still lurking - if changes are needed, just ping him a mail or IM and im sure he'd be happy to fix whatever peter wants.

Cheers, Tim
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages