Skip to content

Commit 1ae6530

Browse files
committed
Adjust cube viewer sizing and axis scaling
1 parent 8fb5ee9 commit 1ae6530

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/cubedynamics/plotting/axis_rig.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,17 @@ def axis_rig_css(spec: AxisRigSpec) -> str:
301301
transform-style: preserve-3d;
302302
pointer-events: none;
303303
color: var(--cd-axis-color);
304-
font-size: var(--cube-axis-font-size, 13px);
304+
font-size: var(--cd-axis-font, var(--cube-axis-font-size, 13px));
305305
letter-spacing: 0.04em;
306306
/* Axis rig lives in cube-local coords; out-z anchors to front face, Y labels shift left for legibility. */
307307
--cd-axis-color: rgba(25, 25, 25, 0.9);
308308
--cd-axis-out-x: 16px;
309309
--cd-axis-out-y: 14px;
310310
--cd-axis-front-z: calc(0.5 * var(--cd-cube-size, var(--cube-size)));
311311
--cd-axis-out-z: calc(var(--cd-axis-front-z) + 6px);
312-
--cd-axis-line-w: 2px;
313-
--cd-axis-tick-w: 1px;
314-
--cd-axis-tick-l: 8px;
312+
--cd-axis-line-w: var(--cd-axis-stroke, 2px);
313+
--cd-axis-tick-w: var(--cd-axis-stroke, 1px);
314+
--cd-axis-tick-l: var(--cd-axis-tick-l, 8px);
315315
--cd-axis-label-gap: 16px;
316316
--cd-axis-end-nudge: 6px;
317317
--cd-axis-x-name-drop: 18px;
@@ -369,6 +369,7 @@ def axis_rig_css(spec: AxisRigSpec) -> str:
369369
370370
.cd-axis-label-face {
371371
display: inline-block;
372+
padding: var(--cd-axis-pill-px, 0px);
372373
transform-style: preserve-3d;
373374
transform: rotateX(var(--cd-bb-rot-x)) rotateY(var(--cd-bb-rot-y));
374375
}

src/cubedynamics/plotting/cube_viewer.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,27 @@ def _render_cube_html(
282282
axis_rig_data_attr = " data-axis-rig=\"true\"" if axis_rig_spec else ""
283283

284284
cube_size_css = (
285-
f"{size_px}px" if size_px is not None else "clamp(320px, min(70vh, 70vw), 760px)"
285+
f"{size_px}px" if size_px is not None else "clamp(300px, min(58vh, 58vw), 640px)"
286286
)
287287
html = f"""
288288
<!DOCTYPE html>
289289
<html lang=\"en\">
290290
<head>
291291
<meta charset=\"UTF-8\" />
292-
<style>
292+
<style>
293293
:root {{
294+
/* Viewer override hooks:
295+
--cd-cube-size
296+
--cd-axis-font
297+
--cd-axis-tick-l
298+
--cd-axis-stroke
299+
*/
294300
--cd-cube-size: {cube_size_css};
295301
--cube-size: var(--cd-cube-size);
302+
--cd-axis-font: clamp(11px, calc(var(--cd-cube-size) * 0.045), 18px);
303+
--cd-axis-pill-px: clamp(4px, calc(var(--cd-cube-size) * 0.010), 8px);
304+
--cd-axis-stroke: clamp(2px, calc(var(--cd-cube-size) * 0.006), 4px);
305+
--cd-axis-tick-l: clamp(10px, calc(var(--cd-cube-size) * 0.035), 18px);
296306
{css_vars}
297307
}}
298308
* {{ box-sizing: border-box; }}
@@ -311,7 +321,10 @@ def _render_cube_html(
311321
user-select: none;
312322
}}
313323
.cube-figure {{
314-
width: min(1180px, 100%);
324+
width: 100%;
325+
max-width: 1100px;
326+
margin: 0 auto;
327+
padding: 0 24px;
315328
display: flex;
316329
flex-direction: column;
317330
align-items: center;

0 commit comments

Comments
 (0)