Update table d3 with the new data in the Meteor collection after submitting the form

The My Meteor application is somewhat simple and displays a d3 diagram generated using the serverโ€™s calculated data stored in the newly inserted mongodb document:

  • the user fills in a simple form and presses the submit button
  • the server does some asynchronous work and calculates the intensity of calculations using form data
  • a new calculus document with two fields (formData and calculateResult) is inserted into the Calculi mongodb collection
  • SVG chart updated with new computed data

Despite reading an example of Meteor parties that uses d3, this tutorial on using d3 and Meteor to generate SVG and this screencast on how to create a reactive data source is really confusing! Itโ€™s hard for me to correctly understand the sources of reactive data, patterns and dependencies in Meteor.

It seems I cannot update the SVG charts after adding a new Calculus document.

Here is my question: what is a comprehensive, convenient for beginners way to automatically update the created d3 SVG diagram with the data calculated on the server, received after sending the form, which inserts the document into the collection?

+6
source share
1 answer

You either need the user to subscribe to the changes in the Calculi collection ( http://docs.meteor.com/#reactivity ), or if you are rendering into a user response template that you can do, and calling the update() method, which runs your d3 code. This will update your charts in terms of updating the d3 code.

0
source

All Articles