Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
remove a Trendline from xamDataChart
posted

Hi. I want to remove some trendline, I've tried doing it like this in the codebehind:

Infragistics.Controls.Charts.ValueOverlay overlay = new Infragistics.Controls.Charts.ValueOverlay();
overlay.Brush = Brushes.Green;
overlay.BorderThickness = new Thickness(3);
overlay.Thickness = 3;
overlay.Axis = this.xmYAxis;
overlay.Value = 80.00;
this.xmDataChart.Series.Remove(overlay);

But the Trendline wasn't deleted?

I set the Trendline with this code:

 Infragistics.Controls.Charts.ValueOverlay overlay = new Infragistics.Controls.Charts.ValueOverlay();
 overlay.Brush = Brushes.Green;
 overlay.BorderThickness = new Thickness(3);
 overlay.Thickness = 3;
 overlay.Axis = this.xmYAxis;
overlay.Value = 80.00;
this.xmDataChart.Series.Add(overlay);

Thanks for your help

Parents
  • 27093
    posted

    Hello, 

    I have been looking into your requirement and from your code snippet it appears that you are creating a new instance of the ValueOverlay and trying to remove another that has the same properties. If you do it like so: 

    ValueOverlay overlay = new ValueOverlay();

    overlay.Brush = Brushes.Green;

    overlay.BorderThickness = new Thickness(3);

    overlay.Thickness = 3;

    overlay.Axis = this.xmYAxis;

    overlay.Value = 80.00;

    this.chart1.Series.Add(overlay);

    this.chart1.Series.Remove(overlay);

     

    it works, however if you use a new instance it is still a different instance even though it has the same name. What I can suggest is either preserving the instance until you need to remove it from the collection, or iterate through the Series and when the proper instance is found remove it by index using the RemoveAt method. 

    Please let me know, if you require any further clarification on the matter.

Reply Children