This page explores the rendering of a horizontal bar chart in NVD3, based on survey response data from the Pew Research Center’s Internet & American Life Project, “The Social Side of the Internet”. Permission to use the survey data was granted by the Pew Research Center’s Internet Project December 2013.

The charts were created in R using rCharts, survey, and shiny packages, and summarize the types of social groups in which female and male respondents reported being active.

Some notes on getting nv.d3.js to run in WordPress

This site was originally developed in WordPress, then re-built from scratch. This is one of the pages involving interactive charts that was successfully rendered in WordPress. The usual solutions to running javascript in WordPress pages (template files , WP-D3, and Raw HTML ) did not work for nv.d3.js. I found a solution initially created for inserting Google Charts into Wordpress that has been used to successfully render this chart within WordPress. If using WordPress, with the exception of the div tag in the rChart template, all of the javascript used to create the chart can be inserted into the header of using the Per page add to head plugin.

Two modifications to the rCharts output template

1. Replace the jquery function $(document).ready(function() { with jQuery(document).ready(function($) {

2. My output (insert version of rCharts) came with .tooltip option. Tooltips were refactored in nvd3 version 1.8.1, so I customized the tooltips by inserting the chart.tooltip.contentGenerator function right before the d3-selection call. Here's the fiddle.

Social Group Activity among Male Respondents

Tip: Click on DNK and Ref before stacking

Social Group Activity among Female Respondents

Tip: Click on DNK and Ref before stacking