Forum rules
A place to show off your creations with noesisGUI and comment on them. From XAML snippets to full projects.
 
cosmo
Topic Author
Posts: 14
Joined: 27 Mar 2015, 13:52

Arc and Pie Chart

17 Dec 2015, 19:52

Good Afternoon,

I had the need to build an arc control and pie chart control for my current project and figured I would share.

There is a lot more that could be done and I may update in the future with a legend for the pie chart and tool-tips.

Originally I was going to have the collection be a dependency property for the pie slices but there is an issue that I was unable to resolve with the dependency property when using noesis during the build process, but it dosen't seem important.

Here are examples of both.
<UserControl 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:control="clr-namespace:Assets.BrightHue.Control;assembly=Nexus.Views"
        mc:Ignorable="d"
        Height="350" Width="525">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <control:PieChartControl Width="90" Height="90" Grid.Column="0">
            <control:PieChartControl.PieSlices>
                <control:PieSlice Color="Blue" Percent="60"></control:PieSlice>
                <control:PieSlice Color="Red" Percent="10"></control:PieSlice>
                <control:PieSlice Color="Black" Percent="40"></control:PieSlice>
            </control:PieChartControl.PieSlices>
        </control:PieChartControl>
        <control:ArcControl Height="60" Width="60" ArcWidth="90" Fill="Aquamarine" Direction="90" Grid.Column="1"/>
    </Grid>
</UserControl>
Thanks,
Greg
Attachments
controls.7z
(1.92 KiB) Downloaded 249 times
 
User avatar
jsantos
Site Admin
Posts: 1873
Joined: 20 Jan 2012, 17:18
Contact:

Re: Arc and Pie Chart

21 Dec 2015, 08:02

Amazing! Thanks for sharing!
Originally I was going to have the collection be a dependency property for the pie slices but there is an issue that I was unable to resolve with the dependency property when using noesis during the build process, but it dosen't seem important.
Could you elaborate more on that issue?
 
cosmo
Topic Author
Posts: 14
Joined: 27 Mar 2015, 13:52

Re: Arc and Pie Chart

04 Jan 2016, 17:02

Ive been on a Christmas Holiday for the last few weeks. Here is what I ran into.

For the pie slice collection on the PieChartControl if I use a standard collection with a backing field everything works as expected. This can be seen as follows.
        public ObservableCollection<PieSlice> _pieSlices = new ObservableCollection<PieSlice>();


        public ObservableCollection<PieSlice> PieSlices
        {
            get
            {
                return _pieSlices;
            }
            set
            {
                _pieSlices = value;
            }
        }
If I use a dependency property for the for the collection instead I am getting an invalid cast exception that occurs. I am attempting to initialize the field from the FrameworkPropertyMetadata to a new ObservableCollection<PieSlice> but it appears that it is not happening as I expect it to as an invalid cast exception occurs during runtime. For non collection types it works as expected. But for a collection, at least a generic observable collection the underlying data type seems to be getting set wrong.

Here is the code I am using for this.
        public static DependencyProperty PieSlicesProperty =
            DependencyProperty.Register("PieSlices",
            typeof(ObservableCollection<PieSlice>),
            typeof(PieChartControl),
            new FrameworkPropertyMetadata(new ObservableCollection<PieSlice>()));

        public ObservableCollection<PieSlice> PieSlices
        {
            get { return GetValue(PieSlicesProperty) as ObservableCollection<PieSlice>; }
            set { SetValue(PieSlicesProperty, value); }
        }
It has no real effect on my project having the collection as a dependency property but I can see instances where it would be an issue.
 
User avatar
sfernandez
Site Admin
Posts: 1167
Joined: 22 Dec 2011, 19:20

Re: Arc and Pie Chart

07 Jan 2016, 13:09

Could you please create a user account in our bugtracker and report this bug, thanks.

Who is online

Users browsing this forum: No registered users and 1 guest