Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2090
XamDoughnutChart:Assign Color per slice and style seperator
posted
Hello,
I started to work with the XamDoughNut control and have a number of questions:
1. How can I set the background of each slice via binding? The underlying List<T> contains object with following properties:
public class Stundenerfolg
  {
   public string Beschreibung { get; set; }
   public decimal Stunden { get; set; }
   public string Label { get { return this.Stunden.ToString("N0") + "h " + this.Beschreibung; } }
   public SolidColorBrush Farbe { get; set; }
  }
This is the XAML definition:
<ig:XamDoughnutChart Grid.Row="0" x:Name="doughnutChart" InnerExtent="50">
 <ig:XamDoughnutChart.Series>
  <ig:RingSeries x:Name="ringSeries"
            ItemsSource="{Binding Baustellenerfolg, UpdateSourceTrigger=PropertyChanged}"
            LabelMemberPath="Label"
            ValueMemberPath="Stunden"
            Legend="{Binding ElementName=legend}"
            ToolTip="{}{Beschreibung}"
   LabelsPosition="BestFit"
            LabelExtent="20"
            OthersCategoryType="Number"
            RadiusFactor="0.8"/>
 </ig:XamDoughnutChart.Series>
</ig:XamDoughnutChart>
I have seen this posting: www.infragistics.com/.../455170   but did not see if there is possibility to bind the color of each item.
Currently I am refreshing the public List<SolidColorBrush> BaustellenErfolgFarben { get; private set; } in order to get the correct color for each item.
2. The output shows following error: System.Windows.Data Error: 40 : BindingExpression path error: 'ActualOutline' property not found on 'object' ''Arc' (Name='')'. BindingExpression:Path=Series.ActualOutline; DataItem='PieSliceDataContext' (HashCode=41847592); target element is 'Border' (Name=''); target property is 'BorderBrush' (type 'Brush')
What is missing here?
3. Is there a chance to define a specific seperator beween two slices:
a) The whole diagram represents an overview about hours for a project: estimated, already used hours and planed for the future
b) Between the slice of already used hours and planed hours I would like to create a big seperator that says "Today"
Thanks
Niko
  • 34810
    Offline posted

    Hello Niko,

    I have been investigating into the requirements that you are looking to achieve, and I have some information for you on this matter. I will answer your inquiries in the order they were asked.

    1. The best way to “bind” the background of each slice in the XamDoughnutChart is described at the forum thread that you have linked. There is nothing that you can write a Style for that will affect this, as the Slice elements of the XamDoughnutChart resolve their background colors internally using the Brushes collection of the owning RingSeries when they are drawn.

    The index of the Slice elements will be proportionate to the index of your data items, though, which will also be proportionate to the brush in the BrushCollection. For example, a particular RingSeries’s Slices[0] will correspond to your bound ItemsSource[0], which will receive the brush inside of the Brushes property at the BrushCollection[0] that you assign to it. As such, I would highly recommend usage of the Brushes property of your RingSeries and set it up such that the order of the brushes are the same order as in your bound ItemsSource.

    2. It sounds like you have a Style or some sort of binding in your application that is bound to Series.ActualOutline – possibly targeting some sort of Border element. From the description of the error, the “Series” property is returning an Arc, which does not have an ActualOutline property, and so this binding will fail. Would it be possible for you to please provide this style that you are writing or the binding that you are using, if any?

    3. The best thing I can recommend for this is to use another data item to serve as your “separator” in this case. You mentioned that you wish to place this between a slice of “already used hours” and “planned hours.” If you place your “today” data item between the two data items that make up these slices in your ItemsSource, a new slice will appear between them, which can serve as your separator in this case. There does not currently exist any other “separator” functionality in the XamDoughnutChart.

    Regarding your above requirements with respect to points 1 and 3, if you would like to see custom separator support or something like a “BrushMemberPath” implemented in the XamDoughnutChart, I would recommend suggesting a new product idea for these features. You can do this at our WPF Ideas Site, as this will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.

    Please let me know if you have any other questions or concerns on this matter.