var Chart;

var chart_data = chart_data || {
  "title":"PQ Statistics: stages time",
  "current_journey":[
    {
      "name":"Draft Answer",
      "time":"1.0"
    },
    {
      "name":"POD Clearance",
      "time":"2.0"
    },
    {
      "name":"Minister Clearance",
      "time":"3.0"
    },
    {
      "name":"Submit Answer",
      "time":"4.0"
    }
  ],
  "benchmark_journey":[
    {
      "name":"Draft Answer",
      "time":"4.0"
    },
    {
      "name":"POD Clearance",
      "time":"3.0"
    },{
      "name":"Minister Clearance",
      "time":"2.0"
    },{
      "name":"Submit Answer",
      "time":"1.0"
    }
  ]
};

(function() {
  'use strict';

  var barchart = {};
  barchart.labels = chart_data.current_journey.map(function(d) { return d.name; });
  barchart.datasets = [
    {
      label: "Current Journey",
      fillColor: "rgba(220,220,220,0.5)",
      strokeColor: "rgba(220,220,220,0.8)",
      highlightFill: "rgba(220,220,220,0.75)",
      highlightStroke: "rgba(220,220,220,1)",
      data: chart_data.current_journey.map(function(d) { return d.time; })
    },
    {
      label: "Benchmark Journey",
      fillColor: "rgba(151,187,205,0.5)",
      strokeColor: "rgba(151,187,205,0.8)",
      highlightFill: "rgba(151,187,205,0.75)",
      highlightStroke: "rgba(151,187,205,1)",
      data: chart_data.benchmark_journey.map(function(d) { return d.time; })
    }
  ];


  var ctx = document.getElementById("current").getContext("2d");
  var currentBarChart = new Chart(ctx).Bar(barchart, {
    scaleLabel: "<%=value%> hours",
    multiTooltipTemplate: "<%= datasetLabel %>: <%= value %> hours"
  });



})();

@@ -141,33 +141,33 @@
 ,%0A      %22time%22:%22
-1
+0
 .0%22%0A    %7D,%0A    %7B
@@ -203,33 +203,33 @@
 ,%0A      %22time%22:%22
-2
+0
 .0%22%0A    %7D,%0A    %7B
@@ -270,33 +270,33 @@
 ,%0A      %22time%22:%22
-3
+0
 .0%22%0A    %7D,%0A    %7B
@@ -332,33 +332,33 @@
 ,%0A      %22time%22:%22
-4
+0
 .0%22%0A    %7D%0A  %5D,%0A 
@@ -433,9 +433,9 @@
 e%22:%22
-4
+0
 .0%22%0A
@@ -495,9 +495,9 @@
 e%22:%22
-3
+0
 .0%22%0A
@@ -553,17 +553,17 @@
 %22time%22:%22
-2
+0
 .0%22%0A    
@@ -610,17 +610,17 @@
 %22time%22:%22
-1
+0
 .0%22%0A    

reset bar chart data to 0 if no object available