Skip to content

Premium Analytics: Keep the first and last time-axis tick labels inside the chart - #52112

Draft
chihsuan wants to merge 1 commit into
trunkfrom
change/uni-753-axis-edge-labels
Draft

Premium Analytics: Keep the first and last time-axis tick labels inside the chart#52112
chihsuan wants to merge 1 commit into
trunkfrom
change/uni-753-axis-edge-labels

Conversation

@chihsuan

@chihsuan chihsuan commented Sep 9, 2026

Copy link
Copy Markdown
Member

Fixes UNI-753.

Proposed changes

  • Reserve half the width of the first and last x-axis tick labels in useChartMargin, so a label centred on the edge of the plot area no longer hangs outside the chart SVG.
  • Measure those labels at the axis font size. The theme carries a unitless fontSize, which CSSOM drops, so they were otherwise measured at whatever the host body inherits.
  • Drop the hardcoded right: 0 margin override from the Premium Analytics comparative line and bar charts, which is why the last date was clipped there.
  • Skip the reservation when the x axis is hidden, and leave the compact sparkline branch on exactly the margins it had.

The y-axis half of useChartMargin already measures its widest label to size its gutter; the x-axis half only had a fixed 20px. Premium Analytics then overrode that to 0, on the reasoning that "the y-axis is on the left, so the right margin is always 0", which missed that the right margin is what the last x-axis label needs.

Related product discussion/links

  • UNI-753

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Open the Premium Analytics dashboard on a site that has stats data, Traffic tab, Last 30 days.
  • Look at the right-hand end of the Traffic summary chart's horizontal axis. The final date should be fully readable rather than sliced in half.
  • Switch the chart to bars with the control in the widget header and check the same thing.
  • Worth a look in a locale where September abbreviates to "Sept" (en-GB and most non-US English), which is where this was first noticed.

Before:

Screenshot 2026-09-09 at 12 07 21 PM

After:

Screenshot 2026-09-09 at 12 31 18 PM

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the change/uni-753-axis-edge-labels branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/uni-753-axis-edge-labels
bin/jetpack-downloader test jetpack-mu-wpcom-plugin change/uni-753-axis-edge-labels

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@chihsuan chihsuan changed the title UNI-753: Keep the first and last time-axis tick labels inside the chart Chart: Keep the first and last time-axis tick labels inside the chart Sep 9, 2026
@chihsuan chihsuan changed the title Chart: Keep the first and last time-axis tick labels inside the chart Premium Analytics: Keep the first and last time-axis tick labels inside the chart Sep 9, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/js-packages/charts/src/hooks/use-chart-margin.tsx 51/51 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-comparative-bar/comparative-bar-chart.tsx 64/65 (98.46%) -0.02% 0 💚
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-comparative-line/comparative-line-chart.tsx 38/52 (73.08%) -0.51% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/js-packages/charts/src/utils/get-edge-tick-widths.ts 7/7 (100.00%) 💚

Full summary · PHP report · JS report

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant