Skip to content

Fix Gantt chart display issues#111

Open
vilpessoa wants to merge 1 commit into
mainfrom
56cryi-codex/fix-ganttchart-component-inconsistencies
Open

Fix Gantt chart display issues#111
vilpessoa wants to merge 1 commit into
mainfrom
56cryi-codex/fix-ganttchart-component-inconsistencies

Conversation

@vilpessoa
Copy link
Copy Markdown
Owner

@vilpessoa vilpessoa commented Jul 28, 2025

Summary

  • correct TodayLine positioning and visibility
  • restore completion label and outline in GanttBar
  • render early/late stripes properly
  • keep today line offset zero in chart

Testing

  • npx prettier --write src/components/Gantt/TodayLine.tsx src/components/Gantt/GanttBar.tsx src/components/Gantt/GanttChart.tsx
  • npm run lint (fails: various unused vars)
  • npm test (fails: missing Supabase env vars)

https://chatgpt.com/codex/tasks/task_e_6887897e9284832397f0abb9912aa3b4

Summary by CodeRabbit

  • Novos Recursos
    • Linha de "hoje" no gráfico de Gantt agora aceita deslocamento horizontal personalizado e apresenta posicionamento aprimorado.
  • Aprimoramentos de Interface
    • Indicadores de dias adiantados e atrasados reposicionados e com novo estilo visual dentro das barras do Gantt.
    • Exibição da porcentagem de progresso movida para o canto superior direito da barra, com estilo atualizado.
    • Barra principal do Gantt recebeu borda e sombra interna para melhor destaque visual.
  • Estilo
    • Ajustes de formatação e padronização no código para maior legibilidade, sem impacto funcional.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 28, 2025

Walkthrough

As alterações concentram-se na melhoria do cálculo e estilização dos componentes do gráfico de Gantt. O componente GanttBar ajusta a lógica de cálculo de dias adiantados e atrasados, reposiciona e estiliza indicadores visuais, e aprimora o componente TodayLine para aceitar um deslocamento horizontal opcional. O GanttChart recebe apenas ajustes de formatação e estilo.

Changes

Cohort / File(s) Change Summary
Lógica e Estilização do GanttBar
src/components/Gantt/GanttBar.tsx
Refatoração dos cálculos de earlyDays e lateDays para garantir valores não-negativos e lógica simplificada. Mudança do posicionamento e estilo do percentual de progresso. Indicadores de dias adiantados/atrasados agora usam gradientes e ficam dentro da barra principal. O componente TodayLine foi atualizado para aceitar um deslocamento horizontal opcional (offsetX) e lógica de posicionamento baseada no dia do mês.
Formatação e Estilo do GanttChart
src/components/Gantt/GanttChart.tsx
Alterações puramente de formatação: troca de aspas simples por duplas, inclusão de vírgulas finais, ajustes de indentação e espaçamento para padronização e legibilidade. Nenhuma alteração funcional ou de fluxo de controle.
Atualização do TodayLine
src/components/Gantt/TodayLine.tsx
Simplificação do cálculo de posição horizontal usando o dia do mês, inclusão da prop opcional offsetX (padrão 320), ajustes de classes CSS para visibilidade responsiva e remoção de opacidade. Interface de props e assinatura do componente atualizadas para aceitar o novo parâmetro.

Sequence Diagram(s)

sequenceDiagram
    participant Usuário
    participant GanttChart
    participant GanttBar
    participant TodayLine

    Usuário->>GanttChart: Renderiza gráfico de Gantt
    GanttChart->>GanttBar: Renderiza barras de tarefas
    GanttBar->>TodayLine: Renderiza linha de hoje (passando offsetX)
    TodayLine-->>GanttBar: Calcula posição da linha de hoje
    GanttBar-->>GanttChart: Renderiza barras com indicadores e progresso
Loading

Estimated code review effort

🎯 2 (Simples) | ⏱️ ~8 minutos

Poem

🐇
No Gantt eu pulo sem parar,
Dias adiantados, atrasos a calcular.
O progresso agora brilha no canto,
E a linha de hoje dança com encanto.
Com gradientes e sombra a reluzir,
O gráfico ficou fácil de seguir!
🗓️✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 56cryi-codex/fix-ganttchart-component-inconsistencies

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8060e37 and b2e2fa5.

📒 Files selected for processing (3)
  • src/components/Gantt/GanttBar.tsx (1 hunks)
  • src/components/Gantt/GanttChart.tsx (14 hunks)
  • src/components/Gantt/TodayLine.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use tipagem forte e evite any em TypeScript

Files:

  • src/components/Gantt/TodayLine.tsx
  • src/components/Gantt/GanttChart.tsx
  • src/components/Gantt/GanttBar.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{js,jsx,ts,tsx}: Evite console.log em produção
Organize imports e remova dead code apenas nos arquivos em escopo
Para parâmetros não utilizados, utilize prefixo _ (ex: _unusedParam)

Files:

  • src/components/Gantt/TodayLine.tsx
  • src/components/Gantt/GanttChart.tsx
  • src/components/Gantt/GanttBar.tsx
**/*.{jsx,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Mantenha uso de hooks React (useEffect, useState) se já presentes, a menos que autorizado

Files:

  • src/components/Gantt/TodayLine.tsx
  • src/components/Gantt/GanttChart.tsx
  • src/components/Gantt/GanttBar.tsx
🧠 Learnings (3)
src/components/Gantt/TodayLine.tsx (2)

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{jsx,tsx} : Mantenha uso de hooks React (useEffect, useState) se já presentes, a menos que autorizado

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{ts,tsx} : Use tipagem forte e evite any em TypeScript

src/components/Gantt/GanttChart.tsx (4)

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{jsx,tsx} : Mantenha uso de hooks React (useEffect, useState) se já presentes, a menos que autorizado

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Para parâmetros não utilizados, utilize prefixo _ (ex: _unusedParam)

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Organize imports e remova dead code apenas nos arquivos em escopo

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{ts,tsx} : Use tipagem forte e evite any em TypeScript

src/components/Gantt/GanttBar.tsx (3)

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{jsx,tsx} : Mantenha uso de hooks React (useEffect, useState) se já presentes, a menos que autorizado

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Organize imports e remova dead code apenas nos arquivos em escopo

Learnt from: CR
PR: vilpessoa/Intake#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T15:07:24.036Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Para parâmetros não utilizados, utilize prefixo _ (ex: _unusedParam)

🧬 Code Graph Analysis (1)
src/components/Gantt/TodayLine.tsx (1)
src/components/Gantt/GanttBar.tsx (1)
  • TodayLine (117-130)
🔇 Additional comments (9)
src/components/Gantt/GanttChart.tsx (5)

1-22: Formatação dos imports melhorada.

As alterações de formatação nos imports estão consistentes, convertendo aspas simples para duplas e melhorando a organização. A mudança está alinhada com as práticas de formatação do projeto.


34-40: Formatação dos parâmetros da interface melhorada.

A formatação multilinhas dos parâmetros da função onFiltrosChange melhora a legibilidade do código.


44-50: Formatação dos parâmetros do componente melhorada.

A formatação multilinhas dos parâmetros do componente funcional melhora a legibilidade e consistência.


52-56: Formatação dos hooks melhorada.

A formatação do estado projetosExpandidos com quebras de linha adequadas melhora a legibilidade.


549-549: Verifique o override de offsetX em TodayLine

O componente TodayLine declara offsetX com valor padrão de 320, mas no GanttChart ele está recebendo offsetX={0}. Confirme se esse override é intencional ou se o prop deve ser removido para usar o valor padrão.

Ponto de atenção:

  • src/components/Gantt/GanttChart.tsx: linha 549
    <TodayLine larguraDia={larguraDia} offsetX={0} />
  • Valor padrão em src/components/Gantt/TodayLine.tsx (linha 11): offsetX = 320,
src/components/Gantt/TodayLine.tsx (2)

4-7: Interface bem definida com tipagem forte.

A interface TodayLineProps está bem estruturada com tipagem forte, seguindo as diretrizes do projeto. A propriedade offsetX opcional com valor padrão é uma boa prática.


17-17: Z-index alterado pode afetar a visibilidade.

A mudança do z-index de um valor maior para z-0 pode fazer com que a linha "hoje" apareça atrás de outros elementos do gráfico, reduzindo sua visibilidade.

Verifique se a linha "hoje" permanece visível sobre as barras do Gantt após esta alteração. Se necessário, considere usar um z-index maior como z-10.

src/components/Gantt/GanttBar.tsx (2)

48-54: Cálculo de atraso melhorado.

A lógica de cálculo de lateDays está correta, considerando tanto projetos finalizados quanto em andamento que passaram da data planejada.


85-88: Reposicionamento do percentual de progresso.

O reposicionamento do percentual para o canto superior direito (-top-4 right-0) melhora a visibilidade e evita sobreposição com o conteúdo da barra.

Comment on lines +42 to +46
const inicioPlanejado = dayjs(projeto.dataInicioPlanjada);
const inicioReal = projeto.dataInicioReal
? dayjs(projeto.dataInicioReal)
: inicioPlanejado;
const earlyDays = Math.max(0, inicioPlanejado.diff(inicioReal, "day"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Lógica de cálculo de antecipação pode estar incorreta.

A lógica atual usa inicioPlanejado como fallback quando dataInicioReal está ausente, mas isso sempre resultará em earlyDays = 0. Se o objetivo é calcular antecipação, a lógica deveria comparar quando o projeto realmente começou versus quando estava planejado para começar.

-  const inicioReal = projeto.dataInicioReal
-    ? dayjs(projeto.dataInicioReal)
-    : inicioPlanejado;
-  const earlyDays = Math.max(0, inicioPlanejado.diff(inicioReal, "day"));
+  const earlyDays = projeto.dataInicioReal 
+    ? Math.max(0, inicioPlanejado.diff(dayjs(projeto.dataInicioReal), "day"))
+    : 0;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const inicioPlanejado = dayjs(projeto.dataInicioPlanjada);
const inicioReal = projeto.dataInicioReal
? dayjs(projeto.dataInicioReal)
: inicioPlanejado;
const earlyDays = Math.max(0, inicioPlanejado.diff(inicioReal, "day"));
const inicioPlanejado = dayjs(projeto.dataInicioPlanjada);
const earlyDays = projeto.dataInicioReal
? Math.max(0, inicioPlanejado.diff(dayjs(projeto.dataInicioReal), "day"))
: 0;
🤖 Prompt for AI Agents
In src/components/Gantt/GanttBar.tsx around lines 42 to 46, the calculation for
earlyDays uses inicioPlanejado as a fallback for inicioReal, which causes
earlyDays to always be zero when dataInicioReal is missing. To fix this, adjust
the logic to handle the absence of dataInicioReal appropriately, such as
treating missing inicioReal as no early start or using a different fallback,
ensuring the diff calculation correctly reflects the project's actual start date
versus the planned start date.

Comment on lines +112 to +130
interface TodayLineProps {
larguraDia: number;
offsetX?: number;
}

export const TodayLine: React.FC<TodayLineProps> = ({
larguraDia,
offsetX = 320,
}) => {
const hojeIndex = dayjs().date() - 1;

return (
<div
className="absolute top-0 bottom-0 w-[2px] bg-blue-500 z-0 pointer-events-none md:block hidden"
style={{ left: `${offsetX + hojeIndex * larguraDia}px` }}
data-export="false"
/>
);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicação de código: componente TodayLine.

O componente TodayLine está duplicado neste arquivo e também existe em src/components/Gantt/TodayLine.tsx. Isso viola o princípio DRY e pode causar inconsistências.

Remova a definição duplicada e importe o componente do arquivo dedicado:

-interface TodayLineProps {
-  larguraDia: number;
-  offsetX?: number;
-}
-
-export const TodayLine: React.FC<TodayLineProps> = ({
-  larguraDia,
-  offsetX = 320,
-}) => {
-  const hojeIndex = dayjs().date() - 1;
-
-  return (
-    <div
-      className="absolute top-0 bottom-0 w-[2px] bg-blue-500 z-0 pointer-events-none md:block hidden"
-      style={{ left: `${offsetX + hojeIndex * larguraDia}px` }}
-      data-export="false"
-    />
-  );
-};
+import { TodayLine } from "./TodayLine";
🤖 Prompt for AI Agents
In src/components/Gantt/GanttBar.tsx around lines 112 to 130, the TodayLine
component is duplicated as it also exists in src/components/Gantt/TodayLine.tsx.
To fix this, remove the TodayLine component definition from GanttBar.tsx and
instead import TodayLine from the dedicated file
src/components/Gantt/TodayLine.tsx. This will eliminate duplication and ensure a
single source of truth for the component.

larguraDia,
offsetX = 320,
}) => {
const hojeIndex = dayjs().date() - 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Verificar lógica de cálculo do dia atual.

O cálculo dayjs().date() - 1 pode causar problemas no primeiro dia do mês (retornaria -1) e não considera adequadamente a navegação entre meses no contexto do Gantt chart.

-  const hojeIndex = dayjs().date() - 1;
+  const hojeIndex = Math.max(0, dayjs().date() - 1);

Ou considere uma lógica mais robusta que leve em conta o período visível do gráfico de Gantt.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const hojeIndex = dayjs().date() - 1;
const hojeIndex = Math.max(0, dayjs().date() - 1);
🤖 Prompt for AI Agents
In src/components/Gantt/TodayLine.tsx at line 13, the calculation of hojeIndex
using dayjs().date() - 1 can result in -1 on the first day of the month and does
not account for the visible date range of the Gantt chart. Update the logic to
calculate hojeIndex based on the current date's position within the Gantt
chart's visible date range, ensuring it handles month transitions correctly and
never produces negative indices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant