Skip to content

feat(ui): add Y-axis with numbers to project overview charts#330

Open
nielskaspers wants to merge 1 commit intoOpenpanel-dev:mainfrom
nielskaspers:fix/issue-326-add-yaxis-to-project-charts
Open

feat(ui): add Y-axis with numbers to project overview charts#330
nielskaspers wants to merge 1 commit intoOpenpanel-dev:mainfrom
nielskaspers:fix/issue-326-add-yaxis-to-project-charts

Conversation

@nielskaspers
Copy link
Copy Markdown

@nielskaspers nielskaspers commented Apr 6, 2026

Summary

  • Show Y-axis tick labels on project card charts so users can quickly read values without hovering

Issue

Fixes #326

Changes

  • Import and use the existing useYAxisProps hook in ProjectChart component
  • Replace hidden Y-axis (hide width={0}) with visible Y-axis using consistent formatting (short numbers: 1K, 10K, etc.)
  • Adjust left margin from 10px to 0px since the Y-axis labels now provide spacing

Testing

  • Navigate to the organization projects overview page (/:organizationId/)
  • Verify each project card chart now displays Y-axis labels with formatted numbers
  • Hover over chart points to confirm tooltip still works correctly

Summary by CodeRabbit

  • Refactor
    • Improved project chart Y-axis configuration and layout to use a more flexible property system.
    • Adjusted chart margins for better visual spacing.

Show Y-axis tick labels on project card charts for quick value
reference. Uses the existing useYAxisProps hook for consistent
formatting (short numbers like 1K, 10K) and dynamic width.

Fixes Openpanel-dev#326
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 6, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

Modified the project chart component to dynamically render Y-axis numeric values by integrating a useYAxisProps() hook, and adjusted the chart's left margin from 10 to 0. The change enables better visualization of data scales in the projects overview.

Changes

Cohort / File(s) Summary
Y-Axis Display Enhancement
apps/start/src/components/projects/project-chart.tsx
Integrated useYAxisProps() hook to display Y-axis with numeric values, replacing the previous hidden Y-axis behavior. Adjusted ComposedChart left margin from 10 to 0 to accommodate the visible axis labels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

📊 A chart once bare, now gleams so bright,
With Y-axis numbers in perfect sight!
Numbers dancing, scales so clear—
Data's story is finally here! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding visible Y-axis labels with numbers to project overview charts for better user experience.
Linked Issues check ✅ Passed The PR implements all required changes from issue #326: adds Y-axis with numeric labels to project charts, uses the useYAxisProps hook for consistent formatting, and removes the hidden Y-axis.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue #326: Y-axis visibility, numeric labels, margin adjustment, and hook integration. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/start/src/components/projects/project-chart.tsx (1)

97-111: ⚠️ Potential issue | 🔴 Critical

React Rules of Hooks violation: useYAxisProps is called after conditional return.

The hook call on line 111 occurs after the early return on lines 99-101. When data.length changes between 0 and non-zero, React will see a different number of hook calls, causing a runtime error.

Move the hook call before the early return to ensure hooks are called unconditionally.

🐛 Proposed fix
 export function ProjectChart({
   data,
   dots = false,
   color = 'blue',
 }: {
   dots?: boolean;
   color?: 'blue' | 'green' | 'red';
   data: { value: number; date: Date; revenue: number }[];
 }) {
   const [activeBar, setActiveBar] = useState(-1);
+  const yAxisProps = useYAxisProps({});

   if (data.length === 0) {
     return null;
   }

   // Transform data for Recharts (needs timestamp for time-based x-axis)
   const chartData = data.map((item) => ({
     ...item,
     timestamp: item.date.getTime(),
   }));

   const maxValue = Math.max(...data.map((d) => d.value), 0);
   const maxRevenue = Math.max(...data.map((d) => d.revenue), 0);
-  const yAxisProps = useYAxisProps({});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/start/src/components/projects/project-chart.tsx` around lines 97 - 111,
The hook useYAxisProps is being called after an early return when data.length
=== 0, which violates the Rules of Hooks; move the useYAxisProps(...) call so it
executes unconditionally before the "if (data.length === 0) return null;" check
(i.e., call useYAxisProps above the early-return and keep the rest of chartData,
maxValue, maxRevenue logic unchanged) so hooks are invoked in the same order
regardless of data.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/start/src/components/projects/project-chart.tsx`:
- Around line 97-111: The hook useYAxisProps is being called after an early
return when data.length === 0, which violates the Rules of Hooks; move the
useYAxisProps(...) call so it executes unconditionally before the "if
(data.length === 0) return null;" check (i.e., call useYAxisProps above the
early-return and keep the rest of chartData, maxValue, maxRevenue logic
unchanged) so hooks are invoked in the same order regardless of data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f81ef5a9-4c72-4a5a-9114-9ed00ed73e3a

📥 Commits

Reviewing files that changed from the base of the PR and between a1ce71f and d817e18.

📒 Files selected for processing (1)
  • apps/start/src/components/projects/project-chart.tsx

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.

Small UI improvement suggestion

2 participants