AnjanJ / AnjanJ/rails_error_dashboard
Chart axes ignore the dashboard locale, and BarChart axis titles are inverted
- Dominant language
- Ruby
- Stars
- 92
- Forks
- 9
- Avg merge
- 11h 34m
- Merged PRs (30d)
- 54
Description
Reported by @gmarziou while reviewing the French locale in #158. Three defects in the same area, none of them translation problems.
## 1. Chart date axes render in English regardless of locale
Every chart with a date axis shows English month names ("Aug 6") in all eleven locales.
RED has two working date paths, and charts use neither:
- **In the page** — `local_time` emits ``, re-rendered by `formatDateTime()` using the localized names in `red.js.*`
- **In email** — `red_mail_time` substitutes the same vocabulary server-side before `strftime`
Chart labels take a third route: `errors_over_time` is `group_by_day(:occurred_at).count`, and the raw `Date` keys go straight to Chartkick → Chart.js, which formats them with its own English defaults.
Two sites bypass i18n with direct `strftime`, which is not locale-aware:
- `app/views/rails_error_dashboard/errors/platform_comparison.html.erb:361` — `strftime('%b %d')`
- `app/views/rails_error_dashboard/errors/correlation.html.erb:39,40,48,49` — `strftime("%b %d")`
`MailerI18nHelper` already documents this exact trap; the chart code predates it.
## 2. `BarChart` axis titles are inverted
Chartkick 5.0.1, `renderColumnChart`:
```js
if ("bar" === e) { var n = o(w, C); n.indexAxis = "y"; ... }
```
`BarChart` is horizontal — categories on y, values on x. Both of ours claim the opposite:
- `analytics.html.erb:175-176` — Top Errors: `xtitle: "Error Type"`, `ytitle: "Count"` (swapped)
- `analytics.html.erb:559` — MTTR by platform: no titles, but same chart type
The `ColumnChart`s (Errors by Hour, by Version) are vertical and correct as written.
## 3. Redundant English axis titles, plus one live untranslated string
Every chart sets axis titles twice — Chartkick's `xtitle`/`ytitle` hardcoded in English, and `library.scales.*.title.text` via `red_js_t`. The i18n sprint wired the second and missed the first.
The merge order in 5.0.1 is:
```js
p.xtitle && s(h, p.xtitle), p.ytitle && l(h, p.ytitle), h = o(h, p.library || {})
```
`o()` deep-merges `library` last into the same `scales.x.title.text` slot, so **the translated string wins today**. This is latent, not visible — but it becomes live on any Chartkick upgrade or merge-order change.
Affected: `analytics.html.erb:78-79, 175-176, 217-218, 425-426`.
One genuinely untranslated string: `analytics.html.erb:561` — `suffix: " hours"` on the MTTR chart.
Keys already exist in all eleven locales: `axis_date`, `axis_hour`, `axis_error_type`, `axis_count`, `axis_number_of_errors`, `axis_hours`. The literals just need deleting.
## Fix
1. Feed localized month/day names from `red.js.*` to Chart.js; replace the six direct `strftime` calls
2. Swap the two `BarChart` axis titles
3. Delete the redundant `xtitle`/`ytitle`; add a key for the hours suffix
Needs a locale-switched visual check on Analytics, Platform Comparison and Correlation — `bin/i18n-check` cannot catch any of this, since it verifies key structure, not what reaches the canvas.
Contributor guide
Research direction
Start with the chart definitions and direct strftime calls in analytics.html.erb, platform_comparison.html.erb, and correlation.html.erb, then trace the localized vocabulary in red.js.* and the existing MailerI18nHelper guidance. Compare BarChart axis orientation with Chartkick 5.0.1 and inspect the affected library options. Done means localized date labels and suffixes, correct titles without redundant literals, and a locale-switched visual check on Analytics, Platform Comparison, and Correlation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- chart.js, javascript, rails, ruby
- Domain
- frontend, internationalization, localization, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100