Jump to content
Software FX Community

Adding a point on a line


krb875
 Share

Recommended Posts

Hopefully this is a simple question, If I have a line graph and I want to mark a particular point on that graph with a marker and I have the corresponding value to is there away to do this without having to overlay a scatterplot on top of the line plot. 

Link to comment
Share on other sites

If you want to "highlight" one of the points in the line you can do so using the Chart.Points property. This allows you to change the marker shape, size, color, etc.

If you draw a marker on a specific XY but this is not one of the points in the line, you will probably use the Annotation extension. This extension allows you to create WPF visuals and attach them to a logical XY position inside our plot area.

If you wanted to do this in code it would be something like this:

ChartFX.WPF.Annotation.Annotations annotations = new ChartFX.WPF.Annotation.Annotations();Rectangle r = new Rectangle();r.Width = 10;r.Height = 10;r.Fill = Brushes.Red;r.Stroke = Brushes.Black;

ChartFX.WPF.Annotation.Annotations.SetAttachX(r, 2.0);ChartFX.WPF.Annotation.Annotations.SetAttachY(r, 40.0);

annotations.Children.Add®;

chart1.Extensions.Add(annotations);

Regards,

JuanC

Link to comment
Share on other sites

I just need to highlight one of the points on the line.  The source is a simple Array of Singles containing about 280 elements.  How to I highlight the X point on the line in c#.  I appreciate the work JuanC.  just incase you want to see whats going on I've attached the following

 

 

ChartFX.WPF.SeriesAttributes series1 = new ChartFX.WPF.SeriesAttributes();ChartFX.WPF.SeriesAttributes series2 = new ChartFX.WPF.SeriesAttributes();

series1.ItemsSource = m_smartBus1[region].VLOADARRAY;

series2.ItemsSource = m_smartBus2[region].VLOADARRAY;

series1.Gallery = ChartFX.WPF.Gallery.Line;

series2.Gallery = ChartFX.WPF.

Gallery.Line;series1.Fill = System.Windows.Media.Brushes.Blue;

series2.Fill = System.Windows.Media.

Brushes.OrangeRed;series1.Content = "Vload vs Ref Curve 1st Dir";

series2.Content =

"Vload vs Ref Curve 2nd Dir";series1.PointLabels.Visibility = System.Windows.Visibility.Hidden;

series2.PointLabels.Visibility = System.Windows.

Visibility.Hidden;

chartfxVloadVsRef0 = new ChartFX.WPF.Chart();

vloadvsRefElemHost0.Child = chartfxVloadVsRef0;

chartfxVloadVsRef0.AxisY = new ChartFX.WPF.Axis();chartfxVloadVsRef0.AxisY.ForceZero = false;

chartfxVloadVsRef0.Series.Add(series1);

chartfxVloadVsRef0.Series.Add(series2);

Link to comment
Share on other sites

  • 1 year later...

Hi,

I found an interesting  class (Effects) that can help you. Please look at the following code snippet:

 

LighterEffect myEffect = new LighterEffect();

  myEffect.Change = 80;

 

  chart1.Highlight.Mode = HighlightMode.Point;

  chart1.Highlight.IsEnabled = true;

  chart1.Points[0].Effects.Add(myEffect);

 

This will highlight point [0] of the Chart. You can also set the HighlightMode to Series.

This does not puts a marker shape on the chart, but it does hightlight an specific point on the chart

 

Hope this helps.

post-6106-13922412852982_thumb.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...