skjhaveri Posted May 10, 2008 Report Share Posted May 10, 2008 Hi, I am using ChartFx WPF 8.0 Beta release. I have collection contains two properties Date and Value So i wanted to draw line chart where i am abble to plot each value in graph. Now by default value which are passing from pastdate (date less or equal to today) should show as solid line, but any future date line should apply DashArray for line. Is it possible to achieve with single series in chart!!! Thanks Shrenik Quote Link to comment Share on other sites More sharing options...
JuanC Posted May 12, 2008 Report Share Posted May 12, 2008 >> Is it possible to achieve with single series in chart!!! Yes, it is possible. There are 2 ways to accomplish this, manually user per-point attributes or using Conditional Attributes 1) Using per-point Attributes The Points collection allows you to assign per-point attributes. private void PageLoaded(object sender, EventArgs e){ chart1.DataBound += new EventHandler(OnChartBound);}void OnChartBound (object sender, EventArgs e){ // Find the first point that matches your criteria (date greater than today) int firstPoint = 4; PointAttributes pointAttr = new PointAttributes(); pointAttr.StrokeDashArray = new DoubleCollection(new double[] { 1, 2}); int n = chart1.Data.Points; for (int i = firstPoint; i < n; i++) chart1.Points = pointAttr; } 2-a) Using ConditionalAttributes in code private void PageLoaded(object sender, EventArgs e){ ConditionalAttributes conditional = new ConditionalAttributes(); conditional.StrokeDashArray = new DoubleCollection(new double[] { 1, 2 }); RangeCondition rangeCondition = new RangeCondition(); rangeCondition.From = DateTime.Today; rangeCondition.BindingPath = "X"; conditional.Condition = rangeCondition; chart1.ConditionalAttributes.Add(conditional); } 2- Or using ConditionalAttributes in XAML <cfx:Chart.ConditionalAttributes> <cfx:ConditionalAttributes StrokeDashArray="1 2"> <cfx:ConditionalAttributes.Condition> <cfx:RangeCondition From="{x:Static sys:DateTime.Today}" BindingPath="X"/> </cfx:ConditionalAttributes.Condition> </cfx:ConditionalAttributes></cfx:Chart.ConditionalAttributes> Where sys and cfx are defined in your root XAML node as follows xmlns:sys="clr-namespace:System;assembly=mscorlib"xmlns:cfx="clr-namespace:ChartFX.WPF;assembly=ChartFX.WPF"Unfortunately we recently discovered (and fixed) an issue related to conditional attributes when using dates in the X axis, if you want to follow this approach please send an email to wpf at softwarefx dot com requesting an updated build. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
skjhaveri Posted June 11, 2008 Author Report Share Posted June 11, 2008 Thanks I have achieved this by creating my own condition. following is code for that /// <summary> /// Check Tomrrow is condition extension for validating dates which are greater than current date /// so graph should show data for those dates in Dash format. /// </summary> public sealed class CheckTomorrow : ConditionBase { /// <summary> /// Evaluates the specified cond value. /// </summary> /// <param name="condValue">The cond value.</param> /// <returns></returns> public override bool Evaluate(ConditionValue condValue) { Data data = condValue.DataItem as Data; if (null != data) { return ((Data)condValue.DataItem).Date > DateTime.Today; } return false; } } Now can you help me for more issues?? 1. How to constomise Legend in XAML. I didnt find any default style or template and not able to generate in Expression. Which type its targeting what can be datacontext of that??? 2. If i create run time series than its adding two more series its own, no idea from where its come. any clue!!! 3. Can i create style of series attribute and apply thru my code??? 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.