Spaces:
Running
Running
Commit ·
742e0c6
1
Parent(s): 0b619ee
New settings
Browse files- index.html +25 -0
- script.js +30 -2
index.html
CHANGED
|
@@ -112,6 +112,31 @@
|
|
| 112 |
<label class="block text-sm text-gray-600 mb-1">Diagram Height</label>
|
| 113 |
<input type="range" id="diagram-height" min="300" max="800" value="400" class="w-full">
|
| 114 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
</div>
|
| 116 |
</div>
|
| 117 |
</div>
|
|
|
|
| 112 |
<label class="block text-sm text-gray-600 mb-1">Diagram Height</label>
|
| 113 |
<input type="range" id="diagram-height" min="300" max="800" value="400" class="w-full">
|
| 114 |
</div>
|
| 115 |
+
<div>
|
| 116 |
+
<label class="block text-sm text-gray-600 mb-1">Font Size</label>
|
| 117 |
+
<select id="font-size" class="w-full p-2 border rounded-md">
|
| 118 |
+
<option value="small">Small</option>
|
| 119 |
+
<option value="medium" selected>Medium</option>
|
| 120 |
+
<option value="large">Large</option>
|
| 121 |
+
</select>
|
| 122 |
+
</div>
|
| 123 |
+
<div>
|
| 124 |
+
<label class="block text-sm text-gray-600 mb-1">Background Color</label>
|
| 125 |
+
<input type="color" id="background-color" value="#f3f4f6" class="w-full h-8">
|
| 126 |
+
</div>
|
| 127 |
+
<div>
|
| 128 |
+
<label class="block text-sm text-gray-600 mb-1">Node Edge Color</label>
|
| 129 |
+
<input type="color" id="node-edge-color" value="#000000" class="w-full h-8">
|
| 130 |
+
</div>
|
| 131 |
+
<div>
|
| 132 |
+
<label class="block text-sm text-gray-600 mb-1">Text Shadow</label>
|
| 133 |
+
<select id="text-shadow" class="w-full p-2 border rounded-md">
|
| 134 |
+
<option value="none">None</option>
|
| 135 |
+
<option value="light">Light</option>
|
| 136 |
+
<option value="medium">Medium</option>
|
| 137 |
+
<option value="dark">Dark</option>
|
| 138 |
+
</select>
|
| 139 |
+
</div>
|
| 140 |
</div>
|
| 141 |
</div>
|
| 142 |
</div>
|
script.js
CHANGED
|
@@ -573,6 +573,10 @@ function initDiagram() {
|
|
| 573 |
(node.targetLinks && node.targetLinks.length > 0)
|
| 574 |
);
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
// Add nodes with better styling
|
| 577 |
const node = svg.append("g")
|
| 578 |
.selectAll("g")
|
|
@@ -586,11 +590,13 @@ function initDiagram() {
|
|
| 586 |
return pos ? `translate(${pos.x},${pos.y})` : `translate(${d.x},${d.y})`;
|
| 587 |
});
|
| 588 |
|
|
|
|
|
|
|
| 589 |
node.append("rect")
|
| 590 |
.attr("height", d => Math.max(d.dy, 1)) // Ensure minimum height of 1px
|
| 591 |
.attr("width", d => d.dx)
|
| 592 |
.attr("fill", d => d.color || "#4f46e5")
|
| 593 |
-
.attr("stroke",
|
| 594 |
.attr("stroke-width", 1)
|
| 595 |
.attr("rx", 3) // Rounded corners
|
| 596 |
.attr("ry", 3);
|
|
@@ -641,6 +647,23 @@ function initDiagram() {
|
|
| 641 |
textAnchor = "middle";
|
| 642 |
}
|
| 643 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
node.append("text")
|
| 645 |
.attr("x", textX)
|
| 646 |
.attr("y", d => d.dy / 2)
|
|
@@ -648,8 +671,9 @@ function initDiagram() {
|
|
| 648 |
.attr("text-anchor", textAnchor)
|
| 649 |
.text(d => d.name)
|
| 650 |
.attr("fill", document.getElementById('text-color').value)
|
| 651 |
-
.attr("font-size",
|
| 652 |
.attr("font-weight", "bold")
|
|
|
|
| 653 |
.attr("pointer-events", "all")
|
| 654 |
.attr("cursor", "pointer")
|
| 655 |
.on("dblclick", function(event, d) {
|
|
@@ -983,6 +1007,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 983 |
document.getElementById('diagram-height').addEventListener('input', initDiagram);
|
| 984 |
document.getElementById('link-alpha').addEventListener('input', initDiagram);
|
| 985 |
document.getElementById('static-link-color').addEventListener('input', initDiagram);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 986 |
|
| 987 |
// Handle link color mode changes
|
| 988 |
const linkColorMode = document.getElementById('link-color-mode');
|
|
|
|
| 573 |
(node.targetLinks && node.targetLinks.length > 0)
|
| 574 |
);
|
| 575 |
|
| 576 |
+
// Update diagram container background
|
| 577 |
+
const backgroundColor = document.getElementById('background-color').value;
|
| 578 |
+
document.getElementById('diagram-container').style.backgroundColor = backgroundColor;
|
| 579 |
+
|
| 580 |
// Add nodes with better styling
|
| 581 |
const node = svg.append("g")
|
| 582 |
.selectAll("g")
|
|
|
|
| 590 |
return pos ? `translate(${pos.x},${pos.y})` : `translate(${d.x},${d.y})`;
|
| 591 |
});
|
| 592 |
|
| 593 |
+
const nodeEdgeColor = document.getElementById('node-edge-color').value;
|
| 594 |
+
|
| 595 |
node.append("rect")
|
| 596 |
.attr("height", d => Math.max(d.dy, 1)) // Ensure minimum height of 1px
|
| 597 |
.attr("width", d => d.dx)
|
| 598 |
.attr("fill", d => d.color || "#4f46e5")
|
| 599 |
+
.attr("stroke", nodeEdgeColor)
|
| 600 |
.attr("stroke-width", 1)
|
| 601 |
.attr("rx", 3) // Rounded corners
|
| 602 |
.attr("ry", 3);
|
|
|
|
| 647 |
textAnchor = "middle";
|
| 648 |
}
|
| 649 |
|
| 650 |
+
// Get font size from settings
|
| 651 |
+
const fontSizeMap = {
|
| 652 |
+
'small': '10px',
|
| 653 |
+
'medium': '12px',
|
| 654 |
+
'large': '14px'
|
| 655 |
+
};
|
| 656 |
+
const fontSize = fontSizeMap[document.getElementById('font-size').value] || '12px';
|
| 657 |
+
|
| 658 |
+
// Get text shadow settings
|
| 659 |
+
const textShadowMap = {
|
| 660 |
+
'none': 'none',
|
| 661 |
+
'light': '1px 1px 2px rgba(0,0,0,0.2)',
|
| 662 |
+
'medium': '2px 2px 4px rgba(0,0,0,0.3)',
|
| 663 |
+
'dark': '3px 3px 6px rgba(0,0,0,0.4)'
|
| 664 |
+
};
|
| 665 |
+
const textShadow = textShadowMap[document.getElementById('text-shadow').value] || 'none';
|
| 666 |
+
|
| 667 |
node.append("text")
|
| 668 |
.attr("x", textX)
|
| 669 |
.attr("y", d => d.dy / 2)
|
|
|
|
| 671 |
.attr("text-anchor", textAnchor)
|
| 672 |
.text(d => d.name)
|
| 673 |
.attr("fill", document.getElementById('text-color').value)
|
| 674 |
+
.attr("font-size", fontSize)
|
| 675 |
.attr("font-weight", "bold")
|
| 676 |
+
.style("text-shadow", textShadow)
|
| 677 |
.attr("pointer-events", "all")
|
| 678 |
.attr("cursor", "pointer")
|
| 679 |
.on("dblclick", function(event, d) {
|
|
|
|
| 1007 |
document.getElementById('diagram-height').addEventListener('input', initDiagram);
|
| 1008 |
document.getElementById('link-alpha').addEventListener('input', initDiagram);
|
| 1009 |
document.getElementById('static-link-color').addEventListener('input', initDiagram);
|
| 1010 |
+
document.getElementById('font-size').addEventListener('change', initDiagram);
|
| 1011 |
+
document.getElementById('background-color').addEventListener('input', initDiagram);
|
| 1012 |
+
document.getElementById('node-edge-color').addEventListener('input', initDiagram);
|
| 1013 |
+
document.getElementById('text-shadow').addEventListener('change', initDiagram);
|
| 1014 |
|
| 1015 |
// Handle link color mode changes
|
| 1016 |
const linkColorMode = document.getElementById('link-color-mode');
|