[Dojo-interest] Need to update data in a chart

John F. Walsh walsh159 at gmail.com
Tue Dec 5 19:34:15 MST 2006


Tom or others,

Thanks. I've got the Chart working. Now I'm wondering how much (or how
little) I need to do update it with new data. I assume I don't want to throw
out and recreate the whole Chart at each update. I tried just the following,
and it didn't update the chart:

    store.setData(updatedJSONString);
    chart.render();

So, going into the Chart.js files, I saw the following:

   - render() uses "series" to render the data.
   - "series" is set by parseData(table)
   - postCreate() callse parseData(table), passing it the table it gets
   from this.domNode, which it later removes at the end of the function.
   So I can't just call postCreate(). I need to call something that sets
   this.domNode .

I'm stuck at that point. I can't see anything in the files or the inherited
files that sets this.domNode. I assume it's set by a different object
somewhere else.

If you could tell me how much I need to do when I have an updated JSON
string, or point me in the direction where I can find it, I'd appreciate it.


Thanks!
John


On 12/5/06, Tom Trenka <dojo-interest at dept-z.com> wrote:
>
>
> Short answer: don't use the Chart widget, but use the new charting engine
> in
> dojo.charting.  It was designed to be updateable on the fly from the
> ground
> up, while the Chart widget was designed to be a simple, static data view.
>
> You can take a look at the example at
> http://archive.dojotoolkit.org/nightly/tests/charting/test_engine.html to
> get started.  One thing to keep in mind: browsers still have limited
> resources when it comes to rendering large vector graphics, so you might
> want to test to see how much you can actually update something before you
> bring a browser to its' knees.
>
> trt
>
>
> John F. Walsh-2 wrote:
> >
> > Greetings,
> >
> > I'm trying to update a chart in the same way that I update a table. It
> > doesn't work because a chart gets converted to an svg node, so there is
> no
> > table for me to grab from the Document and update.
> >
> > Details:
> >
> > I've got a regular table that displays data that is updated regularly on
> a
> > server. The JavaScript regularly makes a server call (using dojo.io.bind
> )
> > to
> > retrieve the new data as a json string, removes all the old rows from
> the
> > table, and adds new rows with the new data. All this works fine.
> >
> > The real goal is to render that updating data feed in a chart (graph).
> > When
> > I code the following:
> >     <div dojoType="chart">
> >         <table id="myChart">
> >             ...
> > the table gets converted into an <svg> object (obviously necessary for
> > rendering), meaning that a call to document.getElementById ("myChart")
> > fails.
> > I don't get a table I can update, because it's been changed into an
> <svg>
> > object.
> >
> > What's the best way to update the chart? Should I remove it from the
> DOM,
> > programatically create a new one, and insert it into the DOM?
> >
> > I'm an experienced Java coder new to JavaScript and Dojo. I'll continue
> to
> > go through the source, but was hoping that someone could give me a quick
>
> > pointer.
> >
> > Thanks,
> > John
> >
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Need-to-update-data-in-a-chart-tf2761767.html#a7701281
>
> Sent from the Dojo mailing list archive at Nabble.com.
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20061205/f81f658c/attachment.html


More information about the Dojo-interest mailing list