Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScatterSeries points change color when hovering over #1188

Closed
bennewehn opened this issue Aug 22, 2023 · 2 comments
Closed

ScatterSeries points change color when hovering over #1188

bennewehn opened this issue Aug 22, 2023 · 2 comments
Labels
not verified It is probably an issue, but we have not enough evidence to mark this as a bug.

Comments

@bennewehn
Copy link

bennewehn commented Aug 22, 2023

I'm working on a chart with point selection. With ScatterSeries and ChartPointPointerDown some
points change the color when hovering over.

Reproduce

 public partial class MainWindow : Window
 {
     public MainWindow()
     {
         InitializeComponent();
         Series[0] = S;
         S.ChartPointPointerDown += S_ChartPointPointerDown;
         DataContext = this;
     }

     private LiveChartsCore.Kernel.ChartPoint<ObservablePoint, 
         LiveChartsCore.SkiaSharpView.Drawing.Geometries.CircleGeometry, 
         LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>? lastPoint = null;
   
     private void S_ChartPointPointerDown(LiveChartsCore.Kernel.Sketches.IChartView chart, LiveChartsCore.Kernel.ChartPoint<ObservablePoint, LiveChartsCore.SkiaSharpView.Drawing.Geometries.CircleGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>? point)
     {
         if(lastPoint?.Visual != null)
         {
             lastPoint.Visual.Fill = new SolidColorPaint(SKColors.Blue);
         }

         if(point?.Visual != null)
         {
             point.Visual.Fill = new SolidColorPaint(SKColors.Red);
         }

         lastPoint = point;
     }

     public ISeries[] Series { get; set; } = new ISeries[1];

     ScatterSeries<ObservablePoint> S { get; set; } = new ScatterSeries<ObservablePoint>
     {
         Values = new ObservableCollection<ObservablePoint>
         {
             new(2.2, 5.4),
             new(4.5, 2.5),
             new(4.2, 7.4),
             new(6.4, 9.9),
             new(4.2, 9.2),
             new(5.8, 3.5),
             new(7.3, 5.8),
             new(8.9, 3.9),
             new(6.1, 4.6),
             new(9.4, 7.7),
             new(8.4, 8.5),
             new(3.6, 9.6),
             new(4.4, 6.3),
             new(5.8, 4.8),
             new(6.9, 3.4),
             new(7.6, 1.8),
             new(8.3, 8.3),
             new(9.9, 5.2),
             new(8.1, 4.7),
             new(7.4, 3.9),
             new(6.8, 2.3),
             new(5.3, 7.1),
         }

     };
 }

Screenshots

2023-08-22.13-39-33.mp4
@beto-rodriguez
Copy link
Owner

Visuals do not implement INotifyPropertyChanged, that is by design, it means that the UI will not update automatically,

Have you tried to call a chart update? like shown here https://livecharts.dev/docs/Maui/2.0.0-beta.920/samples.events.cartesian

chart.Invalidate();

@beto-rodriguez beto-rodriguez added the not verified It is probably an issue, but we have not enough evidence to mark this as a bug. label Aug 26, 2023
@bennewehn
Copy link
Author

Same problem when using chart.Invalidate();

 private void S_ChartPointPointerDown(LiveChartsCore.Kernel.Sketches.IChartView chart, 
     LiveChartsCore.Kernel.ChartPoint<ObservablePoint, 
     LiveChartsCore.SkiaSharpView.Drawing.Geometries.CircleGeometry, 
     LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>? point)
 {
     if (point?.Visual == null) return;

     if(lastPoint?.Visual != null)
     {
         lastPoint.Visual.Fill = null; 
     }

     point.Visual.Fill = new SolidColorPaint(SKColors.Red);
     chart.Invalidate();
     lastPoint = point;
 }

@bennewehn bennewehn changed the title ScatterSeries points change color when highlighting ScatterSeries points change color when hovering over Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not verified It is probably an issue, but we have not enough evidence to mark this as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants