This is a migrated thread and some comments may be shown as answers.

databinding - pie chart color

7 Answers 119 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 07 Jul 2011, 08:38 PM
hi

is there a way to databind background color of the sliice of  pie chart?

Thx

Kevin

7 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 08 Jul 2011, 08:47 PM
hello.. anybody?
0
Evgenia
Telerik team
answered on 12 Jul 2011, 08:42 AM
Hi Kevin,

Could you elaborate a bit more on your requirement? What do you mean by databinding the colors for the Pie Slices? Do you mean that you want each of your Slice colored due to condition - for example if it's Value is > 100 - apply red color otherwise apply Blue color?

Greetings,
Evgenia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kevin
Top achievements
Rank 1
answered on 12 Jul 2011, 01:31 PM
hi Evgenia

yes.  but I will have the color hex value in the view model, so just bind it to the slice's background color.

Kevin
0
Evgenia
Telerik team
answered on 14 Jul 2011, 01:11 PM
Hello Kevin,

You can bind your custom color to the Pie's slice by it's style:
<Style x:Key="PieStyle" TargetType="telerik:Pie">
         <Setter Property="Template" >
             <Setter.Value>
                 <ControlTemplate TargetType="telerik:Pie">
                     <Canvas x:Name="PART_MainContainer">
                         <Ellipse Clip="{TemplateBinding FigurePath}" 
                              Width="{TemplateBinding ItemActualWidth}"
                              Height="{TemplateBinding ItemActualHeight}"
                              Fill="{Binding DataItem.Color}"
                              StrokeThickness="0"
                              Style="{TemplateBinding ItemStyle}"/>
                         <Path x:Name="PART_DefiningGeometry" 
                           Data="{TemplateBinding FigurePath2}" 
                           Fill="{Binding DataItem.Color}"
                           Style="{TemplateBinding ItemStyle}"/>
                         <Ellipse 
                         Clip="{TemplateBinding FigurePath3}" 
                         Fill="{StaticResource PieMaskBrush}" 
                         Width="{TemplateBinding ItemActualWidth}"
                         Height="{TemplateBinding ItemActualHeight}"/>
                     </Canvas>
                 </ControlTemplate>
             </Setter.Value>
         </Setter>
     </Style>

This is the static resource used for the PieMaskBrush:
<RadialGradientBrush x:Key="PieMaskBrush" GradientOrigin="0.5,0.5">
           <GradientStop Color="#33FFFFFF" Offset="0.88"/>
           <GradientStop Color="#00FFFFFF" Offset="0.65"/>
           <GradientStop Offset="0.89"/>
       </RadialGradientBrush>

You may find more information about creating Color property in this help topic as the approach shown there is quite similar to the one you are following.

Best wishes,
Evgenia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
n
Top achievements
Rank 1
answered on 19 Aug 2011, 03:25 PM
I am getting an error during run time when I use this style. I have the RadChart control in a TabControl. The first time I go to the tab with the RadChart everything is fine, but when I go to a different tab after that and then try to navigate back to the tab with the RadChart I get an error.

SCRIPT5022: Unhandled Error in Silverlight Application
Code: 2531
Category: ParserError
Message: Failed to assign to property 'System.Windows.Shapes.Path.Data'.
File:
Line: 83
Position: 31


The line that gets the error is:
Data="{TemplateBinding FigurePath2}"

Help please!

 

 

 

 

 

0
Evgenia
Telerik team
answered on 24 Aug 2011, 11:49 AM
Hi,

We haven't faced such issue up to now with the RadChart control. Can you send us a sample stripped down version of your project where this issue reproduces so that we can investigate it locally and get back to you with our findings. Also can you clarify the version of the binaries you are getting this error with?

Best wishes,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
n
Top achievements
Rank 1
answered on 24 Aug 2011, 08:54 PM
Sorry, it was an issue with something else. Everythings working great. Thanks for responding though!
Tags
Chart
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Evgenia
Telerik team
n
Top achievements
Rank 1
Share this question
or