In my current project, I am facing a challenge where I need to present data in a dashboard both as a chart using the perak:c3 package and as a table using the aslagle:reactive-table package. The issue arises because the data is retrieved from a MongoDB collection in a format that works well with c3 for plotting but needs to be converted into a local collection for use with reactive-table, as mentioned in this previous question's answer.
Whenever I update the dataset to be displayed, I expect both the chart and the table to reflect these changes. However, altering the values in the local collection causes a delay, resulting in a freeze on the page before the updated data is shown.
To easily replicate the problem, I have set up a sample project on GitHub here. By selecting a dataset in your browser, you can experience firsthand what I am describing.
https://i.sstatic.net/BgxTY.png
To observe the desired reactive behavior in the chart, visit client/templates/dashboard/dashboard.html and comment out the table template {{> dashboardTable}}
https://i.sstatic.net/XFdLU.png
Then, switch the dataset to witness how the chart smoothly updates without any freezing. My goal is to ensure that both templates, dashboardChart and dashboardTable, render independently of each other.
UPDATE
After taking Michael Floyd’s advice to introduce a timeout, there was some improvement, observed via the following code snippet:
Meteor.setTimeout(function(){createLocalCollection(data)},200);
However, while the chart redraws smoothly, once the table population completes, the chart undergoes another drawing process. It seems like it transitions to an intermediate state that is unclear to me. A video showcasing this phenomenon can be viewed here.