Skip to content

Enable automatic graph updates when values change#655

Merged
Bujee415 merged 26 commits intomasterfrom
feature/chart-controls-subscribe-notifypropertychanged
Oct 29, 2025
Merged

Enable automatic graph updates when values change#655
Bujee415 merged 26 commits intomasterfrom
feature/chart-controls-subscribe-notifypropertychanged

Conversation

@YukiMatsuzawa
Copy link
Copy Markdown
Contributor

Description

This update improves existing chart components so that graphs automatically reflect changes in the underlying data values.


Changes

  • Added NotifiableDataPoint, ValueHolder, and related helper classes to manage property change notifications.
  • Refactored Annotator and ScatterControlSlim to listen for data updates and re-render automatically.
  • Introduced IPropertiesAccessor abstraction to replace expression-based property access.
  • Removed unnecessary manual refresh logic and unified property update handling.

Impact

  • Affects Annotator and ScatterControlSlim components in ChartDrawing.
  • Behavior of graph updates is now event-driven rather than manually triggered.
  • Backward compatibility preserved for most existing bindings.

Testing

  • Added new unit tests:

    • ValueHolderTests verifies that property change notifications correctly update observed values, and that event detachment works properly.
    • ExpressionHelperTests ensures property accessor expressions behave as expected and handle invalid input safely.
  • Added new UI test pages:

    • ScatterControlSlimNotifyTest and AnnotatorNotifyTest confirm that graphs visually update when underlying data changes.
    • ScatterControlSlimTest2 validates both typed and typeless data scenarios.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for property change notification tracking in chart controls, enabling reactive updates when nested properties change. The main enhancement allows chart controls to automatically update visualizations when properties on bound data objects implement INotifyPropertyChanged.

Key Changes:

  • Implemented a comprehensive property accessor system with support for typed and dynamic property access
  • Added ValueHolder and NotifiableDataPoint classes to track nested property changes
  • Enhanced ScatterControlSlim and Annotator to respond to property changes in data items
  • Added extensive unit tests for the new expression helper functionality

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Common/ChartDrawing/Helper/ExpressionHelper.cs Added new methods for generating property getter expressions with extensive documentation
src/Common/ChartDrawing/Helper/PropertiesAccessor.cs Factory for creating appropriate property accessor implementations
src/Common/ChartDrawing/Helper/TypedPropertiesAccessor.cs Typed property accessor using compiled expressions
src/Common/ChartDrawing/Helper/DynamicPropertiesAccessor.cs Dynamic property accessor for runtime type resolution
src/Common/ChartDrawing/Helper/IdentityAccessor.cs Identity accessor for empty property strings
src/Common/ChartDrawing/Helper/IgnoreAccessor.cs Null accessor for null property strings
src/Common/ChartDrawing/Helper/IPropertiesAccessor.cs Common interface for property accessors
src/Common/ChartDrawing/Data/ValueHolder.cs Tracks nested property changes via INotifyPropertyChanged
src/Common/ChartDrawing/Data/NotifiableDataPoint.cs Wraps data items with change notifications for chart coordinates
src/Common/ChartDrawing/Chart/ScatterControlSlim.cs Refactored to use new property accessor system with change tracking
src/Common/ChartDrawing/Chart/Annotator.cs Updated to use property accessors and support reactive label updates
tests/Common/ChartDrawingTests/Helper/ExpressionHelperTests.cs Comprehensive tests for expression helper methods
tests/Common/ChartDrawingTests/Data/ValueHolderTests.cs Tests for ValueHolder property change tracking
tests/Common/ChartDrawingUiTest/Chart/ScatterControlSlimTest2.xaml New UI test for scatter control with typed/typeless variants
tests/Common/ChartDrawingUiTest/Chart/ScatterControlSlimNotifyTest.xaml UI test for property change notifications
tests/Common/ChartDrawingUiTest/Chart/AnnotatorNotifyTest.xaml UI test for annotator change notifications
src/MSDIAL5/MsdialGuiApp/View/Search/PeakSpotNavigatorView.xaml Fixed ComboBox binding to use ComboBoxItem with DataContext
src/MSDIAL5/MsdialGuiApp/Model/Gcms/GcmsAnalysisModel.cs Updated to handle nullable annotation labels
tests/Common/ChartDrawingTests/ChartDrawingTests.csproj Simplified project references format
tests/Common/ChartDrawingUiTest/ChartDrawingUiTest.csproj Added UseWPF property and changed LangVersion to latest

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to 6
using System.Runtime.CompilerServices;

Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The System.Runtime.CompilerServices namespace is imported but not used in this file. This import should be removed to keep the code clean.

Suggested change
using System.Runtime.CompilerServices;

Copilot uses AI. Check for mistakes.
<TargetFrameworkProfile />
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>12</LangVersion>
<LangVersion>latest</LangVersion>
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Using 'latest' for LangVersion is not recommended for production code as it can lead to unpredictable behavior when the SDK is updated. Consider specifying an explicit version like '12' or use 'latestmajor' for more stability.

Suggested change
<LangVersion>latest</LangVersion>
<LangVersion>7.3</LangVersion>

Copilot uses AI. Check for mistakes.
return;
}
Value = Item is null ? null : Accessor.Apply(Item);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Value)));
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The Value property is being set and then PropertyChanged is invoked manually on line 115, but the Value setter already invokes PropertyChanged when the value changes (lines 36-38). This results in duplicate property change notifications. Remove line 115 to avoid the redundant notification.

Suggested change
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Value)));

Copilot uses AI. Check for mistakes.
@Bujee415 Bujee415 merged commit b4eb7f3 into master Oct 29, 2025
9 checks passed
@Bujee415 Bujee415 deleted the feature/chart-controls-subscribe-notifypropertychanged branch October 29, 2025 12:10
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