app/views/sets/embed.html.erb
<%= javascript_include_tag "analyze" %>
<%= javascript_include_tag "application" %>
<div id="graph" style="width:<%= @width.to_i-30 %>px;height:<%= @height.to_i - 40 %>px;"></div>
<script type="text/javascript">
data = []
<% @set.spectrums.each do |spectrum| %>
<% if spectrum.data == "" || spectrum.data.nil? %>
spectrum_<%= spectrum.id %> = <%= raw spectrum.extract_data %>
<% else %>
spectrum_<%= spectrum.id %> = <%= raw spectrum.data.chomp(",") %>
<% end %>
//data.push({data:[]})
data.push({label: "<%= spectrum.title %> = 0% ",data:[]})
scaled = true
$.each(spectrum_<%= spectrum.id %>.lines,function(index,line) {
if (line.wavelength == null) {
line.wavelength = index
scaled = false
}
data[data.length-1].data.push([line.wavelength,line.average/(2.55)])
})
<% end %>
flotoptions.xaxis.show = scaled
flotoptions.grid.backgroundColor = "#eee"
flotoptions.grid.color = "#444"
flotoptions.colors[0] = "#666"
$.plot($("#graph"),data,flotoptions);
</script>
<b><a target="_blank" href="//spectralworkbench.org/sets/show/<%= @set.id %>"><%= @set.title %></a></b>
<span style="text-align:right;">by <a href="//spectralworkbench.org/spectra/author/<%= @set.author %>"><%= @set.author %></a></span>
<span style="text-align:right;">on <img src="/images/spectralworkbench.png" /> <a href="//spectralworkbench.org">SpectralWorkbench.org</a></span>
<span id="hidelegend"> | <a href="javascript:void();" onClick="flotoptions.legend = {show:false};$.plot($('#graph'),data,flotoptions);">hide legend</a></span>
<style>
html {
font-family: lucida grande, lucida console, arial, sans-serif;
font-size:11px;
padding-top:8px;
}
body {
margin:0;
}
b {
padding:3px;
font-size:13px;
}
#graph {
}
</style>