Mick Posted August 10, 2010 Report Share Posted August 10, 2010 Is there any way to only show certain markers on a line graph? i.e. I only want to show the 3 blue markers, even though there are 10 discrete data points on the line. Thank you, Mick Quote Link to comment Share on other sites More sharing options...
JuanC Posted August 11, 2010 Report Share Posted August 11, 2010 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. JuanC Quote Link to comment Share on other sites More sharing options...
Mick Posted August 12, 2010 Author Report Share Posted August 12, 2010 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: (Notice the cut-off markers which make using them on a stacked area chart undesirable). Is there a simple fix for this? Mick Quote Link to comment Share on other sites More sharing options...
Mick Posted August 12, 2010 Author Report Share Posted August 12, 2010 Also, notice that there is a vertical line present on the first 5-10% on the chart when markers are turned on this way. Here is another example of this behavior: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.