Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve image graph axis display in email reports #20953

Merged
merged 6 commits into from
Jul 9, 2023
Merged

Conversation

bx80
Copy link
Contributor

@bx80 bx80 commented Jun 30, 2023

Description:

Fixes #17747

When using the 🇫🇷 French language locale, numbers with thousand separators are shown with boxes instead of the expected separator. This is because the number formatter is using a narrow non-breaking space (NNBSP) as the thousand separator which is not supported by all fonts.

graph-font-before

This PR makes the following changes to image graphs:

  • If the unifont is available then it will be used for French and the NNBSP will be shown correctly.
  • If the unifont is not available, then the narrow non-breaking space character will be replaced with a normal space so it displays correctly.
  • Graph margins have been increased to avoid clipping the axis labels when using the unifont.

This is the same report using unifont:
graph-font-after-unifont

And again without unifont:
graph-font-after-no-unifont

Review

@bx80 bx80 added Bug For errors / faults / flaws / inconsistencies etc. c: Design / UI For issues that impact Matomo's user interface or the design overall. labels Jun 30, 2023
@bx80 bx80 added this to the 5.0.0 milestone Jun 30, 2023
@bx80 bx80 self-assigned this Jun 30, 2023
@bx80
Copy link
Contributor Author

bx80 commented Jun 30, 2023

@sgiehl I haven't added a UI test for this yet as it would require a report with >1,000 visits and the UI test fixture only has 514 visits in total. Modifying the omnifixture to add another 500 visits which will then slow down all UI test suites doesn't seem like a good idea for a single test. Any other suggestions?

@michalkleiner
Copy link
Contributor

Could the same issue occur on the x-axis? Could there be a report that has thousands on the x-axis and would be affected by the same problem? Wondering whether we should apply this to all point labels on any axis in a more generic way.

@bx80
Copy link
Contributor Author

bx80 commented Jun 30, 2023

It's the formatXAxis method itself which is introducing the problem character, so since we don't have any method that applies similiar number formatting to the X axis then this shouldn't be an issue.

@bx80 bx80 added the Needs Review PRs that need a code review label Jul 3, 2023
Copy link
Contributor

@michalkleiner michalkleiner left a comment

Choose a reason for hiding this comment

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

This looks good to me but would still prefer @sgiehl's review as well.

@michalkleiner michalkleiner requested a review from sgiehl July 3, 2023 12:12
plugins/ImageGraph/API.php Outdated Show resolved Hide resolved
const TOP_GRID_MARGIN_HORIZONTAL_GRAPH = 1;
const RIGHT_GRID_MARGIN_HORIZONTAL_GRAPH = 4;
const TOP_GRID_MARGIN_HORIZONTAL_GRAPH = 10;
const RIGHT_GRID_MARGIN_HORIZONTAL_GRAPH = 20;
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the changed screenshots it looks like the adjustments were actually only needed for the evolution chart.
The other charts now have additional unused space. Wouldn't it been have possible to only adjust the evolution one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other charts are also drawn very close to the edge of the image, for example the horizontal bar chart would likely clip the bar totals for numbers with four digits. I think adding few extra pixels of padding around them reduces the likelihood of other clipping issues and will look better if the images are embedded with other text.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we would actually need to automatically increase those margins if higher values are meant to be printed.
It might make sense to adjust the UI tests so they use higher values. I think we could achieve that without tracking additional numbers but simply modifying the results. I'll try something an maybe push some changes here to achieve that if easily possible.

@bx80 bx80 requested a review from sgiehl July 7, 2023 02:08
@sgiehl
Copy link
Member

sgiehl commented Jul 7, 2023

@bx80 I've pushed some changes so the imagegraph tests run with higher values. Feel free to check if that looks good to you. Otherwise I think this PR would be read to merge.

@bx80
Copy link
Contributor Author

bx80 commented Jul 9, 2023

Thanks @sgiehl, the tests should be more robust with higher values 👍

@bx80 bx80 merged commit 6bba0ba into 5.x-dev Jul 9, 2023
18 of 20 checks passed
@bx80 bx80 deleted the m17747-graph-font-fix branch July 9, 2023 22:22
@sgiehl sgiehl added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Design / UI For issues that impact Matomo's user interface or the design overall. Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thousand numbers are wrongly displayed in email reports
3 participants