Fix chart data labels RTL alignment issue

- Force LTR direction on chart canvas elements via CSS
- Add locale: 'en-US' to chart options for consistent number formatting
- Add textDirection: 'ltr' to datalabels and tooltip configs
- Fixes background/text misalignment in Arabic RTL mode
This commit is contained in:
fahed
2026-02-03 16:40:30 +03:00
parent 0c7987493e
commit afe276541f
2 changed files with 14 additions and 1 deletions

View File

@@ -1990,3 +1990,12 @@ html[dir="rtl"] .chart-export-btn.visible {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
/* Force LTR for chart canvas - fixes RTL label alignment issues */
.chart-canvas-wrapper,
.chart-canvas-wrapper canvas,
.chart-container canvas,
.exportable-chart canvas {
direction: ltr !important;
text-align: left !important;
}

View File

@@ -48,6 +48,7 @@ export const createDataLabelConfig = (showDataLabels) => ({
padding: 4, padding: 4,
backgroundColor: 'rgba(255, 255, 255, 0.85)', backgroundColor: 'rgba(255, 255, 255, 0.85)',
borderRadius: 3, borderRadius: 3,
textDirection: 'ltr', // Force LTR for numbers - fixes RTL misalignment
formatter: (value) => { formatter: (value) => {
if (value == null) return ''; if (value == null) return '';
if (value >= 1000000) return (value / 1000000).toFixed(2) + 'M'; if (value >= 1000000) return (value / 1000000).toFixed(2) + 'M';
@@ -60,6 +61,7 @@ export const createDataLabelConfig = (showDataLabels) => ({
export const createBaseOptions = (showDataLabels) => ({ export const createBaseOptions = (showDataLabels) => ({
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
locale: 'en-US', // Force LTR number formatting
layout: { layout: {
padding: { padding: {
top: showDataLabels ? 25 : 5, top: showDataLabels ? 25 : 5,
@@ -75,7 +77,9 @@ export const createBaseOptions = (showDataLabels) => ({
padding: 12, padding: 12,
cornerRadius: 8, cornerRadius: 8,
titleFont: { size: 12 }, titleFont: { size: 12 },
bodyFont: { size: 11 } bodyFont: { size: 11 },
rtl: false,
textDirection: 'ltr'
}, },
datalabels: createDataLabelConfig(showDataLabels) datalabels: createDataLabelConfig(showDataLabels)
}, },