Bryan,

In CometActors, there's a "partialUpdate" method which sends JavaScript to
the client.  Using a simple example, if you have a JavaScript Array
"theData" that has the points for plotting and a JavaScript function called
"updateGraph()" which re-plots the graph based on the contents of theData,
you could do something like:

val newPoints: List[Int] = ...
val updates: List[JsCmd] = newPoints.map(p => JsRaw("theData.shift()") &
JsRaw(" theData.push("+p+")"))
val update: JsCmd = updates.foldLeft[JsCmd](Noop)(_ & _)
partialUpdate(update & JsRaw("updateGraph()")

The above code takes the new data points puts them in "theData" and then
calls updateGraph() to redraw the graph.

Does this help?

Thanks,

David

On Sun, Sep 21, 2008 at 7:41 AM, Bryan <[EMAIL PROTECTED]> wrote:

>
> Yes, I plan on sharing all of the knowledge that I learn from this in
> either the wiki or a blog entry.  What I'm trying to do is tail my log
> files and send them to lift via AMQP.  lift will then parse each log
> line (which contain some statistical information) and plot them every
> 5 seconds.
>
> lift has an AMQP listener which sends a message to my Stats actor.
> The following is a snippet of code in that Stats object (with that
> code snipped out to make this message shorter).  This code assumes
> that flot can maintain history, so I am trying to push 5 seconds worth
> of Map data to the graph every 5 seconds.  This is just sample code
> and the map won't be empty in actuality, but it will be created with
> default keys and values.
>
> def notifyListeners(newStat: Map[String, (Int, Long)]) = {
>  listeners.foreach(_ ! UpdateStats(newStat))
> }
>
> def act = loop(new EmptyMap[String, (Int, Long)])
>
> def loop(map: Map[String, (Int, Long)]) {
>  react {
>    // ... snip ...
>    case Push =>
>      notifyListeners(map)
>      ActorPing.schedule(this, Push, 5000L)
>      loop(new EmptyMap[String, (Int, Long)])
>  }
> }
>
> start
> ActorPing.schedule(this, Push, 5000L)
>
> On Sep 21, 9:58 am, "David Pollak" <[EMAIL PROTECTED]>
> wrote:
> > On Sat, Sep 20, 2008 at 5:16 PM, Bryan <[EMAIL PROTECTED]> wrote:
> >
> > > I am interested in adding some (almost) real-time charts to a project
> > > of mine.  I have a couple of questions, though.
> >
> > > 1) Is there documentation on lift's server and client implementation
> > > of comet available online?
> >
> > None that I'm aware of, but I certainly hope you'll make wiki entries
> based
> > on this exchange.
> >
> >
> >
> > > 2) Are there any reasons why dojo's comet client wasn't considered?
> >
> > Because Dojo is yet another JavaScript library and the goal is to have
> fewer
> > absolute dependencies (Lift can currently be used with YUI and jQuery
> thanks
> > to Marius' work.)  Layering Dojo in would have been more complexity for
> very
> > little gain.
> >
> >
> >
> > > 3) I see that there is a flot widget that will be integrated into lift
> > > soon.  What benefits do these widgets offer over a normal JavaScript
> > > implementation?
> > > 4) I have an immutable Map of data that I need to "push" to the JQuery
> > > chart.  Where should I begin?  Do I send this in JSON format?
> >
> > Do you want to push the whole map or deltas of the map?
> >
> > I'll put together some examples when I better understand what you want to
> > do.
> >
> > Thanks,
> >
> > David
> >
> >
> >
> > > A lot of questions, I know!
> >
> > > p.s. I am loving lift so far.  Great work.  The CometActor tutorial
> > > was very useful as well.
> >
> > > Thanks,
> > > Bryan
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Collaborative Task Managementhttp://much4.us
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

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

Reply via email to