Skip to content

Commit 3d60356

Browse files
committed
push
1 parent 42f7a96 commit 3d60356

51 files changed

Lines changed: 202 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"permissions": {
33
"allow": [
44
"Bash(python3:*)",
5-
"Bash(rm:*)"
5+
"Bash(rm:*)",
6+
"Bash(for file in risk*_bau_chart.html risk*_pm_chart.html)",
7+
"Bash(do)",
8+
"Bash(done)"
69
],
710
"deny": [],
811
"ask": []

add_dpi_fix_only.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Add only the DPI fix after medianValuesPlugin.
4+
"""
5+
6+
import re
7+
from pathlib import Path
8+
9+
def add_dpi_fix(file_path):
10+
"""Add DPI fix after medianValuesPlugin closes."""
11+
12+
with open(file_path, 'r', encoding='utf-8') as f:
13+
content = f.read()
14+
15+
# Check if already has DPI fix
16+
if '// Fix blurry canvas on high-DPI displays' in content:
17+
print(f"Skipped (already has DPI fix): {file_path.name}")
18+
return
19+
20+
dpi_fix = '''
21+
// Fix blurry canvas on high-DPI displays
22+
const dpr = window.devicePixelRatio || 1;
23+
const canvas = document.getElementById('severityChart');
24+
const rect = canvas.getBoundingClientRect();
25+
canvas.width = rect.width * dpr;
26+
canvas.height = rect.height * dpr;
27+
ctx.scale(dpr, dpr);
28+
'''
29+
30+
# Find the closing of medianValuesPlugin and add DPI fix after it
31+
# Pattern: the closing }; of the plugin
32+
pattern = r'(const medianValuesPlugin = \{[^}]*id: ["\']medianValues["\'][^}]*afterDatasetsDraw:[^}]*\}(?:[^}]*\{[^}]*\}[^}]*)*\s*\};)'
33+
34+
def replace_func(match):
35+
return match.group(1) + dpi_fix
36+
37+
content = re.sub(pattern, replace_func, content, flags=re.DOTALL)
38+
39+
# Write back
40+
with open(file_path, 'w', encoding='utf-8') as f:
41+
f.write(content)
42+
43+
print(f"Updated: {file_path.name}")
44+
45+
46+
def main():
47+
"""Process all severity chart files."""
48+
49+
# Find all BAU and PM severity charts
50+
bau_charts = sorted(Path('.').glob('risk*_bau_chart.html'))
51+
pm_charts = sorted(Path('.').glob('risk*_pm_chart.html'))
52+
53+
all_charts = bau_charts + pm_charts
54+
55+
if not all_charts:
56+
print("No severity charts found!")
57+
return
58+
59+
print(f"Found {len(all_charts)} severity charts")
60+
print(f"Adding DPI fix after medianValuesPlugin...\n")
61+
62+
for chart_file in all_charts:
63+
add_dpi_fix(chart_file)
64+
65+
print(f"\nCompleted!")
66+
67+
68+
if __name__ == '__main__':
69+
main()

fix_blank_charts_final.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Final fix: Add ctx definition exactly where it should be, matching exemplar structure.
4+
"""
5+
6+
import re
7+
from pathlib import Path
8+
9+
def fix_blank_charts(file_path):
10+
"""Add ctx and DPI fix in exact exemplar structure."""
11+
12+
with open(file_path, 'r', encoding='utf-8') as f:
13+
content = f.read()
14+
15+
# Find: const canvas = document.getElementById('severityChart');
16+
# followed by blank lines, and replace with the correct structure
17+
18+
# Pattern to find the canvas line followed by whitespace
19+
pattern = r"(// Create chart with custom plugin for colored squares\s*const canvas = document\.getElementById\('severityChart'\);)\s*\n\s*\n\s*\n\s*(let hoveredExpertIndex)"
20+
21+
# Replacement with ctx definition
22+
replacement = r'''\1
23+
const ctx = document.getElementById('severityChart').getContext('2d');
24+
25+
\2'''
26+
27+
content = re.sub(pattern, replacement, content)
28+
29+
# Now add the DPI fix after medianValuesPlugin closes
30+
# Find the closing of medianValuesPlugin
31+
dpi_fix = '''
32+
// Fix blurry canvas on high-DPI displays
33+
const dpr = window.devicePixelRatio || 1;
34+
const canvas = document.getElementById('severityChart');
35+
const rect = canvas.getBoundingClientRect();
36+
canvas.width = rect.width * dpr;
37+
canvas.height = rect.height * dpr;
38+
ctx.scale(dpr, dpr);
39+
'''
40+
41+
# Pattern: end of medianValuesPlugin, before any // Track hover or chartCanvas references
42+
# Look for the plugin closing followed by whitespace
43+
plugin_pattern = r'(const medianValuesPlugin = \{[^}]*afterDatasetsDraw: \(chart\) => \{(?:[^{}]|\{[^{}]*\})*\}\s*\};)\s*\n(\s*const chartCanvas|// Track|let hoveredExpertIndex)'
44+
45+
# Check if DPI fix is already there
46+
if '// Fix blurry canvas on high-DPI displays' not in content:
47+
# Insert after the plugin
48+
plugin_replacement = r'\1' + dpi_fix + '\n\2'
49+
content = re.sub(plugin_pattern, plugin_replacement, content, flags=re.DOTALL)
50+
51+
# Write back
52+
with open(file_path, 'w', encoding='utf-8') as f:
53+
f.write(content)
54+
55+
print(f"Updated: {file_path.name}")
56+
57+
58+
def main():
59+
"""Process all severity chart files."""
60+
61+
# Find all BAU and PM severity charts
62+
bau_charts = sorted(Path('.').glob('risk*_bau_chart.html'))
63+
pm_charts = sorted(Path('.').glob('risk*_pm_chart.html'))
64+
65+
all_charts = bau_charts + pm_charts
66+
67+
if not all_charts:
68+
print("No severity charts found!")
69+
return
70+
71+
print(f"Found {len(all_charts)} severity charts")
72+
print(f"Adding ctx definition and DPI fix...\n")
73+
74+
for chart_file in all_charts:
75+
fix_blank_charts(chart_file)
76+
77+
print(f"\nCompleted! Updated {len(all_charts)} files.")
78+
79+
80+
if __name__ == '__main__':
81+
main()

risk10_bau_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@
16871687

16881688
// Create chart with custom plugin for colored squares
16891689
const canvas = document.getElementById('severityChart');
1690+
const ctx = document.getElementById('severityChart').getContext('2d');
16901691

16911692

16921693


risk10_pm_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@
16871687

16881688
// Create chart with custom plugin for colored squares
16891689
const canvas = document.getElementById('severityChart');
1690+
const ctx = document.getElementById('severityChart').getContext('2d');
16901691

16911692

16921693


risk11_bau_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,7 @@
27122712

27132713
// Create chart with custom plugin for colored squares
27142714
const canvas = document.getElementById('severityChart');
2715+
const ctx = document.getElementById('severityChart').getContext('2d');
27152716

27162717

27172718


risk11_pm_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,7 @@
27122712

27132713
// Create chart with custom plugin for colored squares
27142714
const canvas = document.getElementById('severityChart');
2715+
const ctx = document.getElementById('severityChart').getContext('2d');
27152716

27162717

27172718


risk12_bau_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,7 @@
28622862

28632863
// Create chart with custom plugin for colored squares
28642864
const canvas = document.getElementById('severityChart');
2865+
const ctx = document.getElementById('severityChart').getContext('2d');
28652866

28662867

28672868


risk12_pm_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,6 +2862,7 @@
28622862

28632863
// Create chart with custom plugin for colored squares
28642864
const canvas = document.getElementById('severityChart');
2865+
const ctx = document.getElementById('severityChart').getContext('2d');
28652866

28662867

28672868


risk13_bau_chart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,7 @@
19621962

19631963
// Create chart with custom plugin for colored squares
19641964
const canvas = document.getElementById('severityChart');
1965+
const ctx = document.getElementById('severityChart').getContext('2d');
19651966

19661967

19671968


0 commit comments

Comments
 (0)