Highcharts.setOptions({
    global : {
        useUTC : false
    }
});

$('#load_test_history_chart').highcharts({
      chart: {
      },
      title: {
          text: 'Recent load test results and time'
      },
     xAxis: {
        categories: <%= raw @recent_build_times.collect{|x| x[:time].localtime.strftime('%Y-%m-%d %H:%M')}.inspect rescue [] %>
     },
	 yAxis: [ 
         {
 		  min: 0,  title: {  text: 'VU'  }, labels: { align: 'right'},  allowDecimals: false
         },
	    {
          min: 0,  title: {  text: 'Time (s)'  }, labels: { align: 'left'}, opposite: true
        }

      ],
      tooltip: {
		  shared: true,
      },
      plotOptions: {
          series:{
              turboThreshold:5000//larger threshold or set to 0 to disable
          }
      },
      series: [
  		{ 
              type: 'column',
  			name: "VU",
  			yAxis: 0,
  			// dashStyle: 'shortdot',
  	        tooltip: {
  	            valueSuffix: ''
  	        },
              data: [
                <% @recent_build_times.each do |entry| %>
                {
                  y: <%= entry[:vu_count] rescue 0 %>,
                  color: '<%= entry[:color] %>'		  
                },
                <% end %>
              ]          
  		},
        {
		  name: "Average Time",
          type: 'line',			
  			yAxis: 1,			
		  showInLegend: true,
          enableMouseTracking: true,							 						
	      tooltip: {
	            valueSuffix: ' s'
	      },
          data: [
            <% @recent_build_times.each do |entry| %>
            {
              y: <%= entry[:average_timing] %>,
              // color: '<%= entry[:color] %>'
            },
            <% end %>
          ]          
        },
        {
		  name: "Slowest Time",
          type: 'line',			
  			yAxis: 1,			
		  showInLegend: true,
          enableMouseTracking: true,							 						
	      tooltip: {
	            valueSuffix: ' s'
	      },
          data: [
            <% @recent_build_times.each do |entry| %>
            {
              y: <%= entry[:slowest_timing] %>,
              color: '#fd7e14'
            },
            <% end %>
          ]          
        }
		

	  ]
  });




$("#load_test_history_header").html("<%= @operation_name %>");
$("#load_test_history_dialog").modal("show");