Skip to content

Add fallback in PieChartViewer refresh to not show empty pie chart viewer#413

Open
GuillaumeZhang321 wants to merge 1 commit into
eclipse-tracecompass:masterfrom
GuillaumeZhang321:pie_chart_fallback
Open

Add fallback in PieChartViewer refresh to not show empty pie chart viewer#413
GuillaumeZhang321 wants to merge 1 commit into
eclipse-tracecompass:masterfrom
GuillaumeZhang321:pie_chart_fallback

Conversation

@GuillaumeZhang321

@GuillaumeZhang321 GuillaumeZhang321 commented Jun 5, 2026

Copy link
Copy Markdown

… but not enough event types in the selection, show the global pie chart instead.

What it does

In org.eclipse.tracecompass.internal.tmf.ui.viewers.piecharts.TmfPieChartViewer.refresh, instead of making an empty viewer when less than two events types are selected, show the change shows the global pie chart.

How to test

In statistics view, select only one event type and see that instead of "No Data" being shown, the global pie chart is left.

Follow-ups

Addresses #412

Review checklist

  • [x ] As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Pie chart viewer now displays relevant global data instead of an empty state in certain scenarios.

… but not enough event types in the selection, show the global pie chart instead.
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place.

Review Change Stack

📝 Walkthrough

Walkthrough

The pie chart viewer's refresh() method now transitions to the global pie chart state when fewer than two event types are available, instead of showing an empty selection. This single-line routing change updates the viewer's behavior for low-data scenarios.

Changes

Pie Chart Viewer State Transition

Layer / File(s) Summary
Refresh condition routing for low event-type count
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java
When nbEventsType < 2, the viewer now calls newGlobalEntries(this) to display the global pie chart instead of newEmptySelection(this), with the condition comment updated accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related issues

  • #412: Main change directly implements the exact fix requested—when fewer than two non-zero event types are present, the viewer now shows the global pie chart via newGlobalEntries(this) instead of creating an empty selection.

Poem

🥧 A slice of pie for every chart,
When types fall short, we show the whole,
No empty void, no missing part—
Global entries make us whole! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a fallback mechanism to prevent empty pie chart display by showing the global pie chart instead.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

🧹 Nitpick comments (1)
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java (1)

408-431: ⚡ Quick win

Consider avoiding duplicate global chart updates.

When both refreshGlobal and refreshSelection are true and the selection has fewer than two event types, newGlobalEntries(this) is called twice—once at line 410 and again at line 427. This queues redundant async updates to the global chart with identical data.

⚡ Proposed optimization
         if (refreshGlobal) {
             /* will update the global pc */
             getCurrentState().newGlobalEntries(this);
         }

         if (refreshSelection) {
             // Check if the selection is empty
             int nbEventsType = 0;
             Map<String, Long> selectionModel = getTotalEventCountForChart(false);
             for (Long l : selectionModel.values()) {
                 if (l != 0) {
                     nbEventsType++;
                 }
             }

             // Check if the selection is empty or if
             // there is enough event types to show in the piecharts
             // if there aren't enough, show the global pie chart
             if (nbEventsType < 2) {
-                getCurrentState().newGlobalEntries(this);
+                if (!refreshGlobal) {
+                    getCurrentState().newGlobalEntries(this);
+                }
             } else {
                 getCurrentState().newSelection(this);
             }
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java`
around lines 408 - 431, The code in TmfPieChartViewer calls
getCurrentState().newGlobalEntries(this) twice when both refreshGlobal and
refreshSelection are true and the selection has fewer than two event types;
modify the logic so newGlobalEntries(this) is only queued once by computing the
selection branch first (using getTotalEventCountForChart() and nbEventsType) to
decide between newSelection(this) or newGlobalEntries(this), and then only call
newGlobalEntries(this) for the refreshGlobal path if the global update hasn't
already been queued (i.e., track a local boolean like globalQueued or check
refreshSelection outcome); reference methods: getTotalEventCountForChart(),
getCurrentState().newGlobalEntries(), getCurrentState().newSelection(), and the
refreshGlobal/refreshSelection flags.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java`:
- Around line 408-431: The code in TmfPieChartViewer calls
getCurrentState().newGlobalEntries(this) twice when both refreshGlobal and
refreshSelection are true and the selection has fewer than two event types;
modify the logic so newGlobalEntries(this) is only queued once by computing the
selection branch first (using getTotalEventCountForChart() and nbEventsType) to
decide between newSelection(this) or newGlobalEntries(this), and then only call
newGlobalEntries(this) for the refreshGlobal path if the global update hasn't
already been queued (i.e., track a local boolean like globalQueued or check
refreshSelection outcome); reference methods: getTotalEventCountForChart(),
getCurrentState().newGlobalEntries(), getCurrentState().newSelection(), and the
refreshGlobal/refreshSelection flags.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78535148-aeb1-4e40-b9cc-30b293b40b70

📥 Commits

Reviewing files that changed from the base of the PR and between 75e5dc8 and a8923ff.

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java

@MatthewKhouzam MatthewKhouzam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me!

@MatthewKhouzam

Copy link
Copy Markdown
Contributor

Just a friendly reminder, if you used AI in any patch (I doubt this one has AI), you need to bring it up in the commit message. Like "This patch was created with the assistance of chatgpt 5.5"

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.

2 participants