Run git clone https://github.com/newamerica-graphics/data-viz-boilerplate.git
.
Before starting to build, run npm install
and change the git origin git remote set-url origin https://github.com/newamerica-graphics/REPOSITORY.git
.
- Define all chartIDs that will be referenced in wagtail inside webpack.config.js
- Create a .env file in the root of this directory with entries for
AWS_ACCESS_KEY
andAWS_SECRET_KEY
. - Build your graphic any way you like
- Inside
src/index.js
define initialization functions for each graphic. It may look somethings like this:
var settings = {
"id-for-chart1": chart1init,
"id-for-chart2": chart2init
};
window.renderDataViz = function(el) {
let id = el.getAttribute(id);
if (settings[id]) settings[id](el);
};
newamericadotorg
looks for any element with the class .na-dataviz
, and if a renderDataViz
function is defined globally, calls it for each element. You can see a mock of what happens in the index.html file.
-
React
,ReactDOM
,ReactRedux
, andRedux
are all globally scoped on newamerica.org, and defined as externals within this repo's webpack config. There is no need to install or bundle those dependencies if the graphic will exist exclusively on newamerica.org. -
Critical styles from newamerica.org are included in the head. This includes all fonts and type styles, bootstrap columns, margins, and containers.