Skip to content

Commit 646dff1

Browse files
authored
Downloads chart: fix placement of cursor (#8574)
1 parent d3d6ff7 commit 646dff1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkg/web_app/lib/src/widget/downloads_chart/widget.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void drawChart(
232232
}
233233

234234
final chart = SVGGElement();
235-
svg.replaceChildren(chart);
235+
svg.append(chart);
236236

237237
// Axis and ticks
238238

@@ -449,7 +449,7 @@ void drawChart(
449449
hideCursor(1);
450450

451451
svg.onMouseMove.listen((e) {
452-
final boundingRect = chart.getBoundingClientRect();
452+
final boundingRect = svg.getBoundingClientRect();
453453
if (e.x < boundingRect.x + xZero ||
454454
e.x > boundingRect.x + xMax ||
455455
e.y < boundingRect.y + yMax ||
@@ -465,10 +465,8 @@ void drawChart(
465465
'top:${e.y + toolTipOffsetFromMouse + document.scrollingElement!.scrollTop}px;'
466466
'left:${e.x}px;');
467467

468-
final pointPercentage =
469-
(e.x - chart.getBoundingClientRect().x - xZero) / chartWidth;
468+
final pointPercentage = (e.x - boundingRect.x - xZero) / chartWidth;
470469
final nearestIndex = ((values.length - 1) * pointPercentage).round();
471-
472470
final selectedDay =
473471
computeDateForWeekNumber(newestDate, values.length, nearestIndex);
474472
if (selectedDay == lastSelectedDay) return;
@@ -497,7 +495,7 @@ void drawChart(
497495
..append(rangeText);
498496

499497
final suffix = (displayMode == DisplayMode.percentage)
500-
? '(${(downloads[rangeIndex] * 100 / totals[nearestIndex]).toStringAsPrecision(2)}%)'
498+
? ' (${(downloads[rangeIndex] * 100 / totals[nearestIndex]).toStringAsPrecision(2)}%)'
501499
: '';
502500
final text =
503501
'${formatWithThousandSeperators(downloads[rangeIndex])}$suffix';

0 commit comments

Comments
 (0)