fix: Translate dashboard chart labels (fixes #35941) (#35952)

* fix: translate dashboard chart labels (fixes #35941)

- Translate chart_name when setting chart.label in dashboard_view.js
- Translate chart name when adding existing charts to dashboard
- Translate chart_name fallback in ChartDialog process_data

This ensures dashboard chart labels are properly translated based on user's language preference.

* fix: translate chart dataset names in backend (fixes #35941)

- Translate chart.name when used as dataset name in get_chart_config
- Translate chart.name when used as dataset name in get_group_by_chart_config

This ensures chart dataset names (used in legends/tooltips) are also
translated, complementing the frontend widget label translation fix.
This commit is contained in:
SID 2026-01-15 11:05:19 -08:00 committed by GitHub
parent a9632b175e
commit 3f9957e244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View file

@ -218,7 +218,7 @@ def get_chart_config(chart, filters, timespan, timegrain, from_date, to_date):
else get_period(r[0], timegrain)
for r in result
],
"datasets": [{"name": chart.name, "values": [r[1] for r in result]}],
"datasets": [{"name": _(chart.name), "values": [r[1] for r in result]}],
}
@ -292,7 +292,7 @@ def get_group_by_chart_config(chart, filters) -> dict | None:
if data:
return {
"labels": [item.get("name", "Not Specified") for item in data],
"datasets": [{"name": chart.name, "values": [item["count"] for item in data]}],
"datasets": [{"name": _(chart.name), "values": [item["count"] for item in data]}],
}
return None

View file

@ -124,7 +124,7 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
? JSON.parse(settings.chart_config)
: {};
this.charts.map((chart) => {
chart.label = chart.chart_name;
chart.label = __(chart.chart_name);
chart.chart_settings = this.dashboard_chart_settings[chart.chart_name] || {};
});
this.render_dashboard_charts();
@ -464,7 +464,7 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
} else {
this.chart_group.new_widget.on_create({
chart_name: chart.chart,
label: chart.chart,
label: __(chart.chart),
name: chart.chart,
});
}

View file

@ -147,7 +147,7 @@ class ChartDialog extends WidgetDialog {
}
process_data(data) {
data.label = data.label ? data.label : data.chart_name;
data.label = data.label ? data.label : __(data.chart_name);
return data;
}
}