DSimons Posted December 2, 2009 Report Share Posted December 2, 2009 Hi, I am currently using a bullet chart with multiple instances of the following data structure: <RechargeInfo START_TIME="11/1/2009 6:00:00 PM" FINISH_TIME="11/1/2009 6:45:00 PM" BATT_START=".10" BATT_FINISH=".90" COUPLING="1.77777777777778" /> I am using the chart to compare the BATT_START and BATT_FINISH values in the data structure above. I have successfully used the Conditional Attributes feature to color the fill of the graph based on specific rules in the XAML code with the following code: <cfx:Chart.ConditionalAttributes> <cfx:ConditionalAttributes Fill="Red"> <cfx:ConditionalAttributes.Condition> <cfx:RangeCondition From="0.0" To="0.5" BindingPath="@COUPLING"/> </cfx:ConditionalAttributes.Condition> </cfx:ConditionalAttributes> <cfx:ConditionalAttributes Fill="Yellow"> <cfx:ConditionalAttributes.Condition> <cfx:RangeCondition From="0.5" To="1.25" BindingPath="@COUPLING"/> </cfx:ConditionalAttributes.Condition> </cfx:ConditionalAttributes> <cfx:ConditionalAttributes Fill="Green"> <cfx:ConditionalAttributes.Condition> <cfx:RangeCondition From="1.25" BindingPath="@COUPLING"/> </cfx:ConditionalAttributes.Condition> </cfx:ConditionalAttributes> </cfx:Chart.ConditionalAttributes> I would like to have a legend box which can display the meaning of the coloring of these conditional attributes, but I am not sure how to do this with the current LegendBox. Per another Forum post here I am not sure this is possible using the LegendBox. Can you help me to display a legend to the user for these conditional attributes, and if necessary, suggest a replacement for the conditional attributes? Quote Link to comment Share on other sites More sharing options...
JuanC Posted December 2, 2009 Report Share Posted December 2, 2009 Please try setting the Content property on the ConditionalAttributes object, e.g. <cfx:ConditionalAttributes Fill="Red" Content="Less than Average"> You can also use Visuals if desired. JuanC Quote Link to comment Share on other sites More sharing options...
DSimons Posted December 2, 2009 Author Report Share Posted December 2, 2009 This looks like it has worked quite well! I added Content properties and now these conditional attributes are showing up in the Legend. However, this raises a follow-up question: how can I remove the the first two series in the legend, so I am only showing the colors ConditionalAttributes? Directions for how to do this appear to be in the ChartFX Resource Center under "LegendItemAttributes class", but I think there is an error in this documentation. The code suggested is: LegendItemAttributes item = new LegendItemAttributes();chart1.LegendBox.ItemAttributes[chart1.Series[0]] = item;item.Visible = false; I am doing the following: 1) I am declaring the Series Attributes in WPF like this: <cfx:Chart.Series> <cfx:SeriesAttributesCollection> <cfx:SeriesAttributes BindingPath="@BATT_FINISH" Content="Battery Finish" /> <cfx:SeriesAttributes BindingPath="@BATT_START" Content="Battery Start" Volume="60" Opacity=".75"/> </cfx:SeriesAttributesCollection> </cfx:Chart.Series> In the C# constructor, I try to access the series: LegendItemAttributes item = new LegendItemAttributes(); _batteryRechargeChart.LegendBox.ItemAttributes[_batteryRechargeChart.Series[0]] = item; HoweverI receive the erorr on _batteryRechargeChart of: Error 2 Argument '1': cannot convert from 'ChartFX.WPF.SeriesAttributes' to 'ChartFX.WPF.Internal.ILegendItemGenerator' Additionally, I believe the 3rd line of your documentation should be corrected to: item.Visibility = System.Windows.Visibility.Hidden; Quote Link to comment Share on other sites More sharing options...
DSimons Posted December 2, 2009 Author Report Share Posted December 2, 2009 Forgot to ask my other question: I would also like to have these ConditionalAttributes only affect one of the two data series values (BATT_FINISH, not BATT_START). I thought I could do this by using the AffectedSeries property like this: <cfx:ConditionalAttributes Fill="Red" Content="Poor Coupling" AffectedSeries="1"> <cfx:ConditionalAttributes.Condition> <cfx:RangeCondition From="0.0" To="0.5" BindingPath="@COUPLING"/> </cfx:ConditionalAttributes.Condition> </cfx:ConditionalAttributes> Unfortunately if I set this AffectedSeries property the coloring no longer works for any of the series. How can I ensure that I only color one of the two data series? Quote Link to comment Share on other sites More sharing options...
JuanC Posted December 3, 2009 Report Share Posted December 3, 2009 Actually the code should be chart1.LegendBox.ItemAttributes[chart1.Series].Visibility = Visibility.Hidden; Note that the index used for the ItemAttributes property is the series collection (not one of the series), if you are using our most recent service pack you can also do it in XAML as follows <cfx:Chart.LegendBox> <cfx:LegendBox> <cfx:LegendBox.ItemAttributes> <cfx:LegendItemAttributes cfx:LegendItemAttributes.LegendItemType="Series" Visibility="Hidden"/> </cfx:LegendBox.ItemAttributes> </cfx:LegendBox> </cfx:Chart.LegendBox> JuanC Quote Link to comment Share on other sites More sharing options...
DSimons Posted December 3, 2009 Author Report Share Posted December 3, 2009 The C# method for visibility worked perfectly. I assume I dont have the most recent Service Pack for WPF - When I attempted to use your XAML example it responded with a "method not implemented". How do I get the most recent service pack? Quote Link to comment Share on other sites More sharing options...
JuanC Posted December 7, 2009 Report Share Posted December 7, 2009 You can get our most recent service pack here, we will soon be uploading a new service pack build but even though the XAML approach will work on that build we recently discovered and fixed an issue related to ConditionalAttributes when using BindingPath and AffectedSeries simultaneously (because of your post on this thread). To fix this issue you can download our most recent hotfix here, note that service pack builds go through more testing than hotfixes but we can release hotfixes as soon as issues are corrected. In both cases you need to run IE as administrator if your machine has UAC enabled. JuanC Quote Link to comment Share on other sites More sharing options...
DSimons Posted December 7, 2009 Author Report Share Posted December 7, 2009 Juan,Thanks for your reply! Does that imply that A) I discovered a small bug with the AffectedSeries in my post here? That you have been able to fix the bug and posted a hotfix as described in your post? If I have misunderstood this, could you post a quick reply addressing my question in the same post above ? Thanks again for your help, I think this will resolve all of my issues for thread when this is addressed or confirmed. Quote Link to comment Share on other sites More sharing options...
JuanC Posted December 7, 2009 Report Share Posted December 7, 2009 We have found an issue when you combine AffectedSeries and BindingPath in a condition, it has been fixed on any build marked 3624 or later. JuanC 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.