function ChartManager(C,B,A){this.pagemgr=B;this.chart=C;this.sesh=A}ChartManager.prototype.refresh2=function(){var B,A,D;for(B=0;B<this.pagemgr.layerGroups.length;B++){var C=this.pagemgr.layerGroups[B];D=C.getModel();A=C.u;console.log(A,Json.toString(D));this.chart.render(Json.toString(D),A)}};ChartManager.prototype.refresh3=function(){var C,A,G;var H=[];var F=[];for(C=0;C<this.pagemgr.layerGroups.length;C++){var E=this.pagemgr.layerGroups[C];G=E.getModel();console.log("payload:",Json.toString(G));A=E.u;console.log(A,Json.toString(G));F.push([A,Json.toString(G)]);H.push([A,G])}this.chart.invalidate();try{console.log("payload to send",F);this.chart.renderAll(Json.toString(F))}catch(D){console.log("exception",D)}var B=new Ajax("/cbi/maptool/setChartSession",{method:"post",data:Json.toString([$time(),this.sesh,H])});B.request()};ChartManager.prototype.makeModelIterator=function(){};ChartManager.prototype.refresh=function(){var E,D,C,H,B,G;var A=0;for(E=0;E<this.pagemgr.layerGroups.length;E++){H=this.pagemgr.layerGroups[E];for(D=0;D<H.layers.length;D++){B=H.u+"_"+H.layers[D].id;var F=H.layers[D].foo();if(!F){Log.logDebug("skipping "+B+", incomplete object");continue}F["dataset"]=H.u;G=[B,F];Log.logDebug(JSON.stringify(G));Log.logDebug("rendering key: "+B+", "+JSON.stringify(F));this.chart.render(Json.toString(F),B);F["z-layer"]=A;this._updateSession(B,F);A++}}};ChartManager.prototype._updateSession=function(B,A){var C="/cbi/maptool/updateChartSession";var D=[this.sesh,B,A];new Ajax(C,{data:JSON.stringify(D)}).request()};ChartManager.prototype.show=function(B){var A=B.parent.u+"_"+B.id;Log.logDebug("showing key: "+A);this.chart.setEnabled(A,true)};ChartManager.prototype.hide=function(B){var A=B.parent.u+"_"+B.id;Log.logDebug("hiding key: "+A);this.chart.setEnabled(A,false)};ChartManager.prototype.remove=function(B){var A=B.parent.u+"_"+B.id;Log.logDebug("removing key: "+A);this.chart.remove(A)};var ChartTiles=new Class({initialize:function(B,A){this.chart=B;this.data=A;this.num_tries=0;this.max_tries=10},load:function(){this.attemptrender()},attemptrender:function(){if(this.num_tries>this.max_tries){console.log("not trying again; could not get it to work");return }try{var B=[];var B=this.data.map(function(C){return[C[0],Json.toString(C[1])]});this.chart.renderAll(Json.toString(B));if(this.num_tries>0){console.log("succeeded rendering after",this.num_tries,"retries")}}catch(A){this.num_tries++;console.warn("renderAll failed; trying again in half a second");this.attemptrender.delay(500,this)}}})
