score:2

I suppose your question is high-level and in two parts. This is not a coding answer because your question is too high-level. We don't even know what type of back end you have access too.

Gather your data This part has nothing to do with d3.js and is dependent upon your back end. You need to show the user an HTML form with the question and possible answers to your survey. The form will post to your back end (asynchronously, perhaps) and persist the answer in some sort of a data store (usually a database).

Display your data You should have an endpoint in your web application for extracting the aggregate results from your survey. It should return the data in a form that can be read by JavaScript (JSON, perhaps?) so that you can reference it from your d3.js call to get the data. You can then use d3.js to display the data as a pie chart. If you have trouble writing your own pie chart, consider a boxed approach. You can also find examples of using the pie layout in d3.js.

If you can give us any more information, I'd be happy to expand upon this answer further.


Related Articles