Skip to content

Instantly share code, notes, and snippets.

@jywarren
Created September 22, 2014 19:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jywarren/71b0fc5cc13940f8dc16 to your computer and use it in GitHub Desktop.
equalizes the height of the graphs of any spectra displayed in SpectralWorkbench.org
setup: function() {
// code to run on startup
// assume the same # of datapoints for now
// (this could be a poor assumption but we could bin them)
// go through each spectrum
$.each($W.data,function(index,spectrum){
// determine highest y-height
var highest = 0
$.each(spectrum.data,function(i,v){
if (highest < v[1]) highest = v[1]
})
// now resize the spectrum:
$.each(spectrum.data,function(i,v){
// adjust the intensity by dividing it by the highest peak height
$W.data[index].data[i] = [v[0],v[1]/highest]
})
})
flotoptions.yaxis.max = null
$.plot($("#graph"),$W.data,flotoptions);
},
draw: function() {
// code to run every frame
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment