Skip to content

Instantly share code, notes, and snippets.

@jywarren
Created July 30, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jywarren/a30ea77ad54e8aa9ae1f to your computer and use it in GitHub Desktop.
Save jywarren/a30ea77ad54e8aa9ae1f to your computer and use it in GitHub Desktop.
equalizes the area under the curve of any spectra displayed
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)
$.each($W.data,function(index,spectrum){
var sum = 0
$.each(spectrum.data,function(i,v){
// add the intensity to the sum
sum += v[1]
})
$.each(spectrum.data,function(i,v){
// adjust the intensity by dividing it by the sum
$W.data[index].data[i] = [v[0],v[1]/sum]
})
})
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