anchor.diff:  
   visits_donut = Morris.Donut({
     element: 'visits_donut',
  -  data: <%=@data[:week][:visits_new_visits_donut].to_json%>
  +  data: <%=@data[@range][:visits_new_visits_donut].to_json%>
   });
   
   traffic_donut = Morris.Donut({
  
positive.code: visits_area = Morris.Area({
    element: 'visits_area',
    xkey: 'date',
    data: <%=@data[:week][:visits_new_visits_plot].to_json%>,
    ykeys: ['new_visits', 'returning_visits'],
    labels: ['New Visits', 'Returning Visits'],
    ymax: 'auto',
  
negative.code: 
  });
  
  // visits_spark = Morris.Line({
  //   element: 'visits_spark',
  //   xkey: 'date',
  //   data: <%=@data[@range][:visits_page_views_plot].to_json%>,
  //   ykeys: ['visits', 'page_views'],
  //   labels: ['Visits', 'Page Views'],
  //   xLabelFormat: function(x){return '';},
  //   yLabelFormat: function(x){return '';},
  //   hoverCallback: function(i,x){return x.data[i].date + '<br/>' + 'Page Views: ' + x.data[i].page_views + '<br/>Visits: ' + x.data[i].visits;},
  //   ymax: 'auto',
  //   ymin: 0,
  //   smooth: true,
  //   hideHover: 'auto',
  //   parseTime: false,
  //   lineWidth: 2,
  //   pointSize: 0,
  //   grid: false,
  //   pointFillColors: ['#fff'],
  //   pointStrokeColors: ['#000']
  // });
  
  function setSessionCookie(name,value) {
      document.cookie = name+"="+value+"; path=/";
  }
  
  function changeTimeFrame(range)
  {
  switch(range)
  {
  case 'day':
      setSessionCookie("_rarng", "day");
      visits_area.setData(<%=@data[:day][:visits_new_visits_plot].to_json%>);
      unique_visits_line.setData(<%=@data[:day][:unique_visits].to_json%>);
  
      $("#total_visits")[0].innerHTML = '<%=@data[:day][:total_visits]%> <small class="muted">visits</small>';
      $("#total_page_views")[0].innerHTML = '<%=@data[:day][:total_page_views]%> <small class="muted">page views</small>';
      $("#page_depth")[0].innerHTML = '<%=(@data[:day][:total_page_views].to_f/@data[:day][:total_visits].to_f).round(2)%> <small class="muted">page per visit</small>';
  
      $("#bounce_rate")[0].innerHTML = '<%=(((@data[:day][:total_visits].to_f-@data[:day][:total_second_page_views].to_f)/@data[:day][:total_visits].to_f)*100).round(2)%>% <small class="muted">bounce rate</small>';
      $("#visit_duration")[0].innerHTML = '<%=Time.at(@data[:day][:avg_visit_time].round(2)).gmtime.strftime("%R:%S")%> <small class="muted">avg time spent</small>';
      $("#new_visits")[0].innerHTML = '<%=((@data[:day][:total_new_visits].to_f/@data[:day][:total_visits].to_f)*100).round(2)%>% <small class="muted">new visits</small></h4>';
      $("#compare_unit")[0].innerHTML = 'day';
  
      visits_donut = Morris.Donut({element: 'visits_donut', data: <%=@data[:day][:visits_new_visits_donut].to_json%>});
      browsers_donut = Morris.Donut({element: 'browsers_donut', data: <%=@data[:day][:browsers_donut].to_json%>});
  
      break;
  case 'week':
      setSessionCookie("_rarng", "week");
      visits_area.setData(<%=@data[:week][:visits_new_visits_plot].to_json%>);
      unique_visits_line.setData(<%=@data[:week][:unique_visits].to_json%>);
  
      $("#total_visits")[0].innerHTML = '<%=@data[:week][:total_visits]%> <small class="muted">visits</small>';
      $("#total_page_views")[0].innerHTML = '<%=@data[:week][:total_page_views]%> <small class="muted">page views</small>';
      $("#page_depth")[0].innerHTML = '<%=(@data[:week][:total_page_views].to_f/@data[:week][:total_visits].to_f).round(2)%> <small class="muted">page per visit</small>';
  
      $("#bounce_rate")[0].innerHTML = '<%=(((@data[:week][:total_visits].to_f-@data[:week][:total_second_page_views].to_f)/@data[:week][:total_visits].to_f)*100).round(2)%>% <small class="muted">bounce rate</small>';
      $("#visit_duration")[0].innerHTML = '<%=Time.at(@data[:week][:avg_visit_time].round(2)).gmtime.strftime("%R:%S")%> <small class="muted">avg time spent</small>';
      $("#new_visits")[0].innerHTML = '<%=((@data[:week][:total_new_visits].to_f/@data[:week][:total_visits].to_f)*100).round(2)%>% <small class="muted">new visits</small></h4>';
  
      visits_donut = Morris.Donut({element: 'visits_donut', data: <%=@data[:week][:visits_new_visits_donut].to_json%>});
      browsers_donut = Morris.Donut({element: 'browsers_donut', data: <%=@data[:week][:browsers_donut].to_json%>});
      $("#compare_unit")[0].innerHTML = 'week';
  
      break;
  case 'year':
      setSessionCookie("_rarng", "year");
      visits_area.setData(<%=@data[:year][:visits_new_visits_plot].to_json%>);
      unique_visits_line.setData(<%=@data[:year][:unique_visits].to_json%>);
  
      $("#total_visits")[0].innerHTML = '<%=@data[:year][:total_visits]%> <small class="muted">visits</small>';
      $("#total_page_views")[0].innerHTML = '<%=@data[:year][:total_page_views]%> <small class="muted">page views</small>';
      $("#page_depth")[0].innerHTML = '<%=(@data[:year][:total_page_views].to_f/@data[:year][:total_visits].to_f).round(2)%> <small class="muted">page per visit</small>';
  
      $("#bounce_rate")[0].innerHTML = '<%=(((@data[:year][:total_visits].to_f-@data[:year][:total_second_page_views].to_f)/@data[:year][:total_visits].to_f)*100).round(2)%>% <small class="muted">bounce rate</small>';
      $("#visit_duration")[0].innerHTML = '<%=Time.at(@data[:year][:avg_visit_time].round(2)).gmtime.strftime("%R:%S")%> <small class="muted">avg time spent</small>';
      $("#new_visits")[0].innerHTML = '<%=((@data[:year][:total_new_visits].to_f/@data[:year][:total_visits].to_f)*100).round(2)%>% <small class="muted">new visits</small></h4>';
  
      visits_donut = Morris.Donut({element: 'visits_donut', data: <%=@data[:year][:visits_new_visits_donut].to_json%>});
      browsers_donut = Morris.Donut({element: 'browsers_donut', data: <%=@data[:year][:browsers_donut].to_json%>});
      $("#compare_unit")[0].innerHTML = 'year';
      break;
  }
  }
  