From 30f4ad7ce336f2f3b10564f3976cbfdfb1118572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pi=C5=82atowski?= Date: Mon, 1 Apr 2019 10:34:30 +0200 Subject: [PATCH] Add ability to specify horizontal axis position --- spectrum.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spectrum.js b/spectrum.js index f6e6b09..78fdc1c 100644 --- a/spectrum.js +++ b/spectrum.js @@ -148,7 +148,15 @@ Spectrum.prototype.updateAxes = function() { freq = freq / 1e6 + "M"; else if (this.centerHz + this.spanHz > 1e3) freq = freq / 1e3 + "k"; - this.ctx_axes.fillText(freq, x + adjust, height - 3); + + if(this.horizontalAxisPosition === 'both') { + this.ctx_axes.fillText(freq, x + adjust, height); + this.ctx_axes.fillText(freq, x + adjust, 12); + } else if(this.horizontalAxisPosition === 'bottom') { + this.ctx_axes.fillText(freq, x + adjust, height); + } else if(this.horizontalAxisPosition === 'top') { + this.ctx_axes.fillText(freq, x + adjust, 12); + } } this.ctx_axes.beginPath(); @@ -328,6 +336,7 @@ function Spectrum(id, options) { this.spectrumPercent = (options && options.spectrumPercent) ? options.spectrumPercent : 25; this.spectrumPercentStep = (options && options.spectrumPercentStep) ? options.spectrumPercentStep : 5; this.averaging = (options && options.averaging) ? options.averaging : 0.5; + this.horizontalAxisPosition = (options && options.horizontalAxisPosition) ? options.horizontalAxisPosition : 'bottom'; // either 'top', 'bottom' or 'both' // Setup state this.paused = false;