Skip to content

[WEB-4371] feat: bar chart component with lollipop shape variant#7268

Merged
sriramveeraghanta merged 6 commits intopreviewfrom
feat-bar-chart-lollipop
Jun 25, 2025
Merged

[WEB-4371] feat: bar chart component with lollipop shape variant#7268
sriramveeraghanta merged 6 commits intopreviewfrom
feat-bar-chart-lollipop

Conversation

@JayashTripathy
Copy link
Member

@JayashTripathy JayashTripathy commented Jun 25, 2025

Description

This PR extends the bar chart component with lollipop shape variant

Screenshot 2025-06-25 at 5 49 43 PM

image

this image only depicts how it will look like when we use the lollipop variant and not actually modifies anywhere we have used bar chart

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)

Summary by CodeRabbit

  • New Features
    • Added support for a new "lollipop-dotted" bar shape variant in bar charts.
    • Introduced the ability to customize tooltip content in bar charts.
  • Improvements
    • Enhanced bar chart rendering flexibility with shape variants.
    • Improved percentage label display and bar styling consistency.

@JayashTripathy JayashTripathy requested a review from aaryan610 June 25, 2025 12:28
@makeplane
Copy link

makeplane bot commented Jun 25, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

The changes refactor the bar chart rendering logic by introducing typed props, utility functions, and constants for consistent styling. A new lollipop bar variant with a dotted option and a factory for shape variants are added. The bar chart root now supports flexible shape rendering and an optional custom tooltip. Types are updated to support shape variants.

Changes

File(s) Change Summary
packages/propel/src/charts/bar-chart/bar.tsx Refactored bar rendering with typed props, constants, utility functions, new lollipop and dotted lollipop variants, and shape variant factory.
packages/propel/src/charts/bar-chart/root.tsx Updated to use shape variants for bar rendering; added optional custom tooltip content prop and conditional rendering logic.
packages/types/src/charts/index.d.ts Added TBarChartShapeVariant type with "lollipop-dotted" option and shapeVariant property to TBarItem type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BarChart
    participant barShapeVariants
    participant BarComponent
    participant Tooltip

    User->>BarChart: Render BarChart with bars and optional customTooltipContent
    BarChart->>barShapeVariants: Select shape variant (bar/lollipop/lollipop-dotted) for each bar
    barShapeVariants->>BarComponent: Render bar with props and configuration
    BarChart->>Tooltip: On hover, render tooltip
    alt customTooltipContent provided
        BarChart->>Tooltip: Render customTooltipContent
    else
        BarChart->>Tooltip: Render default CustomTooltip
    end
Loading

Suggested labels

ready to merge

Poem

In the garden of charts, new shapes now bloom,
Bars and lollipops dance, dispelling the gloom.
Type safety abounds, with props neat and tight,
Custom tooltips sparkle, adding delight.
With variants galore and constants in tow,
The charting world’s brighter—onward we go!
🥕📊

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 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
Contributor

@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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 40c0922 and 77e8096.

📒 Files selected for processing (3)
  • packages/propel/src/charts/bar-chart/bar.tsx (3 hunks)
  • packages/propel/src/charts/bar-chart/root.tsx (4 hunks)
  • packages/types/src/charts/index.d.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/types/src/charts/index.d.ts (1)

56-57: Type definitions look good!

The new shape variant types are well-defined and maintain backward compatibility by making the property optional.

Also applies to: 67-67

packages/propel/src/charts/bar-chart/root.tsx (1)

70-71: Excellent implementation of shape variants and custom tooltip!

The integration is clean and maintains backward compatibility:

  • The default "bar" variant ensures existing usage continues to work
  • Custom tooltip content provides flexibility while keeping the default behavior intact
  • The shape variant lookup is efficient and extensible

Also applies to: 142-155

JayashTripathy and others added 2 commits June 25, 2025 18:18
removed the unknown props

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
removed console log

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@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: 1

🧹 Nitpick comments (1)
packages/propel/src/charts/bar-chart/bar.tsx (1)

21-21: Consider using a more specific type for payload.

The payload: any type reduces type safety. Consider using a generic type parameter or a more specific interface.

-interface TShapeProps {
+interface TShapeProps<T = any> {
   x: number;
   y: number;
   width: number;
   height: number;
   dataKey: string;
-  payload: any;
+  payload: T;
   opacity?: number;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 77e8096 and 109f007.

📒 Files selected for processing (1)
  • packages/propel/src/charts/bar-chart/bar.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
packages/propel/src/charts/bar-chart/bar.tsx (5)

7-12: Well-structured constants for styling consistency.

The constants are properly defined and will help maintain consistent styling across the chart components.


44-54: Solid SVG path generation utility.

The getBarPath function correctly generates SVG paths for rounded rectangles with configurable top and bottom border radii.


56-70: Clean and reusable PercentageText component.

Good abstraction for percentage text rendering with proper SVG attributes and styling.


158-177: Well-designed factory pattern for shape variants.

The createShapeVariant factory properly handles optional border radius functions and fill type variations, enabling flexible shape variant creation.


179-186: Clean export structure with proper component naming.

The barShapeVariants export provides a clean API for dynamic shape selection, and the display names follow React best practices for debugging.

@JayashTripathy JayashTripathy changed the title [WEB-4371] feat: enhance bar chart component with shape variants and custom tooltip [WEB-4371] feat: bar chart component with lollipop shape variant Jun 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Caution

No docstrings were generated.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
packages/propel/src/charts/bar-chart/bar.tsx (2)

15-33: Improve type safety by avoiding any types.

The type definitions provide good structure, but using any reduces type safety benefits.

Consider creating more specific types:

interface TShapeProps {
  x: number;
  y: number;
  width: number;
  height: number;
  dataKey: string;
-  payload: any;
+  payload: TChartData<string, string>;
  opacity?: number;
}

interface TBarProps extends TShapeProps {
-  fill: string | ((payload: any) => string);
+  fill: string | ((payload: TChartData<string, string>) => string);
  stackKeys: string[];
  textClassName?: string;
  showPercentage?: boolean;
  showTopBorderRadius?: boolean;
  showBottomBorderRadius?: boolean;
  dotted?: boolean;
}

121-150: CustomBarLollipop implementation looks solid, but verify text positioning.

The lollipop component properly addresses previous review issues (removed console.log, eliminated invalid SVG attributes, uses PercentageText component). However, the percentage text positioning at y={y} might cause overlap with the circle.

Consider adjusting the text position:

{showPercentage && (
-  <PercentageText x={x + width / 2} y={y} percentage={currentBarPercentage} className={textClassName} />
+  <PercentageText x={x + width / 2} y={y - DEFAULT_LOLLIPOP_CIRCLE_RADIUS - 4} percentage={currentBarPercentage} className={textClassName} />
)}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 109f007 and a5d761b.

📒 Files selected for processing (2)
  • packages/propel/src/charts/bar-chart/bar.tsx (3 hunks)
  • packages/types/src/charts/index.d.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/types/src/charts/index.d.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
packages/propel/src/charts/bar-chart/bar.tsx (6)

7-13: Well-defined constants improve maintainability.

The constants are properly named and provide clear configuration for the chart styling. Good separation of concerns.


45-55: Excellent utility function for SVG path generation.

The getBarPath function provides a clean abstraction for generating rounded rectangle paths, improving code reusability and maintainability.


57-71: Good abstraction for consistent text rendering.

The PercentageText component addresses the previous review concern about inconsistent text rendering between variants. This promotes consistency and reusability.


74-119: Well-structured CustomBar component with proper optimizations.

The component properly uses React.memo for performance, integrates the new utility functions, and maintains clean separation of concerns. The conditional rendering and text positioning logic is well-implemented.


152-181: Excellent factory pattern implementation.

The createShapeVariant factory and barShapeVariants mapping provide a clean, extensible architecture for managing different chart variants. This design makes it easy to add new variants while maintaining consistency.


184-185: Good practice setting display names for debugging.

Setting display names on React components improves the debugging experience in React DevTools.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
packages/propel/src/charts/bar-chart/bar.tsx (1)

146-146: Consider adjusting percentage text positioning for better readability.

The percentage text is currently positioned at y={y}, which places it directly on the circle center. This may cause readability issues due to overlap with the circle.

Consider positioning the text slightly below or above the circle:

-        <PercentageText x={x + width / 2} y={y} percentage={currentBarPercentage} className={textClassName} />
+        <PercentageText x={x + width / 2} y={y - DEFAULT_LOLLIPOP_CIRCLE_RADIUS - 4} percentage={currentBarPercentage} className={textClassName} />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a5d761b and 0aed001.

📒 Files selected for processing (1)
  • packages/propel/src/charts/bar-chart/bar.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (8)
packages/propel/src/charts/bar-chart/bar.tsx (8)

4-13: Well-structured constants and imports.

The new constants provide clear configuration values for the component dimensions and styling, improving maintainability and consistency.


14-33: Clean type definitions with proper separation of concerns.

The TShapeProps and TBarProps interfaces provide good type safety while maintaining flexibility. The separation between base shape properties and bar-specific properties follows good design principles.


45-55: Efficient SVG path generation utility.

The getBarPath function correctly generates SVG path strings for rounded rectangles using quadratic Bézier curves. This eliminates code duplication and provides a reusable utility for consistent border radius rendering.


57-71: Good abstraction for percentage text rendering.

The PercentageText component provides consistent styling and positioning for percentage labels. Using fill="currentColor" allows proper color inheritance from the parent context.


74-119: Improved CustomBar implementation with proper typing.

The refactored component uses the new type definitions and utility functions effectively. The conditional rendering logic for percentage text is well-implemented, considering both height constraints and percentage validity.


121-150: Well-implemented lollipop shape variant.

The CustomBarLollipop component correctly implements the lollipop visualization with proper SVG elements. The conditional dotted line feature adds good flexibility, and the fill function support maintains consistency with the standard bar variant.


152-186: Excellent factory pattern implementation for shape variants.

The createShapeVariant factory function provides a clean, extensible approach for creating different shape variants while maintaining consistent prop handling. The type-safe mapping in barShapeVariants ensures proper variant selection and component rendering.


189-190: Proper component display names for debugging.

Setting display names on the components improves the debugging experience in React DevTools.

@sriramveeraghanta sriramveeraghanta merged commit b553856 into preview Jun 25, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-bar-chart-lollipop branch June 25, 2025 18:13
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* feat: enhance bar chart component with shape variants and custom tooltip

* Update packages/propel/src/charts/bar-chart/bar.tsx

removed the unknown props

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/propel/src/charts/bar-chart/bar.tsx

removed console log

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* refactor: replace inline percentage text with PercentageText component in bar chart

* Added new variant - lollipop-dotted

* added some comments

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants