LLR history graph!!!
This commit is contained in:
1 parent
9bcd45bc8b
commit
2884a7ccf8
4 files changed
+490
No files matched your search
@@ -309,6 +309,159 @@ body, html, main{
|
|||||||
padding: 0.50rem 0.75rem;
|
padding: 0.50rem 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#content .llr-history-panel {
|
||||||
|
margin: 0.5rem 0 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-widget {
|
||||||
|
position: relative;
|
||||||
|
width: 372px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-chart {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0.55rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-yaxis {
|
||||||
|
width: 44px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
color: #A7B1C2;
|
||||||
|
font-size: 10px;
|
||||||
|
text-align: right;
|
||||||
|
padding: 0.35rem 0 1.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-main {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.28rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-plot {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-label {
|
||||||
|
color: var(--color-font3);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin-bottom: 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph {
|
||||||
|
display: block;
|
||||||
|
width: 320px;
|
||||||
|
height: 112px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-bg {
|
||||||
|
fill: #242933;
|
||||||
|
stroke: #4C566A;
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-grid-line {
|
||||||
|
stroke: rgba(236, 239, 244, 0.14);
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-boundary {
|
||||||
|
stroke: #BF616A;
|
||||||
|
stroke-width: 1;
|
||||||
|
stroke-dasharray: 4 3;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-zero {
|
||||||
|
stroke: #81A1C1;
|
||||||
|
stroke-width: 1;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-path-positive,
|
||||||
|
#content .llr-history-graph .llr-path-negative {
|
||||||
|
fill: none;
|
||||||
|
stroke-width: 2;
|
||||||
|
stroke-linecap: round;
|
||||||
|
stroke-linejoin: round;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-path-positive {
|
||||||
|
stroke: #7BCB8B;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-path-negative {
|
||||||
|
stroke: #E07A7A;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-xaxis {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
color: #A7B1C2;
|
||||||
|
font-size: 10px;
|
||||||
|
padding: 0 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-point {
|
||||||
|
fill: #ECEFF4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hover-line {
|
||||||
|
stroke: #ECEFF4;
|
||||||
|
stroke-width: 1;
|
||||||
|
stroke-dasharray: 2 2;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hover-point {
|
||||||
|
fill: #ECEFF4;
|
||||||
|
stroke-width: 1.5;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hover-line.active,
|
||||||
|
#content .llr-history-graph .llr-hover-point.active {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hover-point-positive {
|
||||||
|
stroke: #7BCB8B;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hover-point-negative {
|
||||||
|
stroke: #E07A7A;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-graph .llr-hitbox {
|
||||||
|
fill: transparent;
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-tooltip {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
padding: 0.18rem 0.4rem 0.12rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: rgba(36, 41, 51, 0.96);
|
||||||
|
border: 1px solid #4C566A;
|
||||||
|
color: var(--color-font1);
|
||||||
|
font-size: 0.72rem;
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(2px);
|
||||||
|
transition: opacity 0.12s ease, transform 0.12s ease;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .llr-history-tooltip.active {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Test Views */
|
/* Test Views */
|
||||||
|
|
||||||
#content #config {
|
#content #config {
|
||||||
|
|||||||
@@ -18,9 +18,13 @@
|
|||||||
# #
|
# #
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|
||||||
|
import html
|
||||||
|
import json
|
||||||
import re, django
|
import re, django
|
||||||
import OpenBench.config, OpenBench.utils, OpenBench.stats, OpenBench.models
|
import OpenBench.config, OpenBench.utils, OpenBench.stats, OpenBench.models
|
||||||
|
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
def oneDigitPrecision(value):
|
def oneDigitPrecision(value):
|
||||||
try:
|
try:
|
||||||
value = round(value, 1)
|
value = round(value, 1)
|
||||||
@@ -200,6 +204,207 @@ def machine_name(machine_id):
|
|||||||
return machine.info['machine_name']
|
return machine.info['machine_name']
|
||||||
except: return 'None'
|
except: return 'None'
|
||||||
|
|
||||||
|
def llr_history_graph(test, width=320, height=112):
|
||||||
|
|
||||||
|
if test.test_mode != 'SPRT':
|
||||||
|
return ''
|
||||||
|
|
||||||
|
history = list(OpenBench.utils.get_llr_history(test))
|
||||||
|
if not history:
|
||||||
|
history = [[0, 0.0], [max(test.games, 1), test.currentllr]]
|
||||||
|
elif history[-1][0] != test.games or history[-1][1] != test.currentllr:
|
||||||
|
history.append([test.games, test.currentllr])
|
||||||
|
|
||||||
|
x_max = max(max(point[0] for point in history), 1)
|
||||||
|
observed = [point[1] for point in history] + [0.0]
|
||||||
|
observed_min = min(observed)
|
||||||
|
observed_max = max(observed)
|
||||||
|
observed_span = observed_max - observed_min
|
||||||
|
|
||||||
|
if observed_span < 0.75:
|
||||||
|
center = (observed_min + observed_max) / 2.0
|
||||||
|
y_min = center - 0.375
|
||||||
|
y_max = center + 0.375
|
||||||
|
else:
|
||||||
|
padding = max(observed_span * 0.15, 0.15)
|
||||||
|
y_min = observed_min - padding
|
||||||
|
y_max = observed_max + padding
|
||||||
|
|
||||||
|
left_pad = 8
|
||||||
|
right_pad = 8
|
||||||
|
top_pad = 8
|
||||||
|
bottom_pad = 8
|
||||||
|
inner_width = max(width - left_pad - right_pad, 1)
|
||||||
|
inner_height = max(height - top_pad - bottom_pad, 1)
|
||||||
|
|
||||||
|
def scale_x(value):
|
||||||
|
return left_pad + inner_width * (value / x_max)
|
||||||
|
|
||||||
|
def scale_y(value):
|
||||||
|
return top_pad + inner_height * (1.0 - ((value - y_min) / (y_max - y_min)))
|
||||||
|
|
||||||
|
plotted_points = [
|
||||||
|
{
|
||||||
|
'games': x,
|
||||||
|
'llr': round(y, 4),
|
||||||
|
'x': round(scale_x(x), 2),
|
||||||
|
'y': round(scale_y(y), 2),
|
||||||
|
}
|
||||||
|
for x, y in history
|
||||||
|
]
|
||||||
|
y_mid = (y_min + y_max) / 2.0
|
||||||
|
x_mid = x_max / 2.0
|
||||||
|
x_quarter = x_max / 4.0
|
||||||
|
x_three_quarter = 3.0 * x_max / 4.0
|
||||||
|
|
||||||
|
grid_lines = []
|
||||||
|
for value in [y_max, y_mid, y_min]:
|
||||||
|
y_pos = scale_y(value)
|
||||||
|
grid_lines.append(
|
||||||
|
'<line class="llr-grid-line" x1="%d" y1="%.2f" x2="%d" y2="%.2f"></line>'
|
||||||
|
% (left_pad, y_pos, width - right_pad, y_pos)
|
||||||
|
)
|
||||||
|
|
||||||
|
for value in [x_quarter, x_mid, x_three_quarter]:
|
||||||
|
x_pos = scale_x(value)
|
||||||
|
grid_lines.append(
|
||||||
|
'<line class="llr-grid-line" x1="%.2f" y1="%d" x2="%.2f" y2="%d"></line>'
|
||||||
|
% (x_pos, top_pad, x_pos, height - bottom_pad)
|
||||||
|
)
|
||||||
|
|
||||||
|
def interpolate_zero_crossing(a, b):
|
||||||
|
if a['llr'] == b['llr']:
|
||||||
|
return None
|
||||||
|
|
||||||
|
ratio = (0.0 - a['llr']) / (b['llr'] - a['llr'])
|
||||||
|
if ratio < 0.0 or ratio > 1.0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
x_pos = a['x'] + ratio * (b['x'] - a['x'])
|
||||||
|
return {
|
||||||
|
'games': a['games'] + ratio * (b['games'] - a['games']),
|
||||||
|
'llr': 0.0,
|
||||||
|
'x': round(x_pos, 2),
|
||||||
|
'y': round(scale_y(0.0), 2),
|
||||||
|
}
|
||||||
|
|
||||||
|
positive_segments = []
|
||||||
|
negative_segments = []
|
||||||
|
current_segment = [plotted_points[0]]
|
||||||
|
current_positive = plotted_points[0]['llr'] >= 0.0
|
||||||
|
|
||||||
|
for index in range(1, len(plotted_points)):
|
||||||
|
prev_point = plotted_points[index - 1]
|
||||||
|
point = plotted_points[index]
|
||||||
|
point_positive = point['llr'] >= 0.0
|
||||||
|
|
||||||
|
if point_positive == current_positive:
|
||||||
|
current_segment.append(point)
|
||||||
|
continue
|
||||||
|
|
||||||
|
crossing = interpolate_zero_crossing(prev_point, point)
|
||||||
|
if crossing:
|
||||||
|
current_segment.append(crossing)
|
||||||
|
|
||||||
|
if len(current_segment) >= 2:
|
||||||
|
if current_positive:
|
||||||
|
positive_segments.append(current_segment)
|
||||||
|
else:
|
||||||
|
negative_segments.append(current_segment)
|
||||||
|
|
||||||
|
current_segment = [crossing, point] if crossing else [point]
|
||||||
|
current_positive = point_positive
|
||||||
|
|
||||||
|
if len(current_segment) >= 2:
|
||||||
|
if current_positive:
|
||||||
|
positive_segments.append(current_segment)
|
||||||
|
else:
|
||||||
|
negative_segments.append(current_segment)
|
||||||
|
|
||||||
|
positive_paths = ''.join(
|
||||||
|
'<polyline class="llr-path-positive" points="%s"></polyline>' % (
|
||||||
|
' '.join('%.2f,%.2f' % (point['x'], point['y']) for point in segment)
|
||||||
|
)
|
||||||
|
for segment in positive_segments
|
||||||
|
)
|
||||||
|
negative_paths = ''.join(
|
||||||
|
'<polyline class="llr-path-negative" points="%s"></polyline>' % (
|
||||||
|
' '.join('%.2f,%.2f' % (point['x'], point['y']) for point in segment)
|
||||||
|
)
|
||||||
|
for segment in negative_segments
|
||||||
|
)
|
||||||
|
|
||||||
|
guides = []
|
||||||
|
for value, css_class in [
|
||||||
|
(test.lowerllr, 'llr-boundary'),
|
||||||
|
(0.0, 'llr-zero'),
|
||||||
|
(test.upperllr, 'llr-boundary'),
|
||||||
|
]:
|
||||||
|
if y_min <= value <= y_max:
|
||||||
|
y_pos = scale_y(value)
|
||||||
|
guides.append(
|
||||||
|
'<line class="%s" x1="%d" y1="%.2f" x2="%d" y2="%.2f"></line>'
|
||||||
|
% (css_class, left_pad, y_pos, width - right_pad, y_pos)
|
||||||
|
)
|
||||||
|
|
||||||
|
latest_x = plotted_points[-1]['x']
|
||||||
|
latest_y = plotted_points[-1]['y']
|
||||||
|
title = 'LLR history: current %.2f after %d games' % (test.currentllr, test.games)
|
||||||
|
history_json = html.escape(json.dumps(plotted_points, separators=(',', ':')))
|
||||||
|
|
||||||
|
svg = '''
|
||||||
|
<div class="llr-history-widget" data-history="{history_json}">
|
||||||
|
<div class="llr-history-chart">
|
||||||
|
<div class="llr-history-yaxis">
|
||||||
|
<div>{y_max_label}</div>
|
||||||
|
<div>{y_mid_label}</div>
|
||||||
|
<div>{y_min_label}</div>
|
||||||
|
</div>
|
||||||
|
<div class="llr-history-main">
|
||||||
|
<div class="llr-history-plot">
|
||||||
|
<svg class="llr-history-graph" viewBox="0 0 {width} {height}" width="{width}" height="{height}" role="img" aria-label="{title}">
|
||||||
|
<title>{title}</title>
|
||||||
|
<rect class="llr-bg" x="0" y="0" width="{width}" height="{height}" rx="6"></rect>
|
||||||
|
{grid_lines}
|
||||||
|
{guides}
|
||||||
|
{positive_paths}
|
||||||
|
{negative_paths}
|
||||||
|
<line class="llr-hover-line" x1="{latest_x:.2f}" y1="{top_pad:.2f}" x2="{latest_x:.2f}" y2="{hover_bottom:.2f}"></line>
|
||||||
|
<circle class="llr-hover-point" cx="{latest_x:.2f}" cy="{latest_y:.2f}" r="3"></circle>
|
||||||
|
<rect class="llr-hitbox" x="0" y="0" width="{width}" height="{height}" rx="6"></rect>
|
||||||
|
</svg>
|
||||||
|
<div class="llr-history-tooltip"></div>
|
||||||
|
</div>
|
||||||
|
<div class="llr-history-xaxis">
|
||||||
|
<div>0</div>
|
||||||
|
<div>{x_mid_label}</div>
|
||||||
|
<div>{x_max_label}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
'''.format(
|
||||||
|
width=width,
|
||||||
|
height=height,
|
||||||
|
title=html.escape(title),
|
||||||
|
history_json=history_json,
|
||||||
|
grid_lines=''.join(grid_lines),
|
||||||
|
guides=''.join(guides),
|
||||||
|
positive_paths=positive_paths,
|
||||||
|
negative_paths=negative_paths,
|
||||||
|
latest_x=latest_x,
|
||||||
|
latest_y=latest_y,
|
||||||
|
top_pad=top_pad,
|
||||||
|
hover_bottom=height - bottom_pad,
|
||||||
|
y_max_label=html.escape('%.2f' % (y_max)),
|
||||||
|
y_mid_label=html.escape('%.2f' % (y_mid)),
|
||||||
|
y_min_label=html.escape('%.2f' % (y_min)),
|
||||||
|
x_mid_label=html.escape('%d' % (round(x_mid))),
|
||||||
|
x_max_label=html.escape('%d g' % (x_max)),
|
||||||
|
)
|
||||||
|
|
||||||
|
return mark_safe(svg)
|
||||||
|
|
||||||
|
|
||||||
register = django.template.Library()
|
register = django.template.Library()
|
||||||
register.filter('oneDigitPrecision', oneDigitPrecision)
|
register.filter('oneDigitPrecision', oneDigitPrecision)
|
||||||
@@ -218,6 +423,7 @@ register.filter('cpuflagsBlock', cpuflagsBlock)
|
|||||||
register.filter('compilerBlock', compilerBlock)
|
register.filter('compilerBlock', compilerBlock)
|
||||||
register.filter('removePrefix', removePrefix)
|
register.filter('removePrefix', removePrefix)
|
||||||
register.filter('machine_name', machine_name)
|
register.filter('machine_name', machine_name)
|
||||||
|
register.filter('llr_history_graph', llr_history_graph)
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,22 @@ def read_git_credentials(engine):
|
|||||||
def path_join(*args):
|
def path_join(*args):
|
||||||
return "/".join([f.lstrip("/").rstrip("/") for f in args]).rstrip('/')
|
return "/".join([f.lstrip("/").rstrip("/") for f in args]).rstrip('/')
|
||||||
|
|
||||||
|
def llr_history_path(test_id):
|
||||||
|
return os.path.join(MEDIA_ROOT, 'llr_history', '%d.json' % (test_id))
|
||||||
|
|
||||||
|
def get_llr_history(test):
|
||||||
|
|
||||||
|
path = llr_history_path(test.id)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return [[0, 0.0]] if test.test_mode == 'SPRT' else []
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(path) as fin:
|
||||||
|
history = json.load(fin)
|
||||||
|
return history if history else [[0, 0.0]]
|
||||||
|
except Exception:
|
||||||
|
return [[0, 0.0]]
|
||||||
|
|
||||||
def extract_option(options, option):
|
def extract_option(options, option):
|
||||||
|
|
||||||
match = re.search(r'(?<={0}=")[^"]*'.format(option), options)
|
match = re.search(r'(?<={0}=")[^"]*'.format(option), options)
|
||||||
@@ -419,6 +435,7 @@ def update_test(request, machine):
|
|||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|
||||||
test = Test.objects.select_for_update().get(id=test_id)
|
test = Test.objects.select_for_update().get(id=test_id)
|
||||||
|
should_record_llr = False
|
||||||
|
|
||||||
if test.finished or test.deleted:
|
if test.finished or test.deleted:
|
||||||
return { 'stop' : True }
|
return { 'stop' : True }
|
||||||
@@ -452,6 +469,7 @@ def update_test(request, machine):
|
|||||||
test.passed = test.currentllr > test.upperllr
|
test.passed = test.currentllr > test.upperllr
|
||||||
test.failed = test.currentllr < test.lowerllr
|
test.failed = test.currentllr < test.lowerllr
|
||||||
test.finished = test.passed or test.failed
|
test.finished = test.passed or test.failed
|
||||||
|
should_record_llr = True
|
||||||
|
|
||||||
elif test.test_mode == 'GAMES':
|
elif test.test_mode == 'GAMES':
|
||||||
|
|
||||||
@@ -476,6 +494,9 @@ def update_test(request, machine):
|
|||||||
|
|
||||||
test.save()
|
test.save()
|
||||||
|
|
||||||
|
if should_record_llr:
|
||||||
|
record_llr_history(test)
|
||||||
|
|
||||||
# Update Result object; No risk from concurrent access
|
# Update Result object; No risk from concurrent access
|
||||||
Result.objects.filter(id=result_id).update(
|
Result.objects.filter(id=result_id).update(
|
||||||
games = F('games' ) + games,
|
games = F('games' ) + games,
|
||||||
@@ -504,3 +525,29 @@ def update_test(request, machine):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return [{}, { 'stop' : True }][test.finished]
|
return [{}, { 'stop' : True }][test.finished]
|
||||||
|
|
||||||
|
def record_llr_history(test, max_points=120):
|
||||||
|
|
||||||
|
history = get_llr_history(test)
|
||||||
|
point = [test.games, round(test.currentllr, 4)]
|
||||||
|
|
||||||
|
if history and history[-1][0] == point[0]:
|
||||||
|
history[-1] = point
|
||||||
|
else:
|
||||||
|
history.append(point)
|
||||||
|
|
||||||
|
if not history or history[0][0] != 0:
|
||||||
|
history.insert(0, [0, 0.0])
|
||||||
|
|
||||||
|
if len(history) > max_points:
|
||||||
|
keep = [history[0]]
|
||||||
|
interior = history[1:-1:2]
|
||||||
|
history = keep + interior + [history[-1]]
|
||||||
|
|
||||||
|
while len(history) > max_points:
|
||||||
|
history = [history[0]] + history[1:-1:2] + [history[-1]]
|
||||||
|
|
||||||
|
path = llr_history_path(test.id)
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, 'w') as fout:
|
||||||
|
json.dump(history, fout)
|
||||||
@@ -5,6 +5,83 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{% static 'copy_text.js' %}?{{ static_version }}"></script>
|
<script src="{% static 'copy_text.js' %}?{{ static_version }}"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
document.querySelectorAll('.llr-history-widget').forEach(function(widget) {
|
||||||
|
var history = JSON.parse(widget.dataset.history || '[]');
|
||||||
|
if (!history.length) return;
|
||||||
|
|
||||||
|
var svg = widget.querySelector('.llr-history-graph');
|
||||||
|
var plot = widget.querySelector('.llr-history-plot');
|
||||||
|
var hoverLine = widget.querySelector('.llr-hover-line');
|
||||||
|
var hoverPoint = widget.querySelector('.llr-hover-point');
|
||||||
|
var tooltip = widget.querySelector('.llr-history-tooltip');
|
||||||
|
var viewBox = svg.viewBox.baseVal;
|
||||||
|
|
||||||
|
function clamp(value, min, max) {
|
||||||
|
return Math.max(min, Math.min(max, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function setActivePoint(point) {
|
||||||
|
hoverLine.setAttribute('x1', point.x);
|
||||||
|
hoverLine.setAttribute('x2', point.x);
|
||||||
|
hoverPoint.setAttribute('cx', point.x);
|
||||||
|
hoverPoint.setAttribute('cy', point.y);
|
||||||
|
hoverPoint.classList.toggle('llr-hover-point-positive', point.llr >= 0);
|
||||||
|
hoverPoint.classList.toggle('llr-hover-point-negative', point.llr < 0);
|
||||||
|
|
||||||
|
tooltip.textContent = point.games + ' games | LLR ' + point.llr.toFixed(2);
|
||||||
|
tooltip.classList.add('active');
|
||||||
|
|
||||||
|
var left = clamp((point.x / viewBox.width) * plot.clientWidth + 8, 8, plot.clientWidth - tooltip.offsetWidth - 8);
|
||||||
|
var top = clamp((point.y / viewBox.height) * svg.clientHeight - tooltip.offsetHeight - 8, 2, svg.clientHeight - tooltip.offsetHeight - 2);
|
||||||
|
tooltip.style.left = left + 'px';
|
||||||
|
tooltip.style.top = top + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearActivePoint() {
|
||||||
|
tooltip.classList.remove('active');
|
||||||
|
hoverLine.classList.remove('active');
|
||||||
|
hoverPoint.classList.remove('active', 'llr-hover-point-positive', 'llr-hover-point-negative');
|
||||||
|
}
|
||||||
|
|
||||||
|
function nearestPoint(clientX) {
|
||||||
|
var rect = svg.getBoundingClientRect();
|
||||||
|
var localX = ((clientX - rect.left) / rect.width) * viewBox.width;
|
||||||
|
var best = history[0];
|
||||||
|
var bestDistance = Math.abs(best.x - localX);
|
||||||
|
|
||||||
|
for (var i = 1; i < history.length; i++) {
|
||||||
|
var distance = Math.abs(history[i].x - localX);
|
||||||
|
if (distance < bestDistance) {
|
||||||
|
best = history[i];
|
||||||
|
bestDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg.addEventListener('mousemove', function(event) {
|
||||||
|
setActivePoint(nearestPoint(event.clientX));
|
||||||
|
hoverLine.classList.add('active');
|
||||||
|
hoverPoint.classList.add('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.addEventListener('mouseleave', function() {
|
||||||
|
clearActivePoint();
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.addEventListener('mouseenter', function(event) {
|
||||||
|
setActivePoint(nearestPoint(event.clientX));
|
||||||
|
hoverLine.classList.add('active');
|
||||||
|
hoverPoint.classList.add('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
clearActivePoint();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@@ -192,6 +269,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{% if workload.test_mode == "SPRT" %}
|
||||||
|
<div class="llr-history-panel" title="LLR history over the lifetime of the test">
|
||||||
|
<div class="llr-history-label">LLR History</div>
|
||||||
|
{{workload|llr_history_graph}}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- SPSA Paramater Summary, for Tunes -->
|
<!-- SPSA Paramater Summary, for Tunes -->
|
||||||
|
|||||||
Reference in new issue
Block a user