Skip to content

[Dashboards] new line area colors#16272

Merged
ehconitin merged 19 commits intomainfrom
fix-line-gradient-issue
Dec 3, 2025
Merged

[Dashboards] new line area colors#16272
ehconitin merged 19 commits intomainfrom
fix-line-gradient-issue

Conversation

@ehconitin
Copy link
Copy Markdown
Contributor

@ehconitin ehconitin commented Dec 3, 2025

before -

CleanShot.2025-12-03.at.16.17.28.mp4

after -

CleanShot.2025-12-03.at.16.15.33.mp4

@ehconitin ehconitin self-assigned this Dec 3, 2025
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 3, 2025

Greptile Overview

Greptile Summary

This PR refactors the dashboard line chart area fill rendering system by replacing Nivo's built-in gradient implementation with a custom area layer implementation. The key changes include removing the gradient property from GraphColorScheme type and color registry, replacing it with opacity-based gradients that use a starting opacity of 0.14 and fade to 0. The refactor introduces new utility functions (createAreaFillDef, computeLineAreaPath), custom components (CustomStackedAreasLayer, LineAreaGradientDefs, LineAnimatedAreaPath), and constants for consistent opacity values. The implementation moves from pre-defined gradient color pairs to dynamic gradient generation using solid colors with varying opacity levels, providing better control over visual styling and animations through d3-shape and react-spring integration.

Important Files Changed

Filename Score Overview
packages/twenty-front/src/modules/page-layout/widgets/graph/types/GraphColorScheme.ts 4/5 Removes gradient property from type definition, simplifying to only include solid color and variations
packages/twenty-front/src/modules/page-layout/widgets/graph/utils/createGraphColorRegistry.ts 4/5 Removes gradient properties from all 25 color schemes in the registry
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/components/CustomStackedAreasLayer.tsx 4/5 Introduces new custom area rendering layer replacing Nivo's built-in area functionality
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/components/GraphWidgetLineChart.tsx 4/5 Refactors to use custom area layer instead of Nivo's built-in area rendering
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/hooks/useLineChartData.ts 4/5 Simplifies hook interface and removes gradient-related logic
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/utils/createAreaFillDef.ts 5/5 Creates new utility for generating opacity-based linear gradients
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/utils/computeLineAreaPath.ts 5/5 Implements custom area path computation using d3-shape
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/components/LineAreaGradientDefs.tsx 5/5 Generates SVG gradient definitions for custom area fills
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetLineChart/components/LineAnimatedAreaPath.tsx 5/5 Provides animated SVG paths for smooth area fill transitions
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetGaugeChart/hooks/useGaugeChartData.ts 2/5 Returns gradientId without creating corresponding gradient definition, creating reference mismatch
packages/twenty-front/src/modules/page-layout/widgets/graph/utils/createGradientDef.ts 3/5 Completely removed utility function that may still be referenced elsewhere
packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetGaugeChart/components/GraphWidgetGaugeChart.tsx 4/5 Removes gradient rendering functionality from gauge charts

Confidence score: 3/5

  • This PR requires careful review due to potential breaking changes from removing core gradient functionality
  • Score lowered due to incomplete refactoring in gauge chart components (useGaugeChartData returns gradientId but doesn't create gradient) and complete removal of createGradientDef utility without verifying all references are updated
  • Pay close attention to gauge chart files and verify no other components reference the deleted createGradientDef utility

Sequence Diagram

sequenceDiagram
    participant User
    participant GraphWidgetLineChart
    participant useLineChartData
    participant LineAreaGradientDefs
    participant CustomStackedAreasLayer
    participant LineAnimatedAreaPath
    participant ResponsiveLine

    User->>GraphWidgetLineChart: "View dashboard with line chart"
    GraphWidgetLineChart->>useLineChartData: "Process series data with color registry"
    useLineChartData->>useLineChartData: "Generate enriched series with areaFillId"
    useLineChartData-->>GraphWidgetLineChart: "Return enriched series, colors, legend items"
    
    GraphWidgetLineChart->>ResponsiveLine: "Render with custom layers"
    ResponsiveLine->>CustomStackedAreasLayer: "Render area layer"
    CustomStackedAreasLayer->>LineAreaGradientDefs: "Generate gradient definitions"
    LineAreaGradientDefs->>LineAreaGradientDefs: "Create linear gradients with opacity"
    LineAreaGradientDefs-->>CustomStackedAreasLayer: "Return gradient defs"
    
    CustomStackedAreasLayer->>LineAnimatedAreaPath: "Render animated area paths"
    LineAnimatedAreaPath->>LineAnimatedAreaPath: "Apply gradient fill with fillId"
    LineAnimatedAreaPath-->>CustomStackedAreasLayer: "Return animated path"
    CustomStackedAreasLayer-->>ResponsiveLine: "Return complete area layer"
    ResponsiveLine-->>GraphWidgetLineChart: "Return rendered chart"
    GraphWidgetLineChart-->>User: "Display chart with improved gradients"
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetGaugeChart/hooks/useGaugeChartData.ts, line 11 (link)

    style: isHovered is still defined in the type but no longer destructured or used in the implementation. Remove from type definition.

20 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 3, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:37579

This environment will automatically shut down when the PR is closed or after 5 hours.

@ehconitin
Copy link
Copy Markdown
Contributor Author

@greptileai trigger

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. packages/twenty-front/src/modules/page-layout/widgets/graph/graphWidgetGaugeChart/hooks/useGaugeChartHandlers.ts

    logic: The useGaugeChartHandlers hook has been completely removed. This may break components that were using isHovered, setIsHovered, handleClick, or hasClickableItems from this hook. Are you certain that no other components are importing and using this hook's functionality?

22 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@bosiraphael bosiraphael left a comment

Choose a reason for hiding this comment

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

LGTM

@ehconitin ehconitin enabled auto-merge (squash) December 3, 2025 15:37
@ehconitin ehconitin merged commit 6c9abed into main Dec 3, 2025
82 of 84 checks passed
@ehconitin ehconitin deleted the fix-line-gradient-issue branch December 3, 2025 15:51
@twenty-eng-sync
Copy link
Copy Markdown

Hey @ehconitin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 3, 2025

Thanks @ehconitin for your contribution!
This marks your 265th PR on the repo. You're top 1% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

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