Skip to content

Commit edabdfe

Browse files
committed
push
1 parent 3d60356 commit edabdfe

49 files changed

Lines changed: 467 additions & 0 deletions

Some content is hidden

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

add_dpi_fix_simple.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Add DPI fix after medianValuesPlugin closing brace.
4+
"""
5+
6+
from pathlib import Path
7+
8+
def add_dpi_fix(file_path):
9+
"""Add DPI fix after medianValuesPlugin closes."""
10+
11+
with open(file_path, 'r', encoding='utf-8') as f:
12+
lines = f.readlines()
13+
14+
# Check if already has DPI fix
15+
for line in lines:
16+
if '// Fix blurry canvas on high-DPI displays' in line:
17+
print(f"Skipped (already has DPI fix): {file_path.name}")
18+
return
19+
20+
dpi_fix_lines = [
21+
'\n',
22+
' // Fix blurry canvas on high-DPI displays\n',
23+
' const dpr = window.devicePixelRatio || 1;\n',
24+
' const canvas = document.getElementById(\'severityChart\');\n',
25+
' const rect = canvas.getBoundingClientRect();\n',
26+
' canvas.width = rect.width * dpr;\n',
27+
' canvas.height = rect.height * dpr;\n',
28+
' ctx.scale(dpr, dpr);\n'
29+
]
30+
31+
# Find the line with " };" that closes medianValuesPlugin
32+
# It should be after the plugin definition and before the chart creation
33+
new_lines = []
34+
found_plugin_close = False
35+
36+
for i, line in enumerate(lines):
37+
new_lines.append(line)
38+
39+
# Look for the closing of medianValuesPlugin
40+
if not found_plugin_close and line.strip() == '};':
41+
# Check if this is after medianValues plugin definition
42+
# Look back to see if we recently saw the plugin
43+
lookback = ''.join(lines[max(0, i-200):i])
44+
if 'medianValuesPlugin' in lookback and 'afterDatasetsDraw' in lookback:
45+
# Add DPI fix after this line
46+
new_lines.extend(dpi_fix_lines)
47+
found_plugin_close = True
48+
49+
if not found_plugin_close:
50+
print(f"ERROR: Could not find medianValuesPlugin closing in {file_path.name}")
51+
return
52+
53+
# Write back
54+
with open(file_path, 'w', encoding='utf-8') as f:
55+
f.writelines(new_lines)
56+
57+
print(f"Updated: {file_path.name}")
58+
59+
60+
def main():
61+
"""Process all severity chart files."""
62+
63+
# Find all BAU and PM severity charts
64+
bau_charts = sorted(Path('.').glob('risk*_bau_chart.html'))
65+
pm_charts = sorted(Path('.').glob('risk*_pm_chart.html'))
66+
67+
all_charts = bau_charts + pm_charts
68+
69+
if not all_charts:
70+
print("No severity charts found!")
71+
return
72+
73+
print(f"Found {len(all_charts)} severity charts")
74+
print(f"Adding DPI fix after medianValuesPlugin...\n")
75+
76+
for chart_file in all_charts:
77+
add_dpi_fix(chart_file)
78+
79+
print(f"\nCompleted!")
80+
81+
82+
if __name__ == '__main__':
83+
main()

risk10_bau_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,14 @@
18561856
}
18571857
};
18581858

1859+
// Fix blurry canvas on high-DPI displays
1860+
const dpr = window.devicePixelRatio || 1;
1861+
const canvas = document.getElementById('severityChart');
1862+
const rect = canvas.getBoundingClientRect();
1863+
canvas.width = rect.width * dpr;
1864+
canvas.height = rect.height * dpr;
1865+
ctx.scale(dpr, dpr);
1866+
18591867
// Add mouse move handler for hover interaction
18601868
const chartCanvas = document.getElementById('severityChart');
18611869
const tooltip = document.getElementById('expertTooltip');

risk10_pm_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,14 @@
18561856
}
18571857
};
18581858

1859+
// Fix blurry canvas on high-DPI displays
1860+
const dpr = window.devicePixelRatio || 1;
1861+
const canvas = document.getElementById('severityChart');
1862+
const rect = canvas.getBoundingClientRect();
1863+
canvas.width = rect.width * dpr;
1864+
canvas.height = rect.height * dpr;
1865+
ctx.scale(dpr, dpr);
1866+
18591867
// Add mouse move handler for hover interaction
18601868
const chartCanvas = document.getElementById('severityChart');
18611869
const tooltip = document.getElementById('expertTooltip');

risk11_bau_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,14 @@
28812881
}
28822882
};
28832883

2884+
// Fix blurry canvas on high-DPI displays
2885+
const dpr = window.devicePixelRatio || 1;
2886+
const canvas = document.getElementById('severityChart');
2887+
const rect = canvas.getBoundingClientRect();
2888+
canvas.width = rect.width * dpr;
2889+
canvas.height = rect.height * dpr;
2890+
ctx.scale(dpr, dpr);
2891+
28842892
// Add mouse move handler for hover interaction
28852893
const chartCanvas = document.getElementById('severityChart');
28862894
const tooltip = document.getElementById('expertTooltip');

risk11_pm_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,14 @@
28812881
}
28822882
};
28832883

2884+
// Fix blurry canvas on high-DPI displays
2885+
const dpr = window.devicePixelRatio || 1;
2886+
const canvas = document.getElementById('severityChart');
2887+
const rect = canvas.getBoundingClientRect();
2888+
canvas.width = rect.width * dpr;
2889+
canvas.height = rect.height * dpr;
2890+
ctx.scale(dpr, dpr);
2891+
28842892
// Add mouse move handler for hover interaction
28852893
const chartCanvas = document.getElementById('severityChart');
28862894
const tooltip = document.getElementById('expertTooltip');

risk12_bau_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,14 @@
30313031
}
30323032
};
30333033

3034+
// Fix blurry canvas on high-DPI displays
3035+
const dpr = window.devicePixelRatio || 1;
3036+
const canvas = document.getElementById('severityChart');
3037+
const rect = canvas.getBoundingClientRect();
3038+
canvas.width = rect.width * dpr;
3039+
canvas.height = rect.height * dpr;
3040+
ctx.scale(dpr, dpr);
3041+
30343042
// Add mouse move handler for hover interaction
30353043
const chartCanvas = document.getElementById('severityChart');
30363044
const tooltip = document.getElementById('expertTooltip');

risk12_pm_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,14 @@
30313031
}
30323032
};
30333033

3034+
// Fix blurry canvas on high-DPI displays
3035+
const dpr = window.devicePixelRatio || 1;
3036+
const canvas = document.getElementById('severityChart');
3037+
const rect = canvas.getBoundingClientRect();
3038+
canvas.width = rect.width * dpr;
3039+
canvas.height = rect.height * dpr;
3040+
ctx.scale(dpr, dpr);
3041+
30343042
// Add mouse move handler for hover interaction
30353043
const chartCanvas = document.getElementById('severityChart');
30363044
const tooltip = document.getElementById('expertTooltip');

risk13_bau_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,14 @@
21312131
}
21322132
};
21332133

2134+
// Fix blurry canvas on high-DPI displays
2135+
const dpr = window.devicePixelRatio || 1;
2136+
const canvas = document.getElementById('severityChart');
2137+
const rect = canvas.getBoundingClientRect();
2138+
canvas.width = rect.width * dpr;
2139+
canvas.height = rect.height * dpr;
2140+
ctx.scale(dpr, dpr);
2141+
21342142
// Add mouse move handler for hover interaction
21352143
const chartCanvas = document.getElementById('severityChart');
21362144
const tooltip = document.getElementById('expertTooltip');

risk13_pm_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,14 @@
21312131
}
21322132
};
21332133

2134+
// Fix blurry canvas on high-DPI displays
2135+
const dpr = window.devicePixelRatio || 1;
2136+
const canvas = document.getElementById('severityChart');
2137+
const rect = canvas.getBoundingClientRect();
2138+
canvas.width = rect.width * dpr;
2139+
canvas.height = rect.height * dpr;
2140+
ctx.scale(dpr, dpr);
2141+
21342142
// Add mouse move handler for hover interaction
21352143
const chartCanvas = document.getElementById('severityChart');
21362144
const tooltip = document.getElementById('expertTooltip');

risk14_bau_chart.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,14 @@
18061806
}
18071807
};
18081808

1809+
// Fix blurry canvas on high-DPI displays
1810+
const dpr = window.devicePixelRatio || 1;
1811+
const canvas = document.getElementById('severityChart');
1812+
const rect = canvas.getBoundingClientRect();
1813+
canvas.width = rect.width * dpr;
1814+
canvas.height = rect.height * dpr;
1815+
ctx.scale(dpr, dpr);
1816+
18091817
// Add mouse move handler for hover interaction
18101818
const chartCanvas = document.getElementById('severityChart');
18111819
const tooltip = document.getElementById('expertTooltip');

0 commit comments

Comments
 (0)