Merge pull request #37714 from fix-graphic-label-translation-issue
fix: graphic label translation issue completely
This commit is contained in:
commit
4e7b19a00e
1 changed files with 21 additions and 0 deletions
|
|
@ -568,6 +568,7 @@ export default class ChartWidget extends Widget {
|
|||
|
||||
async render() {
|
||||
let setup_dashboard_chart = () => {
|
||||
this.translate_chart_labels();
|
||||
const chart_args = this.get_chart_args();
|
||||
|
||||
const is_circular_chart = ["Pie", "Donut", "Percentage"].includes(this.chart_doc.type);
|
||||
|
|
@ -702,6 +703,26 @@ export default class ChartWidget extends Widget {
|
|||
return chart_args;
|
||||
}
|
||||
|
||||
translate_chart_labels() {
|
||||
if (this.data && Array.isArray(this.data.labels)) {
|
||||
this.data.labels = this.data.labels.map((label) => {
|
||||
if (label === null || label === undefined) {
|
||||
return label;
|
||||
}
|
||||
return typeof label === "string" ? __(label) : label;
|
||||
});
|
||||
}
|
||||
|
||||
if (this.data && Array.isArray(this.data.datasets)) {
|
||||
this.data.datasets = this.data.datasets.map((dataset) => {
|
||||
if (dataset && typeof dataset.name === "string") {
|
||||
dataset.name = __(dataset.name);
|
||||
}
|
||||
return dataset;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get_chart_colors() {
|
||||
let colors = [];
|
||||
if (this.chart_doc.y_axis.length) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue