Permalink
Browse files

graphs for tag searches

  • Loading branch information...
1 parent 51bc5b9 commit 34f93c85f892970d4b2a08421b6b6988b8d1ecdf @jywarren committed Jan 7, 2013
@@ -25,7 +25,9 @@ def show
@count = @spectrums.length
@spectrums = @spectrums.paginate :page => params[:page], :per_page => 24
end
+ @spectrums = [] if @spectrums.nil?
@comments = Comment.all :limit => 12, :order => "id DESC"
+ render :layout => 'bootstrap'
end
def delete
@@ -9,7 +9,7 @@
</div>
<% if ((i+1)/4.0).to_i == ((i+1)/4.0) %>
</div>
- <hr />
+ <hr style="clear:both;"/>
<div class="_row">
<% end %>
<% end %>
@@ -1,15 +1,38 @@
+<script language="javascript" type="text/javascript" src="/javascripts/flot/jquery.flot.js"></script>
+<script language="javascript" type="text/javascript" src="/javascripts/flot/jquery.flot.crosshair.js"></script>
-<h1>Spectra tagged with "<%=h params[:id] %>"<% if @tag %> (<%= @count %>)<% end %></h1>
+ <div style="margin-left:20px;width:95%;height:160px;" id="graph"></div>
+ <h2 style="margin-left:10px;">Spectra tagged with "<%=h params[:id] %>"<% if @tag %> (<%= @count %>)<% end %></h2>
-<hr style="clear:both;" />
+ <% if @tag %>
+ <%= render :partial => 'spectrums/list_bootstrap' %>
+ <% else %>
+ <p>No results for tag "<%=h params[:id] %></p>
+ <% end %>
-<%= render :partial => 'spectrums/sidebar' %>
-
-<div id="maincolumn">
-<% if @tag %>
-<%= render :partial => 'spectrums/list' %>
-<% else %>
-<p>No results for tag "<%=h params[:id] %></p>
-<% end %>
-</div>
+<script type="text/javascript">
+ data = []
+ <% @spectrums.each do |spectrum| %>
+ <% if spectrum.data == "" || spectrum.data.nil? %>
+ spectrum = <%= spectrum.extract_data %>
+ <% else %>
+ spectrum = <%= spectrum.data.chomp(",") %>
+ <% end %>
+ data.push({data:[]})
+ scaled = true
+ $.each(spectrum.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.tickFormatter = function(nm) { return nm }
+ flotoptions.xaxis.show = true
+ flotoptions.colors = ["#ddd"]
+ flotoptions.colors = ["#ddd"]
+ flotoptions.grid.backgroundColor = "#222"
+ $.plot($("#graph"),data,flotoptions);
+</script>

0 comments on commit 34f93c8

Please sign in to comment.