Skip to content

Commit

Permalink
Merge pull request #22 from mwang87/title_update
Browse files Browse the repository at this point in the history
adding a passthrough for rotation for mass label
  • Loading branch information
mwang87 authored Oct 11, 2019
2 parents 9abe1ca + 19cdbae commit d8f0703
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
12 changes: 11 additions & 1 deletion templates/spectrum.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ <h2>Drawing Controls</h2>
</div>
</div>
<br>
<div class="form-group row">
<div class="col">
<input type="text" id="rotation" class="form-control" placeholder="Rotation angle (70 default)">
</div>
</div>
<br>
<button class="btn btn-primary" onclick=updateFigure()>Update</button>
<hr>
<a id="controlsvgdownload" href="/svg/?usi=((identifier))&label" download="((identifier)).svg">
Expand Down Expand Up @@ -181,7 +187,11 @@ <h2>Drawing Controls</h2>
xmax = $("#xmax").val()
draw_parameters += `xmax=${xmax}&rescale&`
}

if($("#rotation").val().length > 0){
rotation = $("#rotation").val()
draw_parameters += `rotation=${rotation}&`
}

$("#spectrumrender")[0].src = svg_url + draw_parameters
$("#controlsvgdownload")[0].href = svg_url + draw_parameters
$("#controlpngdownload")[0].href = png_url + draw_parameters
Expand Down
17 changes: 9 additions & 8 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def generate_figure(usi, extension, **kwargs):
for mz in annotate_mz:
spec.annotate_mz_fragment(mz, 0, 0.01, 'Da', text=f'{mz:.4f}')

spectrum_plotter_plot.spectrum(spec, annot_kws={'rotation': 70})
spectrum_plotter_plot.spectrum(spec, annot_kws={'rotation': kwargs.get('rotation', 70)})

xmin, xmax = plt.xlim()
plt.xlim(kwargs.get('xmin', xmin), kwargs.get('xmax', xmax))
Expand Down Expand Up @@ -299,15 +299,21 @@ def get_plot_pars(request):
label = False

try:
thresh = float(request.args.get('thresh',None))
thresh = float(request.args.get('thresh', None))
except:
thresh = 0.1

try:
rotation = float(request.args.get('rotation', None))
except:
rotation = 70

plot_pars = {'xmin':xmin,
'xmax':xmax,
'rescale':rescale,
'label':label,
'thresh':thresh}
'thresh':thresh,
'rotation':rotation}

return plot_pars

Expand Down Expand Up @@ -379,8 +385,6 @@ def generateQRImage():
return send_file("image.png")




def parse_USI(usi):
usi_identifier = usi.split(":")[1]

Expand Down Expand Up @@ -420,9 +424,6 @@ def lorikeet_example():
return render_template('example_use.html',text = "boo")





@app.route('/test', methods=['GET'])
# to be deleted - just simon experimenting..
def example_spectrum_grab():
Expand Down

0 comments on commit d8f0703

Please sign in to comment.