<% if @signature_metrics.empty? %>

	<div id='signature-graph' style='display:none;' class='dashboard-graph no-pie-data'></div>

<% else %>

	<% content_for :footer do %>

		<script type="text/javascript">

		pie = new Highcharts.Chart({
		      chart: {
		         renderTo: 'signature-graph',
		         margin: [50, 165, 50, 160]
		      },
          credits: {
            enabled: false
          },
		      title: {
		         text: ''
		      },
		      tooltip: {
		         formatter: function() {
		            return "<b>" + this.point.name.substring(0, 30) + "</b>... (" + this.y + " events)"
		         }
		      },
		      plotOptions: {
		         pie: {
              events: {
                click: function(event) {
                  HCloader(event.toElement.offsetParent.id);
                  document.location = '/results?title='+event.point.name+'&match_all=true&search%5B0%5D%5Bcolumn%5D=signature_name&search'+
                    '%5B0%5D%5Benabled%5D=true&search%5B0%5D%5Boperator%'+
                    '5D=is&search%5B0%5D%5Bvalue%5D='+event.point.name+'&search%'+
                    '5B1%5D%5Bcolumn%5D=start_time&search%5B1%5D%5Benabl'+
                    'ed%5D=true&search%5B1%5D%5Boperator%5D=gte&search%5B'+
                    '1%5D%5Bvalue%5D=<%= @start_time.strftime("%Y-%m-%d %H:%M:%S") %>&search%5B2%5D%5B'+
                    'column%5D=end_time&search%5B2%5D%5Benabled%5D=true&'+
                    'search%5B2%5D%5Boperator%5D=lte&search%5B2%5D%5Bvalu'+
                    'e%5D=<%= @end_time.strftime("%Y-%m-%d %H:%M:%S") %>';
                }
              },
		            allowPointSelect: true,
		            cursor: 'pointer',
								dataLabels: {
										distance: 20,
									  formatter: function() {
										return "" + this.point.name.substring(0, 30) + "... (" + Math.round(this.percentage) + "%)"
									 },
		                connectorColor: '#888',
										style: {
											fontSize: 10
										}
		            }
		         }
		      },
			    legend: {
			        enabled: false
			    },
		       series: [{
		         type: 'pie',
		         name: 'Signatures',
		         data: [
							<% @signature_metrics.each do |key,value| %>
								['<%= key.to_s %>', <%= value %>],
							<% end %>
		         ]
		      }]
		   });

		</script>

	<% end %>

	<div id='signature-graph' style='display:none;' class='dashboard-graph'></div>

<% end %>
