Skip to content

Commit b6c913a

Browse files
committed
push
1 parent e825fc3 commit b6c913a

49 files changed

Lines changed: 404 additions & 336 deletions

Some content is hidden

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

move_dpi_fix_correctly.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Move DPI fix to the correct location - right before chart creation.
4+
"""
5+
6+
from pathlib import Path
7+
import re
8+
9+
def move_dpi_fix(file_path):
10+
"""Move DPI fix to right before chart creation."""
11+
12+
with open(file_path, 'r', encoding='utf-8') as f:
13+
content = f.read()
14+
15+
# First, remove the existing DPI fix wherever it is
16+
dpi_fix_pattern = r'\n // Fix blurry canvas on high-DPI displays\n const dpr = window\.devicePixelRatio \|\| 1;\n const rect = canvas\.getBoundingClientRect\(\);\n canvas\.width = rect\.width \* dpr;\n canvas\.height = rect\.height \* dpr;\n ctx\.scale\(dpr, dpr\);\n'
17+
18+
content = re.sub(dpi_fix_pattern, '', content)
19+
20+
# Now add it right before "const chart = new Chart"
21+
dpi_fix = ''' // Fix blurry canvas on high-DPI displays
22+
const dpr = window.devicePixelRatio || 1;
23+
const rect = canvas.getBoundingClientRect();
24+
canvas.width = rect.width * dpr;
25+
canvas.height = rect.height * dpr;
26+
ctx.scale(dpr, dpr);
27+
28+
'''
29+
30+
# Find "const chart = new Chart" and add DPI fix before it
31+
chart_pattern = r'( const chart = new Chart\(ctx,)'
32+
replacement = dpi_fix + r'\1'
33+
34+
if re.search(chart_pattern, content):
35+
content = re.sub(chart_pattern, replacement, content)
36+
37+
with open(file_path, 'w', encoding='utf-8') as f:
38+
f.write(content)
39+
40+
print(f"Fixed: {file_path.name}")
41+
else:
42+
print(f"ERROR: Could not find chart creation in {file_path.name}")
43+
44+
45+
def main():
46+
"""Process all severity chart files."""
47+
48+
# Find all BAU and PM severity charts
49+
bau_charts = sorted(Path('.').glob('risk*_bau_chart.html'))
50+
pm_charts = sorted(Path('.').glob('risk*_pm_chart.html'))
51+
52+
all_charts = bau_charts + pm_charts
53+
54+
if not all_charts:
55+
print("No severity charts found!")
56+
return
57+
58+
print(f"Found {len(all_charts)} severity charts")
59+
print(f"Moving DPI fix to correct location...\n")
60+
61+
for chart_file in all_charts:
62+
move_dpi_fix(chart_file)
63+
64+
print(f"\nCompleted!")
65+
66+
67+
if __name__ == '__main__':
68+
main()

risk10_bau_chart.html

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

1859-
// Fix blurry canvas on high-DPI displays
1860-
const dpr = window.devicePixelRatio || 1;
1861-
const rect = canvas.getBoundingClientRect();
1862-
canvas.width = rect.width * dpr;
1863-
canvas.height = rect.height * dpr;
1864-
ctx.scale(dpr, dpr);
1865-
18661859
// Add mouse move handler for hover interaction
18671860
const chartCanvas = document.getElementById('severityChart');
18681861
const tooltip = document.getElementById('expertTooltip');
@@ -1972,6 +1965,13 @@
19721965
chart.update('none');
19731966
});
19741967

1968+
// Fix blurry canvas on high-DPI displays
1969+
const dpr = window.devicePixelRatio || 1;
1970+
const rect = canvas.getBoundingClientRect();
1971+
canvas.width = rect.width * dpr;
1972+
canvas.height = rect.height * dpr;
1973+
ctx.scale(dpr, dpr);
1974+
19751975
const chart = new Chart(ctx, {
19761976
type: 'line',
19771977
data: {

risk10_pm_chart.html

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

1859-
// Fix blurry canvas on high-DPI displays
1860-
const dpr = window.devicePixelRatio || 1;
1861-
const rect = canvas.getBoundingClientRect();
1862-
canvas.width = rect.width * dpr;
1863-
canvas.height = rect.height * dpr;
1864-
ctx.scale(dpr, dpr);
1865-
18661859
// Add mouse move handler for hover interaction
18671860
const chartCanvas = document.getElementById('severityChart');
18681861
const tooltip = document.getElementById('expertTooltip');
@@ -1972,6 +1965,13 @@
19721965
chart.update('none');
19731966
});
19741967

1968+
// Fix blurry canvas on high-DPI displays
1969+
const dpr = window.devicePixelRatio || 1;
1970+
const rect = canvas.getBoundingClientRect();
1971+
canvas.width = rect.width * dpr;
1972+
canvas.height = rect.height * dpr;
1973+
ctx.scale(dpr, dpr);
1974+
19751975
const chart = new Chart(ctx, {
19761976
type: 'line',
19771977
data: {

risk11_bau_chart.html

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

2884-
// Fix blurry canvas on high-DPI displays
2885-
const dpr = window.devicePixelRatio || 1;
2886-
const rect = canvas.getBoundingClientRect();
2887-
canvas.width = rect.width * dpr;
2888-
canvas.height = rect.height * dpr;
2889-
ctx.scale(dpr, dpr);
2890-
28912884
// Add mouse move handler for hover interaction
28922885
const chartCanvas = document.getElementById('severityChart');
28932886
const tooltip = document.getElementById('expertTooltip');
@@ -2997,6 +2990,13 @@
29972990
chart.update('none');
29982991
});
29992992

2993+
// Fix blurry canvas on high-DPI displays
2994+
const dpr = window.devicePixelRatio || 1;
2995+
const rect = canvas.getBoundingClientRect();
2996+
canvas.width = rect.width * dpr;
2997+
canvas.height = rect.height * dpr;
2998+
ctx.scale(dpr, dpr);
2999+
30003000
const chart = new Chart(ctx, {
30013001
type: 'line',
30023002
data: {

risk11_pm_chart.html

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

2884-
// Fix blurry canvas on high-DPI displays
2885-
const dpr = window.devicePixelRatio || 1;
2886-
const rect = canvas.getBoundingClientRect();
2887-
canvas.width = rect.width * dpr;
2888-
canvas.height = rect.height * dpr;
2889-
ctx.scale(dpr, dpr);
2890-
28912884
// Add mouse move handler for hover interaction
28922885
const chartCanvas = document.getElementById('severityChart');
28932886
const tooltip = document.getElementById('expertTooltip');
@@ -2997,6 +2990,13 @@
29972990
chart.update('none');
29982991
});
29992992

2993+
// Fix blurry canvas on high-DPI displays
2994+
const dpr = window.devicePixelRatio || 1;
2995+
const rect = canvas.getBoundingClientRect();
2996+
canvas.width = rect.width * dpr;
2997+
canvas.height = rect.height * dpr;
2998+
ctx.scale(dpr, dpr);
2999+
30003000
const chart = new Chart(ctx, {
30013001
type: 'line',
30023002
data: {

risk12_bau_chart.html

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

3034-
// Fix blurry canvas on high-DPI displays
3035-
const dpr = window.devicePixelRatio || 1;
3036-
const rect = canvas.getBoundingClientRect();
3037-
canvas.width = rect.width * dpr;
3038-
canvas.height = rect.height * dpr;
3039-
ctx.scale(dpr, dpr);
3040-
30413034
// Add mouse move handler for hover interaction
30423035
const chartCanvas = document.getElementById('severityChart');
30433036
const tooltip = document.getElementById('expertTooltip');
@@ -3147,6 +3140,13 @@
31473140
chart.update('none');
31483141
});
31493142

3143+
// Fix blurry canvas on high-DPI displays
3144+
const dpr = window.devicePixelRatio || 1;
3145+
const rect = canvas.getBoundingClientRect();
3146+
canvas.width = rect.width * dpr;
3147+
canvas.height = rect.height * dpr;
3148+
ctx.scale(dpr, dpr);
3149+
31503150
const chart = new Chart(ctx, {
31513151
type: 'line',
31523152
data: {

risk12_pm_chart.html

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

3034-
// Fix blurry canvas on high-DPI displays
3035-
const dpr = window.devicePixelRatio || 1;
3036-
const rect = canvas.getBoundingClientRect();
3037-
canvas.width = rect.width * dpr;
3038-
canvas.height = rect.height * dpr;
3039-
ctx.scale(dpr, dpr);
3040-
30413034
// Add mouse move handler for hover interaction
30423035
const chartCanvas = document.getElementById('severityChart');
30433036
const tooltip = document.getElementById('expertTooltip');
@@ -3147,6 +3140,13 @@
31473140
chart.update('none');
31483141
});
31493142

3143+
// Fix blurry canvas on high-DPI displays
3144+
const dpr = window.devicePixelRatio || 1;
3145+
const rect = canvas.getBoundingClientRect();
3146+
canvas.width = rect.width * dpr;
3147+
canvas.height = rect.height * dpr;
3148+
ctx.scale(dpr, dpr);
3149+
31503150
const chart = new Chart(ctx, {
31513151
type: 'line',
31523152
data: {

risk13_bau_chart.html

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

2134-
// Fix blurry canvas on high-DPI displays
2135-
const dpr = window.devicePixelRatio || 1;
2136-
const rect = canvas.getBoundingClientRect();
2137-
canvas.width = rect.width * dpr;
2138-
canvas.height = rect.height * dpr;
2139-
ctx.scale(dpr, dpr);
2140-
21412134
// Add mouse move handler for hover interaction
21422135
const chartCanvas = document.getElementById('severityChart');
21432136
const tooltip = document.getElementById('expertTooltip');
@@ -2247,6 +2240,13 @@
22472240
chart.update('none');
22482241
});
22492242

2243+
// Fix blurry canvas on high-DPI displays
2244+
const dpr = window.devicePixelRatio || 1;
2245+
const rect = canvas.getBoundingClientRect();
2246+
canvas.width = rect.width * dpr;
2247+
canvas.height = rect.height * dpr;
2248+
ctx.scale(dpr, dpr);
2249+
22502250
const chart = new Chart(ctx, {
22512251
type: 'line',
22522252
data: {

risk13_pm_chart.html

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

2134-
// Fix blurry canvas on high-DPI displays
2135-
const dpr = window.devicePixelRatio || 1;
2136-
const rect = canvas.getBoundingClientRect();
2137-
canvas.width = rect.width * dpr;
2138-
canvas.height = rect.height * dpr;
2139-
ctx.scale(dpr, dpr);
2140-
21412134
// Add mouse move handler for hover interaction
21422135
const chartCanvas = document.getElementById('severityChart');
21432136
const tooltip = document.getElementById('expertTooltip');
@@ -2247,6 +2240,13 @@
22472240
chart.update('none');
22482241
});
22492242

2243+
// Fix blurry canvas on high-DPI displays
2244+
const dpr = window.devicePixelRatio || 1;
2245+
const rect = canvas.getBoundingClientRect();
2246+
canvas.width = rect.width * dpr;
2247+
canvas.height = rect.height * dpr;
2248+
ctx.scale(dpr, dpr);
2249+
22502250
const chart = new Chart(ctx, {
22512251
type: 'line',
22522252
data: {

risk14_bau_chart.html

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

1809-
// Fix blurry canvas on high-DPI displays
1810-
const dpr = window.devicePixelRatio || 1;
1811-
const rect = canvas.getBoundingClientRect();
1812-
canvas.width = rect.width * dpr;
1813-
canvas.height = rect.height * dpr;
1814-
ctx.scale(dpr, dpr);
1815-
18161809
// Add mouse move handler for hover interaction
18171810
const chartCanvas = document.getElementById('severityChart');
18181811
const tooltip = document.getElementById('expertTooltip');
@@ -1922,6 +1915,13 @@
19221915
chart.update('none');
19231916
});
19241917

1918+
// Fix blurry canvas on high-DPI displays
1919+
const dpr = window.devicePixelRatio || 1;
1920+
const rect = canvas.getBoundingClientRect();
1921+
canvas.width = rect.width * dpr;
1922+
canvas.height = rect.height * dpr;
1923+
ctx.scale(dpr, dpr);
1924+
19251925
const chart = new Chart(ctx, {
19261926
type: 'line',
19271927
data: {

0 commit comments

Comments
 (0)