Skip to content

Commit 5f255ac

Browse files
committed
Analyser legend position is added in user settings
1 parent c3c1df2 commit 5f255ac

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,29 @@ <h4 class="modal-title">Advanced User Settings</h4>
29892989
<p>%</p>
29902990
</td>
29912991
</tr>
2992+
<tr>
2993+
<td>
2994+
<label>Legend</label>
2995+
</td>
2996+
<td class="position">
2997+
<label>Top</label>
2998+
<input name="analyser-legend-top" type="number" step="1" min="0"
2999+
max="100" />
3000+
<p>%</p>
3001+
</td>
3002+
<td class="position">
3003+
<label>Left</label>
3004+
<input name="analyser-legend-left" type="number" step="1" min="0"
3005+
max="100" />
3006+
<p>%</p>
3007+
</td>
3008+
<td class="position">
3009+
<label>Width</label>
3010+
<input name="analyser-legend-width" type="number" step="1" min="0"
3011+
max="100" />
3012+
<p>%</p>
3013+
</td>
3014+
</tr>
29923015
</table>
29933016
</div>
29943017
</div>

src/graph_spectrum_plot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,11 @@ GraphSpectrumPlot._drawPowerSpectralDensityGraph = function (canvasCtx) {
432432

433433
GraphSpectrumPlot._drawLegend = function (canvasCtx, WIDTH, HEIGHT, importedCurves) {
434434
const spectrumCount = importedCurves.length,
435-
legendPosX = WIDTH - 180,
436-
legendPosY = 50,
435+
legendPosX = parseInt(userSettings.analyser_legend.left) / 100 * WIDTH,
436+
legendPosY = parseInt(userSettings.analyser_legend.top) / 100 * HEIGHT,
437437
rowHeight = 16,
438438
padding = 4,
439-
legendWidth = 150 + padding,
439+
legendWidth = parseInt(userSettings.analyser_legend.width) / 100 * WIDTH,
440440
legendHeight = spectrumCount * rowHeight + 3 * padding,
441441
legendArea = new Path2D();
442442

src/user_settings_dialog.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ export function UserSettingsDialog(dialog, onLoad, onSave) {
231231
top: "60%", // position from top (as a percentage of height)
232232
size: "35%", // size (as a percentage of width)
233233
},
234+
analyser_legend: {
235+
left: "88%", // position from left (as a percentage of width)
236+
top: "7%", // position from top (as a percentage of height)
237+
width: "10%", // legend width
238+
},
234239
map: {
235240
left: "2%", // position from left (as a percentage of width)
236241
top: "5%", // position from top (as a percentage of height)
@@ -301,6 +306,11 @@ export function UserSettingsDialog(dialog, onLoad, onSave) {
301306
left: `${$('.analyser-settings input[name="analyser-left"]').val()}%`,
302307
size: `${$('.analyser-settings input[name="analyser-size"]').val()}%`,
303308
},
309+
analyser_legend: {
310+
top: `${$('.analyser-settings input[name="analyser-legend-top"]').val()}%`,
311+
left: `${$('.analyser-settings input[name="analyser-legend-left"]').val()}%`,
312+
width: `${$('.analyser-settings input[name="analyser-legend-width"]').val()}%`,
313+
},
304314
map: {
305315
top: `${$('.map-settings input[name="map-top"]').val()}%`,
306316
left: `${$('.map-settings input[name="map-left"]').val()}%`,
@@ -649,6 +659,16 @@ export function UserSettingsDialog(dialog, onLoad, onSave) {
649659
$('.analyser-settings input[name="analyser-size"]').val(
650660
parseInt(currentSettings.analyser.size)
651661
);
662+
663+
$('.analyser-settings input[name="analyser-legend-top"]').val(
664+
parseInt(currentSettings.analyser_legend.top)
665+
);
666+
$('.analyser-settings input[name="analyser-legend-left"]').val(
667+
parseInt(currentSettings.analyser_legend.left)
668+
);
669+
$('.analyser-settings input[name="analyser-legend-width"]').val(
670+
parseInt(currentSettings.analyser_legend.width)
671+
);
652672
$('.map-settings input[name="map-top"]').val(
653673
parseInt(currentSettings.map.top)
654674
);

0 commit comments

Comments
 (0)