Conversation
📝 WalkthroughWalkthroughThis pull request refactors existing area chart components to use Unovis's updated VisArea component with integrated line capabilities, replacing the separate VisLine component. Five new area chart variant components are added (Default, Linear, Legend, Stacked, Step) and registered in the chart constants. Unovis library versions are bumped to ^1.7.0-pre.2. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@apps/v4/registry/new-york-v4/charts/ChartAreaDefault.vue`:
- Around line 73-75: In the tick-format arrow function bound in
ChartAreaDefault.vue, add a defensive check to avoid out-of-bounds or undefined
access on chartData[index] and its monthLabel before calling slice; update the
lambda that currently references chartData[index].monthLabel.slice(0, 3) to
first verify index is within chartData length and that
chartData[index]?.monthLabel is a string, and return a safe fallback (e.g.,
empty string or full label) when the checks fail.
In `@apps/v4/registry/new-york-v4/charts/ChartAreaLegend.vue`:
- Around line 77-79: The tick-format arrow function for the chart's ticks
accesses chartData[index].monthLabel without bounds checking; update the inline
function used in the :tick-format prop to defensively validate that chartData is
an array, index is a valid number within range, and chartData[index]?.monthLabel
exists before slicing, returning a safe fallback (e.g., empty string) when
checks fail so out-of-bounds or undefined values from Unovis cannot throw.
In `@apps/v4/registry/new-york-v4/charts/ChartAreaLinear.vue`:
- Around line 75-77: The tick-format arrow in ChartAreaLinear.vue accesses
chartData[index].monthLabel.slice(0,3) without checking bounds; update the tick
formatter (the :tick-format handler) to first ensure chartData is an array,
index is a valid number within chartData.length, and chartData[index].monthLabel
is a string before calling slice, returning a safe fallback (e.g., empty string
or full label) when checks fail; this prevents runtime exceptions for
out-of-range or undefined entries.
In `@apps/v4/registry/new-york-v4/charts/ChartAreaStep.vue`:
- Around line 75-77: The tick-format callback in ChartAreaStep.vue currently
does chartData[index].monthLabel.slice(0,3) which can throw if index is
out-of-bounds; update the tick-format function to defensively check that
chartData and chartData[index] exist and that monthLabel is a string (e.g.,
guard with chartData && chartData[index] && typeof chartData[index].monthLabel
=== 'string'), then call slice on that value, otherwise return a safe fallback
(empty string or a formatted default); this ensures the tick-format handler
won't throw when Unovis supplies indices that don't align with chartData.
🧹 Nitpick comments (10)
apps/v4/registry/new-york-v4/charts/ChartAreaStacked.vue (1)
70-80: Make X‑axis tick labels resilient to tick decimation.Line 77-79:
tick-formatrelies on the tick index; if ticks are reduced or the data shape changes, labels can desync. Mapping by the tick value is safer.♻️ Suggested change
const chartData = [ { month: 1, monthLabel: "January", desktop: 186, mobile: 80 }, { month: 2, monthLabel: "February", desktop: 305, mobile: 200 }, { month: 3, monthLabel: "March", desktop: 237, mobile: 120 }, { month: 4, monthLabel: "April", desktop: 73, mobile: 190 }, { month: 5, monthLabel: "May", desktop: 209, mobile: 130 }, { month: 6, monthLabel: "June", desktop: 214, mobile: 140 }, ] + +const monthLabelByValue = new Map(chartData.map((d) => [d.month, d.monthLabel]))- :tick-format="(d: number, index: number) => { - return chartData[index].monthLabel.slice(0, 3) - }" + :tick-format="(d: number) => { + return monthLabelByValue.get(d)?.slice(0, 3) ?? '' + }"pnpm-workspace.yaml (1)
27-28: Consider pinning the Unovis pre-release to avoid unexpected version drift.Lines 27-28:
^1.7.0-pre.2allows minor and patch updates within the pre-release sequence. Once a stable 1.7.0 is released, the caret could permit upgrades to the final version, potentially shifting behavior. For consistent pre-release behavior, pin the exact version.🔧 Suggested pinning
- '@unovis/ts': ^1.7.0-pre.2 - '@unovis/vue': ^1.7.0-pre.2 + '@unovis/ts': 1.7.0-pre.2 + '@unovis/vue': 1.7.0-pre.2apps/v4/registry/new-york-v4/charts/ChartAreaStep.vue (2)
6-6: Remove commented-out import.This commented-out recharts import is dead code. Since the PR transitions to Unovis, this leftover should be cleaned up.
🧹 Suggested cleanup
-// import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
27-27: Unuseddescriptionvariable.The
descriptionconstant is defined but never used in the template or exposed. Consider removing it or using it (e.g., for accessibility attributes or meta purposes).apps/v4/registry/new-york-v4/charts/ChartAreaLegend.vue (2)
5-5: Remove commented-out import.Dead code from the recharts migration should be cleaned up.
🧹 Suggested cleanup
-// import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
26-26: Unuseddescriptionvariable.Same as other chart files - this variable is declared but never used.
apps/v4/registry/new-york-v4/charts/ChartAreaDefault.vue (2)
5-5: Remove commented-out import.Dead code from the recharts migration.
🧹 Suggested cleanup
-// import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
26-26: Unuseddescriptionvariable.Declared but not used in the component.
apps/v4/registry/new-york-v4/charts/ChartAreaLinear.vue (2)
6-6: Remove commented-out import.Dead code from the recharts migration.
🧹 Suggested cleanup
-// import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
27-27: Unuseddescriptionvariable.Declared but not used in the component.
| :tick-format="(d: number, index: number) => { | ||
| return chartData[index].monthLabel.slice(0, 3) | ||
| }" |
There was a problem hiding this comment.
Add defensive check for array index access.
🛡️ Suggested defensive fix
:tick-format="(d: number, index: number) => {
- return chartData[index].monthLabel.slice(0, 3)
+ return chartData[index]?.monthLabel?.slice(0, 3) ?? ''
}"📝 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.
| :tick-format="(d: number, index: number) => { | |
| return chartData[index].monthLabel.slice(0, 3) | |
| }" | |
| :tick-format="(d: number, index: number) => { | |
| return chartData[index]?.monthLabel?.slice(0, 3) ?? '' | |
| }" |
🤖 Prompt for AI Agents
In `@apps/v4/registry/new-york-v4/charts/ChartAreaDefault.vue` around lines 73 -
75, In the tick-format arrow function bound in ChartAreaDefault.vue, add a
defensive check to avoid out-of-bounds or undefined access on chartData[index]
and its monthLabel before calling slice; update the lambda that currently
references chartData[index].monthLabel.slice(0, 3) to first verify index is
within chartData length and that chartData[index]?.monthLabel is a string, and
return a safe fallback (e.g., empty string or full label) when the checks fail.
| :tick-format="(d: number, index: number) => { | ||
| return chartData[index].monthLabel.slice(0, 3) | ||
| }" |
There was a problem hiding this comment.
Add defensive check for array index access.
Same potential out-of-bounds issue as other chart files when Unovis passes unexpected index values.
🛡️ Suggested defensive fix
:tick-format="(d: number, index: number) => {
- return chartData[index].monthLabel.slice(0, 3)
+ return chartData[index]?.monthLabel?.slice(0, 3) ?? ''
}"📝 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.
| :tick-format="(d: number, index: number) => { | |
| return chartData[index].monthLabel.slice(0, 3) | |
| }" | |
| :tick-format="(d: number, index: number) => { | |
| return chartData[index]?.monthLabel?.slice(0, 3) ?? '' | |
| }" |
🤖 Prompt for AI Agents
In `@apps/v4/registry/new-york-v4/charts/ChartAreaLegend.vue` around lines 77 -
79, The tick-format arrow function for the chart's ticks accesses
chartData[index].monthLabel without bounds checking; update the inline function
used in the :tick-format prop to defensively validate that chartData is an
array, index is a valid number within range, and chartData[index]?.monthLabel
exists before slicing, returning a safe fallback (e.g., empty string) when
checks fail so out-of-bounds or undefined values from Unovis cannot throw.
| :tick-format="(d: number, index: number) => { | ||
| return chartData[index].monthLabel.slice(0, 3) | ||
| }" |
There was a problem hiding this comment.
Add defensive check for array index access.
🛡️ Suggested defensive fix
:tick-format="(d: number, index: number) => {
- return chartData[index].monthLabel.slice(0, 3)
+ return chartData[index]?.monthLabel?.slice(0, 3) ?? ''
}"🤖 Prompt for AI Agents
In `@apps/v4/registry/new-york-v4/charts/ChartAreaLinear.vue` around lines 75 -
77, The tick-format arrow in ChartAreaLinear.vue accesses
chartData[index].monthLabel.slice(0,3) without checking bounds; update the tick
formatter (the :tick-format handler) to first ensure chartData is an array,
index is a valid number within chartData.length, and chartData[index].monthLabel
is a string before calling slice, returning a safe fallback (e.g., empty string
or full label) when checks fail; this prevents runtime exceptions for
out-of-range or undefined entries.
| :tick-format="(d: number, index: number) => { | ||
| return chartData[index].monthLabel.slice(0, 3) | ||
| }" |
There was a problem hiding this comment.
Potential index out-of-bounds access in tick formatter.
The tick-format callback accesses chartData[index] directly. If Unovis passes an index outside the array bounds (e.g., during interpolation or when num-ticks doesn't align with data length), this will throw a runtime error.
🛡️ Suggested defensive fix
:tick-format="(d: number, index: number) => {
- return chartData[index].monthLabel.slice(0, 3)
+ return chartData[index]?.monthLabel?.slice(0, 3) ?? ''
}"📝 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.
| :tick-format="(d: number, index: number) => { | |
| return chartData[index].monthLabel.slice(0, 3) | |
| }" | |
| :tick-format="(d: number, index: number) => { | |
| return chartData[index]?.monthLabel?.slice(0, 3) ?? '' | |
| }" |
🤖 Prompt for AI Agents
In `@apps/v4/registry/new-york-v4/charts/ChartAreaStep.vue` around lines 75 - 77,
The tick-format callback in ChartAreaStep.vue currently does
chartData[index].monthLabel.slice(0,3) which can throw if index is
out-of-bounds; update the tick-format function to defensively check that
chartData and chartData[index] exist and that monthLabel is a string (e.g.,
guard with chartData && chartData[index] && typeof chartData[index].monthLabel
=== 'string'), then call slice on that value, otherwise return a safe fallback
(empty string or a formatted default); this ensures the tick-format handler
won't throw when Unovis supplies indices that don't align with chartData.
|
@aguingand i have updated it, works like a charm now ⚡🚀 |
❓ Type of change
📚 Description
I've update Unovis to 1.7.0 (beta for now) that includes the feature to add lines to area (f5/unovis#691) . I've added missing area charts from Shadcn except from the "Stacked Expanded" one (we can't configure stack offset in Unovis yet).
PS. Unovis 1.7.0 includes performance improvements (f5/unovis#689). It has been reported in #1567
📝 Checklist
Summary by CodeRabbit
New Features
Updates
Dependencies
✏️ Tip: You can customize this high-level summary in your review settings.