Jump to content
Software FX Community

Selectively showing markers


Recommended Posts

There are 3 ways to accomplish this

1) Using Conditional attributes: the following XAML will selectively show markers for objects whose Discount property is bigger than 0.3

<cfx:Chart Gallery="Line"<cfx:Chart.Series>   <cfx:SeriesAttributes BindingPath="CurrentPrice"/>  </cfx:Chart.Series<cfx:Chart.AllSeries>   <cfx:AllSeriesAttributes>   <cfx:AllSeriesAttributes.Marker>   <cfx:MarkerAttributes Visibility="Hidden"/>   </cfx:AllSeriesAttributes.Marker>   </cfx:AllSeriesAttributes</cfx:Chart.AllSeries<cfx:Chart.ConditionalAttributes>   <cfx:ConditionalAttributes Content="Special Value">   <cfx:ConditionalAttributes.Condition>   <cfx:RangeCondition From="0.3" BindingPath="Discount"/>   </cfx:ConditionalAttributes.Condition>   <cfx:ConditionalAttributes.Marker>   <cfx:MarkerAttributes Visibility="Visible" />   </cfx:ConditionalAttributes.Marker>   </cfx:ConditionalAttributes</cfx:Chart.ConditionalAttributes></cfx:Chart>

Note that the Content property allows you to display conditional attribute in legend, Instead of RangeCondition you could also use DelegateCondition which allows you to provide a delegate that decides when to use this conditional attribute.

2) Use Points API manually

PointAttributes pointAttr = new PointAttributes();pointAttr.Content = "Using Points";pointAttr.Marker.Visibility = Visibility.Visible;pointAttr.Marker.Fill = Brushes.Red;chart1.Points[0, 1] = pointAttr;chart1.Points[0, 5] = pointAttr;

Note that you can reuse the same PointAttributes for multiple points, if you do not set the Content property it will not appear in the legend box. 

3) Changing the template for the marker

Using this approach you could change the template used for the point markers and bind the visibility of the marker to one of your properties, there are a couple of drawbacks to this approach: first the visuals for all markers will be generated (although only some of them will be visible) which could negatively affect performance if you have thousands of points or more, also you would lose the flexibility of easily changing marker shapes.




Link to comment
Share on other sites

I decided to go with #2 because it was the fastest to implement. However, I noticed that in a stacked area chart, the Z-order of the marker is tied to the Z-order of the series it is attached to:

Posted Image 

(Notice the cut-off markers which make using them on a stacked area chart undesirable).

Is there a simple fix for this?


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.

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.

  • Create New...