Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

How to unregister callbackHandler and updateHandler

Answered
Yusuf Yildiz asked on September 2, 2020

Hi,
In our application, user has an option to switch between different highcharts types and I was able to achieve that using FlexmonsterHighcharts.getData.
However, I’m having a performance issue because not just the latest but all the previous updatehandlers are being called.
Basically if user sees, Line, Area, Column and Scatter in this order and then modifies Fields, updateHandler will be called for all chart types.
Is there a way to unregister updatehandler after I’m done with the chart type?
Best,
Yusuf 

5 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 3, 2020

Hello,
 
Thank you for writing to us.
 
We want to ask you for some details about the problem you are facing:

  • Do all chart types need to be displayed simultaneously, or a single chosen chart must be shown?
  • Do charts need to be updated after changes in the pivot’s configuration?
  • Please provide us with a corresponding sample that would demonstrate the issue. It would allow us to come up with the best solution for you.

 
If the chart does not need to be updated after changes in Flexmonster configuration, we recommend not to specify the updateHandler parameter of the getData API call. In such a case, the data from Flexmonster will be passed to the chart once after the getData execution.
Next, if the specific chart instance needs to be synchronized with Flexmonster, subscribe to the reportchange event. Execute the getData method each time the event is triggered. The updateHandler should not be specified as well. If synchronization is not required anymore, unsubscribe from the event using the off API call.
 
Our team is looking forward to hearing details from you.
 
Best regards,
Illia

Public
Yusuf Yildiz September 15, 2020

Hi Illia,
My answers

  • Do all chart types need to be displayed simultaneously, or a single chosen chart must be shown?

ONE CHART AT A TIME

  • Do charts need to be updated after changes in the pivot’s configuration?

YES

  • Please provide us with a corresponding sample that would demonstrate the issue. It would allow us to come up with the best solution for you.

It sounds like I may still need the  updateHandler . Because if user changes the pivot configuration through flex monster menus, I need to be updating the chart which is already in display.
I do this often currently. I open my Highcharts and then modify fields, column order etc. The chart reacts to those changes since updateHandler is registered.
Does reportchange event get triggered when configuration changes? Or in other words, can I get away without having updateHandler for my scenario?
I’m gonna give it a try in the meantime but an answer would be appreciated.
Best,
Yusuf

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 15, 2020

Hello, Yusuf,
 
Thank you for your feedback and for providing additional details.
 
You are right about the fact that the reportchange event is triggered every time the configuration of the pivot is changed. It means the updateHandler function can be replaced with a corresponding handler bounded on the reportchange event.
 
We have prepared a sample demonstrating the described approach.
 
Please let us know if it works well for your case.
Do not hesitate to contact us in case any further questions arise.
 
Best regards,
Illia

Public
Yusuf Yildiz September 16, 2020

Thanks, Illia. I verified that this approach works.
Just one question:
pivot.off(“reportcomplete”);
What’s the benefit of unregistering reportcomplete event?

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 17, 2020

Hello,
 
Thank you for your feedback.
 
We want to explain that it is considered a good practice to unsubscribe from the reportcomplete event after it is triggered. It allows avoiding unexpected behavior after loading new reports or changing the current one.
 
Please let us know if other questions arise.
 
Best regards,
Illia

Please login or Register to Submit Answer