<% 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?search[signature_name]=' + 
                    event.point.name + '&search[time_start]=<%= @start_time.to_i %>' +
                    '&search[time_end]=<%= @end_time.to_i %>';
                }
              },
		            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 %>
