2 Replies Latest reply on Feb 12, 2015 3:06 AM by Peter Williams

    rememberCustomViewAsync running slow

    Peter Williams

      I am trying to implement history functionality using the JavaScript API to allow the user to undo their last action and restore the Viz to a previous state. To do this I am using the rememberCustomViewAsync method (See code below). The code works but when the API call is made it takes approx 9 seconds to complete and shows the waiting spinner over the viz. This prevents the user from any further interactions with the Viz until it completes. Is this the right approach to save states and to reapply them? Also, I thought the call was asynchronous so the displayed Viz would not be affected.


      saveCustomView: function(name) {
        mainWorkbook = agora.vizfuncs.mainViz.getWorkbook();
        var onSuccess = function(view) {
        newCustomView = view; 
        var onError = function(err) {
        mainWorkbook.rememberCustomViewAsync(name).then(onSuccess, onError); 
        • 1. Re: rememberCustomViewAsync running slow
          Russell Christopher

          Hey Peter -


          When a custom view is created, you're actually saving a diff of the viz as a BLOB (representing changes the user made) into the Server - so you're doing a lot of unnecessary work on the "server side" to get from A to B - not optimal.


          I understand why you'd go down this route...it's nice and straight forward. However, I think you'll see much better performance if you lean on the JSAPI events to track user changes to filters/parameters and store them in an multi-dimensional array that can be re-applied at will.


          This won't allow you to track changes to SORTING, but it'll be much faster.


          Hope this helps a little.

          1 of 1 people found this helpful
          • 2. Re: rememberCustomViewAsync running slow
            Peter Williams

            Thanks Russell,


            To be honest I tried that approach initially and dropped it in favor of the rememberCustomViewAsync. That approach seemed much simpler.


            I was running into problems with the tracking of filters as it stored all filters on change rather than updated ones, and repeated the process for each worksheet unnecessarily.I ended up putting a setTimeout to intercept the repeats and run only once. 


            It would be good if there was a getState() and setState method that allowed me to fetch a current Viz's state and set it again later.


            I'll go back to the parameter & filter change approach and report back here when I have something working with good performance.