Skip to content

Commit f5d84fe

Browse files
markheckmannclaude
andcommitted
Add profile font size slider and increase scale/legend text sizes
- Font size slider in profile panel (7-14px, default 10px) for construct pole labels, saved/restored with snapshots - Scale tick numbers increased from 9px to 11px - Benchmark legend names increased from 9px to bold 12px Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 883c6d1 commit f5d84fe

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

inst/threejs/biplot3d.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ body {
202202
margin-bottom: 10px;
203203
}
204204

205+
.profile-font-control {
206+
display: flex;
207+
align-items: center;
208+
gap: 6px;
209+
padding: 2px 12px;
210+
font-size: 10px;
211+
color: #888;
212+
}
213+
214+
.profile-font-control input[type="range"] {
215+
width: 80px;
216+
height: 12px;
217+
}
218+
205219
#profile-container .profile-hint {
206220
font-size: 11px;
207221
color: #999;

inst/threejs/biplot3d.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,27 @@
822822
var profileCtx = profileCanvas.getContext("2d");
823823
var profileHint = document.querySelector("#profile-container .profile-hint");
824824
profileCanvas.style.display = "none";
825+
826+
// Profile font size control
827+
var profileFontSize = 10;
828+
var profileFontControl = document.createElement("div");
829+
profileFontControl.className = "profile-font-control";
830+
var pfRange = document.createElement("input");
831+
pfRange.type = "range";
832+
pfRange.min = "7";
833+
pfRange.max = "14";
834+
pfRange.step = "1";
835+
pfRange.value = "10";
836+
var pfLabel = document.createElement("span");
837+
pfLabel.textContent = "Font";
838+
profileFontControl.appendChild(pfLabel);
839+
profileFontControl.appendChild(pfRange);
840+
var profileContainer = document.getElementById("profile-container");
841+
profileContainer.insertBefore(profileFontControl, profileCanvas);
842+
pfRange.addEventListener("input", function () {
843+
profileFontSize = parseInt(pfRange.value);
844+
if (selectedElementIndex >= 0) drawProfilePlot(selectedElementIndex);
845+
});
825846
var removeBenchmarksBtn = document.getElementById("remove-benchmarks-btn");
826847
removeBenchmarksBtn.addEventListener("click", function () {
827848
benchmarkElements = [];
@@ -1042,11 +1063,11 @@
10421063
var rightMargin = leftMargin;
10431064
var plotWidth = containerWidth - leftMargin - rightMargin;
10441065
if (plotWidth < 60) { leftMargin = Math.floor((containerWidth - 60) / 2); rightMargin = leftMargin; plotWidth = containerWidth - leftMargin - rightMargin; }
1045-
var poleFont = "10px -apple-system, BlinkMacSystemFont, sans-serif";
1046-
var lineHeight = 12;
1066+
var poleFont = profileFontSize + "px -apple-system, BlinkMacSystemFont, sans-serif";
1067+
var lineHeight = Math.round(profileFontSize * 1.2);
10471068
var rowHeight = 32;
10481069
var topPad = 42;
1049-
var bottomPad = benchmarkElements.length > 0 ? 36 : 20;
1070+
var bottomPad = benchmarkElements.length > 0 ? 42 : 20;
10501071
var canvasHeight = topPad + nc * rowHeight + bottomPad;
10511072

10521073
var dpr = window.devicePixelRatio || 1;
@@ -1077,7 +1098,7 @@
10771098
profileCtx.fillText(elements[elemIdx].name, containerWidth / 2, 18);
10781099

10791100
// Scale ticks at top
1080-
profileCtx.font = "9px -apple-system, BlinkMacSystemFont, sans-serif";
1101+
profileCtx.font = "11px -apple-system, BlinkMacSystemFont, sans-serif";
10811102
profileCtx.fillStyle = isDark ? "#888" : "#999";
10821103
profileCtx.textAlign = "center";
10831104
for (var s = scaleMin; s <= scaleMax; s++) {
@@ -1224,8 +1245,8 @@
12241245

12251246
// Legend for benchmarks
12261247
if (benchmarkElements.length > 0) {
1227-
var legendY = topPad + nc * rowHeight + 10;
1228-
profileCtx.font = "9px -apple-system, BlinkMacSystemFont, sans-serif";
1248+
var legendY = topPad + nc * rowHeight + 12;
1249+
profileCtx.font = "bold 12px -apple-system, BlinkMacSystemFont, sans-serif";
12291250
var legendX = leftMargin;
12301251
for (var bi = 0; bi < benchmarkElements.length; bi++) {
12311252
var bIdx = benchmarkElements[bi];
@@ -1887,7 +1908,8 @@
18871908
axisWidth: axisWidthRange.value,
18881909
projWidth: projWidthRange.value,
18891910
pcAxisWidth: pcAxisRange.value,
1890-
gridDensity: gridDensityRange.value
1911+
gridDensity: gridDensityRange.value,
1912+
profileFontSize: pfRange.value
18911913
};
18921914
}
18931915

@@ -1935,6 +1957,10 @@
19351957
pcAxisRange.dispatchEvent(new Event("input"));
19361958
gridDensityRange.value = s.gridDensity;
19371959
gridDensityRange.dispatchEvent(new Event("input"));
1960+
if (s.profileFontSize) {
1961+
pfRange.value = s.profileFontSize;
1962+
pfRange.dispatchEvent(new Event("input"));
1963+
}
19381964

19391965
// Element/construct visibility
19401966
for (var i = 0; i < elements.length; i++) {

0 commit comments

Comments
 (0)