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

Resolved Issue #1695: Sample values in Chart activity are not initialized #1696

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions activities/Chart.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,20 @@ const app = new Vue({
});
},
localized() {
this.SugarL10n.localize(this.l10n);
document.getElementById("export-csv-button").title = this.l10n.stringexportAsCSV;
document.getElementById("export-img-button").title = this.l10n.stringSaveImage;

this.SugarL10n.localize(this.l10n)
document.getElementById('export-csv-button').title = this.l10n.stringexportAsCSV
document.getElementById('export-img-button').title = this.l10n.stringSaveImage
// Add this to ensure translations are ready
if (this.tabularData.length === 0) {
this.onJournalNewInstance()
} else {
// Refresh existing labels with translations
this.tabularData = this.tabularData.map((data) => ({
...data,
x: data.x.startsWith('EgLabel') ? this.SugarL10n.get(data.x) : data.x,
y: data.y,
}))
}
},

addData() {
Expand Down Expand Up @@ -273,14 +283,18 @@ const app = new Vue({
const randArr = this.shuffleArray([1, 2, 3, 4, 5, 6]);
for(let i = 0; i < 3; i++) {
const label = "EgLabel" + randArr[i];
const translatedLabel = this.SugarL10n.get(label);
// Add fallback in case translation fails
this.tabularData.push({
x: this.SugarL10n.get(label),
x: translatedLabel || label,
y: randArr[i] + 6 + "",
})
});
// Log for debugging
console.log(`Label: ${label}, Translated: ${translatedLabel}`);
}
this.pref.labels.x = this.SugarL10n.get("Sports");
this.pref.labels.y = this.SugarL10n.get("Students");
this.updateActivityTitle(this.l10n.stringChartActivity)
this.updateActivityTitle(this.l10n.stringChartActivity);

const header = [this.pref.labels.x, this.pref.labels.y];
this.$refs.csvView.updateJsonData(this.tabularData, header, true);
Expand Down