Skip to content

CondensedChart Fix#253

Merged
ankit-thesys merged 9 commits intomainfrom
condened-chart-bug-fix
Feb 3, 2026
Merged

CondensedChart Fix#253
ankit-thesys merged 9 commits intomainfrom
condened-chart-bug-fix

Conversation

@ankit-thesys
Copy link
Contributor

@ankit-thesys ankit-thesys commented Jan 29, 2026


EntelligenceAI PR Summary

Refactors BarChartCondensed to simplify bar width calculations and adds visual quality improvements for thin bars.

  • Removed minBarWidth and defaultBarWidth props from BarChartCondensed, delegating auto-sizing to Recharts
  • Streamlined calculatedBarWidth calculation to only enforce maximum width constraint
  • Added interactive Storybook playground with controls for testing bar width scenarios and preset configurations
  • Introduced 3px minimum width threshold in LineInBarShape to prevent rendering lines in thin bars
  • Enhanced visibility logic to check both width and height constraints for vertical and horizontal bars

…t components to use passed width prop if available, improving flexibility in rendering. Updated dependencies in useEffect hooks for better responsiveness.
… dependencies, enhancing responsiveness in chart width calculations.
…rties. Introduced minBarWidth, maxBarWidth, and defaultBarWidth props for improved flexibility in rendering. Updated width calculations to ensure responsiveness and accurate bar sizing based on available space.
@entelligence-ai-pr-reviews
Copy link

Re-review triggered for new commit 44065e1.

@entelligence-ai-pr-reviews
Copy link

Walkthrough

This PR applies code formatting and style improvements to the BarChartCondensed component with no functional changes. The updates focus on improving code readability and consistency by reformatting the calculateBarWidth useMemo hook with better indentation and line breaks, standardizing quote usage from single to double quotes, and applying multi-line formatting to the ChartContainer's style prop. Additionally, trailing whitespace is removed throughout the file. These changes align with standard Prettier/ESLint formatting conventions to maintain consistent code style across the codebase.

Changes

File(s) Summary
js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx Applied code formatting improvements including reformatting the calculateBarWidth useMemo hook and dependency array, converting single quotes to double quotes, improving indentation and line breaks, removing trailing whitespace, and reformatting ChartContainer's style prop to multi-line format.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    participant Component as BarChart Component
    participant WidthCalc as Width Calculator (useMemo)
    participant ResizeObs as ResizeObserver
    participant ChartContainer as ChartContainer

    Component->>WidthCalc: Calculate bar width
    activate WidthCalc
    
    alt explicitChartWidth provided
        WidthCalc->>WidthCalc: Use explicitChartWidth
    else chartContainerWidth available
        WidthCalc->>WidthCalc: Use chartContainerWidth
    else no width available
        WidthCalc-->>Component: Return defaultBarWidth
    end
    
    WidthCalc->>WidthCalc: Parse BAR_CATEGORY_GAP percentage
    WidthCalc->>WidthCalc: Calculate spacePerCategory<br/>(availableWidth / data.length)
    
    alt variant === "stacked"
        WidthCalc->>WidthCalc: barsPerCategory = 1
    else variant === "grouped"
        WidthCalc->>WidthCalc: barsPerCategory = dataKeys.length
    end
    
    WidthCalc->>WidthCalc: Calculate categoryGapWidth
    WidthCalc->>WidthCalc: Calculate spaceForBars
    
    alt barsPerCategory === 1
        WidthCalc->>WidthCalc: barWidth = spaceForBars
    else multiple bars per category
        WidthCalc->>WidthCalc: barWidth = (spaceForBars - totalGapWidth) / barsPerCategory
    end
    
    WidthCalc->>WidthCalc: Apply min/max constraints
    WidthCalc-->>Component: Return calculated barWidth
    deactivate WidthCalc
    
    Component->>ResizeObs: Setup resize observer
    activate ResizeObs
    ResizeObs->>ResizeObs: Observe chartContainerRef
    
    opt width not provided
        ResizeObs->>ResizeObs: Also observe containerRef
    end
    
    ResizeObs-->>Component: Monitor dimension changes
    deactivate ResizeObs
    
    Component->>ChartContainer: Render chart
    activate ChartContainer
    
    alt explicitChartWidth exists
        Component->>ChartContainer: Set width to explicitChartWidth px
    else no explicit width
        Component->>ChartContainer: Set width to 100%
    end
    
    Component->>ChartContainer: Set height to effectiveHeight
    ChartContainer-->>Component: Chart rendered
    deactivate ChartContainer
Loading

🔒 Security Analysis

Category Count
Vulnerabilities 0
Bugs 4
Code Smells 7
Security Hotspots 0

🔗 Cross-Repository Impact Analysis

Enable automatic detection of breaking changes across your dependent repositories. → Set up now

Learn more about Cross-Repository Analysis

What It Does

  • Automatically identifies repositories that depend on this code
  • Analyzes potential breaking changes across your entire codebase
  • Provides risk assessment before merging to prevent cross-repo issues

How to Enable

  1. Visit Settings → Code Management
  2. Configure repository dependencies
  3. Future PRs will automatically include cross-repo impact analysis!

Benefits

  • 🛡️ Prevent breaking changes across repositories
  • 🔍 Catch integration issues before they reach production
  • 📊 Better visibility into your multi-repo architecture

{'files_selected': ['js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx'], 'files_unselected': []}

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

@ankit-thesys ankit-thesys changed the title Refactor chart width calculation in AreaChart, BarChart, and LineChart components to use passed width prop if available, improving flexibility in rendering. Updated dependencies in useEffect hooks for better responsiveness. CondensedChart Fix Jan 30, 2026
…ions. Removed minBarWidth and defaultBarWidth props, simplifying the logic to only apply a maximum bar width constraint. Enhanced responsiveness by allowing Recharts to handle thin bars automatically. Added a new interactive story for testing bar width configurations, including variant and data size controls.
@entelligence-ai-pr-reviews
Copy link

Re-review triggered for new commit cc33ecd.

@entelligence-ai-pr-reviews
Copy link

Walkthrough

This PR refactors the BarChartCondensed component to simplify bar width calculation logic by removing manual minimum and default width constraints, instead delegating to Recharts' automatic sizing capabilities. The changes eliminate three props and associated constants, streamlining the calculation to only enforce a maximum width constraint. A new Storybook playground story is added to facilitate testing of various bar width scenarios with different data configurations. Additionally, the LineInBarShape component is enhanced with a minimum width threshold to prevent rendering lines in bars that are too thin, improving visual quality and preventing awkward rendering artifacts.

Changes

File(s) Summary
js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx Simplified bar width calculation by removing minBarWidth, defaultBarWidth props and their constants; streamlined calculatedBarWidth useMemo to only apply maximum width constraint and return undefined for auto-sizing when dimensions unavailable; eliminated manual gap calculations as Recharts handles spacing via barGap and barCategoryGap props.
js/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx Added 'BarWidthPlayground' story with interactive controls for testing chart variants, data set sizes (4-50 points), max bar width (10-120px), and container widths; includes six preset configurations for common scenarios; removed explicit 400px width from CustomPaletteStory for responsive sizing.
js/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.tsx Introduced MIN_BAR_WIDTH_FOR_LINE constant (3px) to prevent rendering lines in thin vertical bars; updated visibility logic to check both width (≥3px) and height (≥8px) thresholds; added clarifying comments for visibility conditions in both orientations.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    participant Component as BarChartCondensed
    participant Hook as useMemo(calculatedBarWidth)
    participant Recharts as Recharts Library

    Note over Component: Component renders with props:<br/>maxBarWidth, data, dataKeys, variant

    Component->>Hook: Calculate bar width
    activate Hook
    
    Hook->>Hook: Get availableWidth<br/>(explicitChartWidth ?? chartContainerWidth)
    
    alt availableWidth unavailable OR data empty
        Hook-->>Component: return undefined
        Note over Component,Recharts: Let Recharts auto-size bars
        Component->>Recharts: Render with barWidth=undefined
        Recharts->>Recharts: Auto-calculate bar dimensions
    else availableWidth available AND data exists
        Hook->>Hook: Calculate spacePerCategory<br/>(availableWidth / data.length)
        
        alt variant === "stacked"
            Hook->>Hook: barsPerCategory = 1
        else variant === "grouped"
            Hook->>Hook: barsPerCategory = dataKeys.length
        end
        
        Hook->>Hook: barWidth = spacePerCategory / barsPerCategory
        Hook->>Hook: Apply max constraint:<br/>Math.min(maxBarWidth, barWidth)
        Hook-->>Component: return constrained barWidth
        Component->>Recharts: Render with calculated barWidth
        Note over Recharts: Recharts applies gaps automatically<br/>via barGap and barCategoryGap props
    end
    
    deactivate Hook
    
    Note over Component: Simplified calculation:<br/>- No min constraint<br/>- No manual gap calculations<br/>- No default fallback width
Loading

🔒 Security Analysis

Category Count
Vulnerabilities 0
Bugs 8
Code Smells 18
Security Hotspots 0

🔗 Cross-Repository Impact Analysis

Enable automatic detection of breaking changes across your dependent repositories. → Set up now

Learn more about Cross-Repository Analysis

What It Does

  • Automatically identifies repositories that depend on this code
  • Analyzes potential breaking changes across your entire codebase
  • Provides risk assessment before merging to prevent cross-repo issues

How to Enable

  1. Visit Settings → Code Management
  2. Configure repository dependencies
  3. Future PRs will automatically include cross-repo impact analysis!

Benefits

  • 🛡️ Prevent breaking changes across repositories
  • 🔍 Catch integration issues before they reach production
  • 📊 Better visibility into your multi-repo architecture

{'files_selected': ['js/packages/react-ui/src/components/Charts/BarChartCondensed/BarChartCondensed.tsx', 'js/packages/react-ui/src/components/Charts/BarChartCondensed/stories/barChartCondensed.stories.tsx', 'js/packages/react-ui/src/components/Charts/shared/LineInBarShape/LineInBarShape.tsx'], 'files_unselected': []}

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

@entelligence-ai-pr-reviews
Copy link

entelligence-ai-pr-reviews bot commented Feb 3, 2026

✅ Review completed for commit 4faa556.

…y. Removed unnecessary line breaks in story descriptions for better readability.
@entelligence-ai-pr-reviews
Copy link

entelligence-ai-pr-reviews bot commented Feb 3, 2026

✅ Review completed for commit e2f5897.

@ankit-thesys ankit-thesys merged commit 65216f3 into main Feb 3, 2026
3 checks passed
@ankit-thesys ankit-thesys deleted the condened-chart-bug-fix branch February 3, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants