WordPress / wporg-theme-directory

15 stars 6 forks source link

New block: Downloads Chart #54

Closed ryelle closed 3 months ago

ryelle commented 3 months ago

Fixes #32 — Adds a new block for the download chart. This uses google charts like the current theme, with some slight styling updates (fonts, colors).

Note: This is using jQuery.getJSON + jsonp to get the data, since this endpoint doesn't have Access-Control-Allow-Origin: * and I was getting cors issues when using wp.apiFetch. If that's easy to fix, this can be updated to not rely on jQuery.

Screenshots

This can show up to 260 days (columns) of data, though the chart looks best when it's much smaller than that… Perhaps a future iteration could use a line chart instead?

Brand new theme, only up for 2 days:

Screen Shot 2024-05-09 at 18 51 02

Slightly older theme, 17 days:

Screen Shot 2024-05-09 at 18 50 14

Full 260 days of data (Twenty Twenty-Three)

Screen Shot 2024-05-09 at 18 50 43

Full 260 days of data, less popular theme, with hover state

Screenshot 2024-05-09 at 6 59 21 PM

How to test the changes in this Pull Request:

  1. View a theme (if working locally, make sure it has a real theme slug)
  2. There should be a graph on the page
  3. It should match the graph on the current site, in terms of data
StevenDufresne commented 3 months ago

I tested the PR; working as expected. I added a few minor comments.

As you note, we can probably make some nice improvements to these charts for readability but I also agree it's not relevant to this PR or issue.

👍