0

As it stands I have a jade file that I pass data from js files into. I then have the jade file require a js file that handles the d3 code.

I do not think this is the proper way to do this, but I do not want to be pulling data from monogo in the public js file because it is visible to the user.

If your slightly confused by my question the project and structures are here: https://github.com/rdecuir/NodeJSGraphics

I am trying to learn the best practices and structures, but have yet to find anything that makes sense in a structured way, I do not want to have script code in the jade file, nor do I want the data to be pulled in my d3 file because its exposed to the user.

JediKid
  • 83
  • 2
  • 9

1 Answers1

0

Is the challenge that you want to use d3 to render the data, but not download the data to the browser because it need be kept proprietary? If so, two options are:

  • Render the visualization server side, and download as an image.
  • Render the visualization in the browser, but download only the data thats necessary.

D3 can be used in Node.js and there are other good reasons to render images server side, but the first option is probably more complex than necessary here. And you do want to present at least some data to the user, which is why you're drawing the Pie Chart.

So in Node, the server queries Mongo, and constructs a minimal dataset that's sufficient to draw the Pie Chart, but excludes confidential information.

You can pass the data to d3 either via Ajax (i.e. render page and have it then call for the data e.g. using d3.csv()) or embed the data in the template (e.g. Passing an object to client in node/express + ejs?)

Community
  • 1
  • 1
prototype
  • 7,249
  • 15
  • 60
  • 94