PDA

View Full Version : I need to prevent a chart update.



jeff.o.taylor
27 Jun 2012, 11:30 AM
Sorry if I'm not wording this properly but basically what I need is to prevent a pie chart from re-drawing when its store is updated.

I have a pie chart ("Pie") that is tied to a store ("PieStore"). I have a service that updates PieStore, but this data needs to be filtered before Pie is redrawn. What I end up seeing is two pie charts in the same space - one with the full set of data, and the other with filtered data. If I do basically anything on the page after it has loaded (reposition the container of Pie, for example), it displays properly - though that is obviously a poor user experience. Is there a way to prevent Pie from drawing until after I have filtered PieStore? I've tried things like Pie.hide() before messing with PieStore and then Pie.show() after, but nothing changed.

Note that I'd like to keep the complete set of data in PieStore - this would save me time if I need to change the filter on the fly.

My current work-around is to use a 2nd array store ("CurrPie") that has the same structure as PieStore but is only loaded with filtered values. There ought to be a way to do this without the extra object though...



this._pieStore.loadData(/*complete set of data returned by service*/); //this causes the redraw that I want to prevent
this._pieStore.filterBy( function(record) {
if (/*insert generic filter condition*/)
{
return true;
}
return false;
}, this);


Thanks in advance!
Jeff

scottmartin
27 Jun 2012, 12:39 PM
Try using store.suspendEvents / resumeEvents

Scott.

jeff.o.taylor
27 Jun 2012, 12:47 PM
Unfortunately, this is something that I had already tried. PieStore.suspendEvents appears to have no effect whatsoever - even if I never use PieStore.resumeEvents, it still displays the unfiltered data pie chart on top of the filtered one.

scottmartin
27 Jun 2012, 7:12 PM
It would be helpful if you could create a small example we can use to test this using array or json file for data.

Regards,
Scott.

stimpy
28 Jun 2012, 4:47 AM
Jeff

IMO try cloning or copying the store data you want to be static to a new store then display that new store.

Thereafter updates to the "original" store will not be reflected in the chart.

jeff.o.taylor
28 Jun 2012, 7:31 AM
Jeff

IMO try cloning or copying the store data you want to be static to a new store then display that new store.

Thereafter updates to the "original" store will not be reflected in the chart.

Yes, this is my current workaround that I had mentioned. It works, but it is probably not the best solution. I'd rather not use an extra object if I don't have to, and I have the time to spend to get a proper solution - projects without deadlines are pretty awesome. :) Also, it'd be awfully convenient (and probably faster) to redraw the pie with a 1 liner to change the filter on the store.

I'll try to get a barebones example of what I am trying to do sometime today.

stimpy
28 Jun 2012, 10:48 AM
IMO

I would rather have an extra object and use proven methods for moving data into and out of stores then something I whipped up....all to save one measly object .

If your objects are that big then ( in my opinion) you are doing something wrong .

Another idea would be to filter the data server side before putting it in the store .