Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions drawdata/static/scatter_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -9567,6 +9567,7 @@ function render({ model, el }) {
container.appendChild(controls);
let selectedClassButton = null;
let selectedColor = colors[0];
let circle_brush;
let classButtonsContainer = document.createElement("div");
classButtonsContainer.style.display = n_classes === 1 ? "none" : "flex";
classButtonsContainer.style.alignItems = "center";
Expand Down Expand Up @@ -9608,7 +9609,9 @@ function render({ model, el }) {
button.style.backgroundColor = hexToRgba(colors[i], 0.25);
button.style.borderColor = colors[i];
button.style.color = "var(--dd-text-color)";
circle_brush.style("fill", selectedColor).style("fill-opacity", 0.3).style("stroke", selectedColor).style("stroke-width", 2);
if (circle_brush) {
circle_brush.style("fill", selectedColor).style("fill-opacity", 0.3).style("stroke", selectedColor).style("stroke-width", 2);
}
};
classButtonsContainer.appendChild(button);
if (i === 0) {
Expand Down Expand Up @@ -9729,7 +9732,7 @@ function render({ model, el }) {
redraw_from_scratch();
}
}
let circle_brush = svg.append("circle").attr("cx", width / 2).attr("cy", height / 2).attr("r", model.get("brushsize") * brushScale).style("fill", selectedColor).style("fill-opacity", 0.3).style("stroke", selectedColor).style("stroke-width", 2).style("stroke-opacity", 0.9).attr("class", "brush-indicator");
circle_brush = svg.append("circle").attr("cx", width / 2).attr("cy", height / 2).attr("r", model.get("brushsize") * brushScale).style("fill", selectedColor).style("fill-opacity", 0.3).style("stroke", selectedColor).style("stroke-width", 2).style("stroke-opacity", 0.9).attr("class", "brush-indicator");
function drag_start(event) {
isDragging = false;
}
Expand Down
15 changes: 9 additions & 6 deletions js/scatter_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function render({ model, el }) {

let selectedClassButton = null;
let selectedColor = colors[0];
let circle_brush;

// Container for class buttons (hidden when n_classes === 1)
let classButtonsContainer = document.createElement("div");
Expand Down Expand Up @@ -105,11 +106,13 @@ function render({ model, el }) {
button.style.borderColor = colors[i];
button.style.color = "var(--dd-text-color)";

circle_brush
.style("fill", selectedColor)
.style("fill-opacity", 0.3)
.style("stroke", selectedColor)
.style("stroke-width", 2);
if (circle_brush) {
circle_brush
.style("fill", selectedColor)
.style("fill-opacity", 0.3)
.style("stroke", selectedColor)
.style("stroke-width", 2);
}
};

classButtonsContainer.appendChild(button);
Expand Down Expand Up @@ -321,7 +324,7 @@ function render({ model, el }) {
}

// Visual brush indicator with higher visibility
let circle_brush = svg
circle_brush = svg
.append("circle")
.attr("cx", width / 2)
.attr("cy", height / 2)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_scatter_widget_init_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pathlib import Path


def test_scatter_widget_does_not_use_circle_brush_before_initialization():
js = Path("drawdata/static/scatter_widget.js").read_text(encoding="utf-8")

assert "let circle_brush;" in js
assert "if (circle_brush)" in js
Loading