templates/_labels.html.erb
<ul class="labels">
<% @labels.each_with_index do |l,i| %>
<% l = l.gsub('_',' ') %>
<li>
<span id="<%=@target_element%>_color_<%=i%>">
<%= @data[i] %>
</span>
<%= l.to_s.capitalize %>
<script type="text/javascript">
document.getElementById('<%=@target_element%>_color_<%=i%>').setAttribute('style','background-color:'+color(<%=i%>)+';');
</script>
</li>
<% end %>
</ul>