 
   componentWillUnmount: ->
     # Remove the extra HTML that Chart.js creates.
-    chartInstances["barChart"].destroy()
-    chartInstances["pieChart"].destroy()
+    @state.barChartInstance.destroy()
+    @state.pieChartInstance.destroy()
 
   # Find the canvas nodes and create charts.
   drawCharts: ->
-    canvas = React.findDOMNode(@refs.bar)
+    canvas = React.findDOMNode(@refs.barChart)
     ctx    = canvas.getContext("2d")
-    chartInstances["barChart"] = new Chart(ctx).Bar(@dataForBarChart())
+    @state.barChartInstance = new Chart(ctx).Bar(@dataForBarChart())
 
-    canvas = React.findDOMNode(@refs.chart)
+    canvas = React.findDOMNode(@refs.pieChart)
     ctx    = canvas.getContext("2d")
-    chartInstances["pieChart"] = new Chart(ctx).Pie(@dataForPieChart())
+    @state.pieChartInstance = new Chart(ctx).Pie(@dataForPieChart())
 
   shuffleArray: (o) ->
     i = o.length

          R.div
            className: 'col-sm-6'
            React.createElement BarChartCanvas,
              ref: "bar"
          R.div
            className: 'col-sm-6'
            React.createElement PieChartCanvas,
              ref: "chart"

  totalVolume: ->
    sum = 0

    React.DOM.canvas
      style: { height: 200, width: 400 }


@MovingRecordsApp = React.createClass

  getInitialState: ->
    records: @props.data
    ajax:    false
    barChartInstance: null
    pieChartInstance: null

  getDefaultProps: ->
    records: []
