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
    • The pie chart viewer now falls back to showing relevant global data (rather than an empty state) when the current selection has too few non-zero event types, improving visibility and avoiding blank charts for small/insufficient selections.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aac54bbc-c3c5-419a-ae3d-8ac2493cd2af

📥 Commits

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

📒 Files selected for processing (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/viewers/piecharts/TmfPieChartViewer.java

📝 Walkthrough

Walkthrough

The pie chart viewer's refresh() now calls newGlobalEntries(this) when fewer than two non-zero event types exist, showing the global pie chart instead of an empty selection.

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: Matches this change replacing the empty-selection path with showing the global pie chart for <2 event types.
  • #414: Also references TmfPieChartViewer.refresh behavior for low event-type counts; this PR makes the viewer prefer global entries instead of empty selection.

Poem

🐰
A hop, a nibble, code so neat,
When event types are small and few,
We show the whole pie—no empty seat,
Slices join together, bold and true.

🚥 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 accurately describes the main change: adding a fallback to display the global pie chart instead of an empty viewer when fewer than two event types are present.
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"

@GuillaumeZhang321

Copy link
Copy Markdown
Author

Looks good to me!

There seems to be a CI check fail that matches the CI failure on main, is this normal?

Also, would it be possible to include this change in some form of nightly build for trace compass 11.3 since I am working on a project in Eclipse 2026-03? Thanks

@MatthewKhouzam

Copy link
Copy Markdown
Contributor

Looks like this work is fine, but it fails because of the upgrade. rebase it and it should work.

@GuillaumeZhang321

Copy link
Copy Markdown
Author

Looks like this work is fine, but it fails because of the upgrade. rebase it and it should work.

Sorry but I might be confused. Which commit do I rebase on top of? My fork is built on top of the current latest commit on main already.

@MatthewKhouzam

Copy link
Copy Markdown
Contributor

The problem is that the "OK" button got replaced with an "APPLY" button in the tests. not your code, it's the platform that's changing. So that's why I'm saying a rebase would fix it. @arfio could you confirm?

@arfio

arfio commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The release is today, after that the rebase will fix the issue. For now the build is not using the new platform by default.

@GuillaumeZhang321

Copy link
Copy Markdown
Author

The release is today, after that the rebase will fix the issue. For now the build is not using the new platform by default.

Just making sure, if I want to use an official eclipse download repo link, this PR's changes will only be reflected in the tracecompass 12.0 links? There are no possibilities to have the PR change on an 11.3 version of tracecompass without me using my local version of tracecompass directly?

Thanks!

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

Copy link
Copy Markdown
Author

Hello,

Would it be possible to restart the workflow check for this PR and #416 ?

Thanks!

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.

3 participants