Skip to content

Comments

feat: add downloads estimations on large charts#1177

Merged
danielroe merged 4 commits intonpmx-dev:mainfrom
graphieros:main
Feb 7, 2026
Merged

feat: add downloads estimations on large charts#1177
danielroe merged 4 commits intonpmx-dev:mainfrom
graphieros:main

Conversation

@graphieros
Copy link
Contributor

@graphieros graphieros commented Feb 7, 2026

  • bump vue-data-ui to 3.14.9 to track minimap events
  • add translation for 'estimation' (en & fr)
  • implement estimations for incomplete endDate, for 'monthly' and 'yearly' granularities
  • always display the last data label
  • fix NaN on scale labels

@vercel
Copy link

vercel bot commented Feb 7, 2026

Deployment failed with the following error:

There is no GitHub account connected to this Vercel account.

@vercel
Copy link

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 7, 2026 9:53pm

Request Review

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/en-GB.json Localization changed, will be marked as complete.
lunaria/files/en-US.json Source changed, localizations will be marked as outdated.
lunaria/files/fr-FR.json Localization changed, will be marked as complete.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

The pull request enhances the DownloadAnalytics component with estimation overlay functionality for incomplete data buckets. It introduces zoom state tracking, end-date period-end detection, and utility functions for UTC bucket calculations and completion ratios. The component now renders SVG overlays for estimations and last datapoints, includes a pending state overlay during loading, and updates chart configuration for dynamic Y-axis scaling. Legend logic is extended to display an estimation item for monthly and yearly granularities. Translation keys for "legend_estimation" are added across locale files (English and French variants), and the vue-data-ui dependency is updated from 3.14.8 to 3.14.9.

Possibly related PRs

Suggested reviewers

  • danielroe
  • shuuji3
  • garthdw
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is directly related to the changeset and accurately describes the key modifications made, including the dependency bump, translation additions, and estimation implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 10.06289% with 143 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Package/DownloadAnalytics.vue 10.06% 86 Missing and 57 partials ⚠️

📢 Thoughts on this report? Let us know!

@danielroe danielroe added this pull request to the merge queue Feb 7, 2026
Merged via the queue into npmx-dev:main with commit a0ea788 Feb 7, 2026
16 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/components/Package/DownloadAnalytics.vue (1)

1139-1264: Consider extracting per-series SVG building to keep drawEstimationLine manageable.

This function is well over the 50‑line guideline; splitting the per‑series SVG generation into a helper would reduce complexity and make unit testing easier.

As per coding guidelines: "Keep functions focused and manageable (generally under 50 lines)".

Comment on lines +1284 to +1306
function drawLastDatapointLabel(svg: Record<string, any>) {
const data = Array.isArray(svg?.data) ? svg.data : []
if (!data.length) return ''

const dataLabels: string[] = []

for (const serie of data) {
const lastPlot = serie.plots.at(-1)

dataLabels.push(`
<text
text-anchor="start"
dominant-baseline="middle"
x="${lastPlot.x + 12}"
y="${lastPlot.y}"
font-size="24"
fill="${colors.value.fg}"
stroke="${colors.value.bg}"
stroke-width="1"
paint-order="stroke fill"
>
${compactNumberFormatter.value.format(Number.isFinite(lastPlot.value) ? lastPlot.value : 0)}
</text>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard serie.plots before dereferencing the last plot.

Without an array check, serie.plots.at(-1) and lastPlot.x will throw if a series has no plots. Add a safeguard to keep this type-safe.

Possible fix
-  for (const serie of data) {
-    const lastPlot = serie.plots.at(-1)
-
-    dataLabels.push(`
+  for (const serie of data) {
+    const plots = Array.isArray(serie?.plots) ? serie.plots : []
+    const lastPlot = plots.at(-1)
+    if (!lastPlot) continue
+
+    dataLabels.push(`
       <text
         text-anchor="start"
         dominant-baseline="middle"
         x="${lastPlot.x + 12}"
         y="${lastPlot.y}"

As per coding guidelines: "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants