Skip to content

fix(ProcessChart): add compatibility handling - #429

Open
ader-h wants to merge 1 commit into
opentiny:devfrom
ader-h:fix-processchrt-0.18
Open

ader-h wants to merge 1 commit into
opentiny:devfrom
ader-h:fix-processchrt-0.18

Conversation

@ader-h

@ader-h ader-h commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of the ProcessChart component by adding defensive checks for missing or empty data before processing series updates, preventing potential errors in edge cases.

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown

Walkthrough

The resize(callback) method in ProcessChart now includes optional chaining and a length check to safely guard access to this.baseOption.series before performing width updates and invoking the callback. This prevents execution when the series array is missing or empty.

Changes

Cohort / File(s) Summary
ProcessChart Resize Guard
src/components/ProcessChart/index.js
Added optional chaining and length validation to the resize(callback) method to safely check if this.baseOption.series exists and contains elements before iterating, updating widths, and executing the callback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A cautious hop through empty arrays,
Where optional chains now guard the way,
No crashes when the series stray,
Safe and sound, come what may! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix(ProcessChart): add compatibility handling' is vague and does not clearly convey the specific change made (adding optional chaining guards to prevent errors when series is missing or empty). Use a more specific title that describes the actual fix, such as 'fix(ProcessChart): guard series access with optional chaining' or 'fix(ProcessChart): prevent errors when series is empty'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/ProcessChart/index.js`:
- Around line 82-90: The resize callback should always be invoked and the code
must guard against missing nameSeries before mutating its width: ensure
callback(this.baseOption, { notMerge: false }) is called unconditionally (i.e.,
even when series is empty or undefined), and only call
setNameSeriesWidth(nameSeries, this.dataSet, this.iChartOption,
this.chartInstance) when nameSeries is found (guard nameSeries !==
undefined/null) to avoid exceptions; locate the logic around series iteration
and the calls to setNameSeriesWidth and callback and reorder/guard accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aae80693-1385-44db-808e-d9855e0e9a10

📥 Commits

Reviewing files that changed from the base of the PR and between 2d30e28 and f10889a.

📒 Files selected for processing (1)
  • src/components/ProcessChart/index.js

Comment on lines +82 to +90
if (series && series.length > 0) {
let nameSeries;
series.forEach(element => {
if(element.name === 'seriesName'){
nameSeries = element;
}
});
setNameSeriesWidth(nameSeries, this.dataSet, this.iChartOption, this.chartInstance);
callback(this.baseOption, { notMerge: false })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Keep resize callback unconditional and guard nameSeries before width mutation

Line 90 now skips callback(...) when series is empty/missing, which changes resize behavior and can leave the chart unrefreshed during partial init states. Also, Line 89 can still throw if no seriesName entry is found.

Suggested fix
   resize(callback){
-    let series = this.baseOption?.series;
-    if (series && series.length > 0) {
-      let nameSeries;
-      series.forEach(element => {
-          if(element.name === 'seriesName'){
-            nameSeries = element;
-          }
-      });
-      setNameSeriesWidth(nameSeries, this.dataSet, this.iChartOption, this.chartInstance);
-      callback(this.baseOption, { notMerge: false })
-    }
+    const series = this.baseOption?.series;
+    if (series?.length > 0) {
+      const nameSeries = series.find((element) => element.name === 'seriesName');
+      if (nameSeries) {
+        setNameSeriesWidth(nameSeries, this.dataSet, this.iChartOption, this.chartInstance);
+      }
+    }
+    callback(this.baseOption, { notMerge: false });
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ProcessChart/index.js` around lines 82 - 90, The resize
callback should always be invoked and the code must guard against missing
nameSeries before mutating its width: ensure callback(this.baseOption, {
notMerge: false }) is called unconditionally (i.e., even when series is empty or
undefined), and only call setNameSeriesWidth(nameSeries, this.dataSet,
this.iChartOption, this.chartInstance) when nameSeries is found (guard
nameSeries !== undefined/null) to avoid exceptions; locate the logic around
series iteration and the calls to setNameSeriesWidth and callback and
reorder/guard accordingly.

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.

1 participant