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

Infinite Loop on my console #1971

Open
bahwemonami opened this issue Sep 25, 2024 · 0 comments
Open

Infinite Loop on my console #1971

bahwemonami opened this issue Sep 25, 2024 · 0 comments
Labels

Comments

@bahwemonami
Copy link

****### Hello guys,
I actually have an issue with the XAxisTickComponent.
I have an infinite loop on my console i dont understand while, even when i remove my XAxisTickComponent function, i dont understand why....

That is the error who is looping :

ERROR TypeError: Cannot read properties of undefined (reading 'constructor')
at XAxisTicksComponent.tickFormat (swimlane-ngx-charts.mjs:5329:15)
at XAxisTicksComponent__svg_g_2_Template (swimlane-ngx-charts.mjs:221:34)
at executeTemplate (core.mjs:11268:9)
at refreshView (core.mjs:12791:13)
at detectChangesInView$1 (core.mjs:13015:9)
at detectChangesInViewIfAttached (core.mjs:12978:5)
at detectChangesInEmbeddedViews (core.mjs:12935:13)
at refreshView (core.mjs:12815:9)
at detectChangesInView$1 (core.mjs:13015:9)
at detectChangesInViewIfAttached (core.mjs:12978:5)

And this is my xAxisTickFormating function :

` xAxisTickFormatting = (val: any): string => {
if (val === null || val === undefined) {
return ''; // Ou une autre valeur par défaut comme 'N/A'
}

const formatDate = (date: Date): string => {
  if (isNaN(date.getTime())) {
    return 'Date invalide';
  }
  return date.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit', year: 'numeric' });
};

if (val instanceof Date) {
  return formatDate(val);
}

if (typeof val === 'number') {
  return formatDate(new Date(val));
}

if (typeof val === 'string') {
  const date = new Date(val);
  if (!isNaN(date.getTime())) {
    return formatDate(date);
  }
  // Si la chaîne n'est pas une date valide, on la retourne telle quelle
  return val;
}

// Pour les objets et autres types
try {
  return String(val);
} catch (error) {
  console.error('Erreur lors de la conversion en chaîne :', error);
  return 'Erreur de format';
}

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant