Skip to content

Commit 87c256d

Browse files
koaningclaude
andcommitted
Better screen real estate for ScatterWidget
- Remove point counters to save vertical space - Compact single-row controls layout - Smaller dots (radius 3) for finer detail - Fix SVG zoom issue with max-width constraint - Scale brush size relative to canvas dimensions - Remove X/Y axis labels (keep grid) - Default height now 400px - Pastel button backgrounds for better color dot visibility - Bump version to 0.4.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 366bdeb commit 87c256d

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

drawdata/static/scatter_widget.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9536,6 +9536,12 @@ var d3 = __toESM(require_d3_v7());
95369536
function render({ model, el }) {
95379537
const colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728"];
95389538
const color_map = { "#1f77b4": "a", "#ff7f0e": "b", "#2ca02c": "c", "#d62728": "d" };
9539+
function hexToRgba(hex, alpha) {
9540+
const r = parseInt(hex.slice(1, 3), 16);
9541+
const g = parseInt(hex.slice(3, 5), 16);
9542+
const b = parseInt(hex.slice(5, 7), 16);
9543+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
9544+
}
95399545
const height = model.get("height") || 400;
95409546
const width = model.get("width") || 800;
95419547
const brushScale = width / 800;
@@ -9587,9 +9593,9 @@ function render({ model, el }) {
95879593
}
95889594
selectedClassButton = button;
95899595
selectedColor = colors[i];
9590-
button.style.backgroundColor = colors[i];
9596+
button.style.backgroundColor = hexToRgba(colors[i], 0.25);
95919597
button.style.borderColor = colors[i];
9592-
button.style.color = "white";
9598+
button.style.color = "var(--dd-text-color)";
95939599
circle_brush.style("fill", selectedColor).style("fill-opacity", 0.3).style("stroke", selectedColor).style("stroke-width", 2);
95949600
};
95959601
controls.appendChild(button);

js/scatter_widget.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ function render({ model, el }) {
44
// Use fixed color values that match the original for API compatibility
55
const colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728"];
66
const color_map = {"#1f77b4": "a", "#ff7f0e": "b", "#2ca02c": "c", "#d62728": "d"};
7+
8+
// Helper to convert hex to rgba for pastel backgrounds
9+
function hexToRgba(hex, alpha) {
10+
const r = parseInt(hex.slice(1, 3), 16);
11+
const g = parseInt(hex.slice(3, 5), 16);
12+
const b = parseInt(hex.slice(5, 7), 16);
13+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
14+
}
715

816
// Get dimensions with fallbacks
917
const height = model.get("height") || 400;
@@ -72,9 +80,10 @@ function render({ model, el }) {
7280
}
7381
selectedClassButton = button;
7482
selectedColor = colors[i];
75-
button.style.backgroundColor = colors[i];
83+
// Use pastel background so the colored dot stands out
84+
button.style.backgroundColor = hexToRgba(colors[i], 0.25);
7685
button.style.borderColor = colors[i];
77-
button.style.color = "white";
86+
button.style.color = "var(--dd-text-color)";
7887

7988
circle_brush
8089
.style("fill", selectedColor)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "drawdata"
7-
version = "0.3.9"
7+
version = "0.4.0"
88
description = "draw a dataset from inside Jupyter"
99
readme = "readme.md"
1010
license = {text = "MIT"}

0 commit comments

Comments
 (0)