Skip to content

Add D3.js line chart for views over time on metrics page#2585

Open
lukepayyapilli wants to merge 3 commits intoMIT-LCP:devfrom
lukepayyapilli:feat/metrics-views-chart
Open

Add D3.js line chart for views over time on metrics page#2585
lukepayyapilli wants to merge 3 commits intoMIT-LCP:devfrom
lukepayyapilli:feat/metrics-views-chart

Conversation

@lukepayyapilli
Copy link
Contributor

@lukepayyapilli lukepayyapilli commented Feb 12, 2026

Summary

  • Added a D3.js line chart displayed side-by-side with the unique registered project views card on the metrics page.
  • Used D3 v3 and d3-tip (already bundled) with inline styles matching the existing charts.html pattern.
  • Chart data serialized via a _format_chart_data helper to keep the view focused on data retrieval.
  • Included fixtures, integration tests, and unit tests for the chart data.

Approach

The project already bundles D3 v3 and d3-tip for the site-wide statistics charts. Rather than introducing a new charting library, we reuse the same dependencies and follow the same pattern established in search/templates/search/charts.html.

Chart data is prepared in the view via a small _format_chart_data helper that serializes the chronological views-over-time data as JSON. This keeps the view as the presenter (gathering and shaping data for the template) while extracting the formatting detail into a named function. The template receives the JSON and renders it inline — no additional REST endpoint needed since the dataset is small (max ~100 months).

The chart is displayed in chronological order (oldest to newest) alongside the counts card, while the table below remains reverse-chronological (newest first) with pagination. Each format follows its natural convention.

Screenshot

Normal View:
Screenshot 2026-02-12 at 3 44 30 PM

Long History:
Screenshot 2026-02-17 at 11 31 06 AM

Short History:
Screenshot 2026-02-17 at 11 31 34 AM

No History:
Screenshot 2026-02-17 at 11 32 08 AM

Closes #2562

@lukepayyapilli lukepayyapilli force-pushed the feat/metrics-views-chart branch from 8fb5f96 to 18e3e36 Compare February 17, 2026 16:16
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.

Metrics: Add visualization chart for views over time

1 participant