Coloring the Legend Items

6 posts, 1 answers
  1. GPJ
    GPJ avatar
    31 posts
    Member since:
    Oct 2008

    Posted 30 Apr 2009 Link to this post

    I followed the instructions in another forum post for changing the colors of my pie chart and that worked fine, but the legend colors continued to show the original theme colours.

     

     

    My XAML inside the grid resources (I only set the first two colors).

     

     
                <SolidColorBrush x:Key="RadialItemStroke" Color="#FF000000"/>  
     
                <telerikStyling:StylesPalette x:Key="{telerikStyling:ThemeResourceKey   
                        ThemeType={x:Type telerikStyling:Office_BlackTheme},   
                        ElementType={x:Type telerikStyling:ChartArea},   
                        ResourceId={x:Static telerikStyling:ResourceHelper.ResourceKeyRadialStyle}}"> 
                    <Style TargetType="{x:Type Shape}">  
                        <Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" /> 
                        <Setter Property="StrokeThickness" Value="2" /> 
                        <Setter Property="Fill" Value="{StaticResource WidgetLightGreen}" /> 
                    </Style> 
                    <Style TargetType="{x:Type Shape}">  
                        <Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" /> 
                        <Setter Property="StrokeThickness" Value="2" /> 
                        <Setter Property="Fill" Value="{StaticResource WidgetOrange}" /> 
                    </Style> 
                </telerikStyling:StylesPalette> 

    My chart.
                <telerik:RadChart x:Name="ProgressChart"   
                                  Margin="4,8,4,4" 
                                  VerticalAlignment="Stretch"   
                                  HorizontalAlignment="Stretch">  
                    <telerik:RadChart.Background> 
                        <SolidColorBrush Color="Transparent"/>  
                    </telerik:RadChart.Background> 
                </telerik:RadChart> 
     

    Nothing fancy, but the legend doesn't color correctly.  I saw another post that mentionned the data series naming & legend items naming have been decoupled in the latest release - so I am assuming that also the colors were seperated as well, but I can't figure out how to change them.

    Greg

  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 04 May 2009 Link to this post

    Hello Greg Peter Joyal,

    I am afraid this seems to be a bug in the control. I have notified our developers of it, so they will provide a fix. Please, accept our apologies for the inconvenience caused. Your Telerik points have been updated.

    Sincerely,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ryan Overton
    Ryan Overton avatar
    12 posts
    Member since:
    Oct 2009

    Posted 01 Oct 2009 Link to this post

    Is there any news on this issue? Has it been fixed?

    I am working with a RadChart line series and have been able to add my own custom legend items, but they are all white. I would like to have them the same color as the lines being produced. Any help would be much appreciated.

    Thank you,
    Ryan
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 05 Oct 2009 Link to this post

    Hello Ryan,

    RadChart will provide the correct colors for the auto-generated legend items.  You will have to provide the style for the custom items by yourself. You can find an example here. You may need to add a value for the Background property of ChartLegendItem.

    Sincerely,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 30 Mar 2010 Link to this post

    Hi,

    Is it possible to bind a color to the value of the Property? The color has to come from my database...
    For the Piechart I was able to bind a color to each segment of the pie.
       <RadialGradientBrush x:Key="DoughnutMaskBrush" GradientOrigin="0.5,0.5">  
                    <GradientStop Color="#33FFFFFF" Offset="0.88"/>  
                    <GradientStop Color="#00FFFFFF" Offset="0.66"/>  
                    <GradientStop Color="#19FFFFFF" Offset="0.47"/>  
                    <GradientStop Offset="0.46"/>  
                    <GradientStop Offset="0.89"/>  
                </RadialGradientBrush> 
     
                <Style x:Key="CustomStyle" TargetType="Telerik_Windows_Controls_Charting:Doughnut">  
                    <Setter Property="Template" > 
                        <Setter.Value> 
                            <ControlTemplate TargetType="Telerik_Windows_Controls_Charting:Doughnut">  
                                <Canvas> 
                                    <Ellipse Clip="{TemplateBinding FigurePath}"   
                                             Width="{TemplateBinding ItemActualWidth}" 
                                             Height="{TemplateBinding ItemActualHeight}" 
                                             StrokeThickness="0" 
                                             Fill="{Binding DataItem.Kleur}" /> 
                                    <Path x:Name="PART_DefiningGeometry"   
                                          Data="{TemplateBinding FigurePath2}" 
                                          Fill="Transparent" 
                                          Style="{TemplateBinding ItemStyle}" /> 
                                    <Ellipse Clip="{TemplateBinding FigurePath3}"   
                                             Fill="{StaticResource DoughnutMaskBrush}"   
                                             Width="{TemplateBinding ItemActualWidth}" 
                                             Height="{TemplateBinding ItemActualHeight}"/>  
                                    <Canvas.RenderTransform> 
                                        <ScaleTransform x:Name="PART_AnimationTransform" ScaleX="0" ScaleY="0" /> 
                                    </Canvas.RenderTransform> 
                                </Canvas> 
                            </ControlTemplate> 
                        </Setter.Value> 
                    </Setter> 
                </Style> 
     PieChart1.DefaultSeriesDefinition = new DoughnutSeriesDefinition()  
                    {  
                        ShowItemToolTips = true,  
                        ShowItemLabels = false,  
                        ItemToolTipFormat = "#Naam : #Percentage%",  
                        ItemStyle = (this.LayoutRoot.Resources["CustomStyle"] as Style)  
                    }; 
     
    Now I'm trying to do the same for the legenditems
    When adding a color to the value it works fine
    PieChart1.DefaultView.ChartLegend.LegendItemStyle = new Style() { TargetType = typeof(ChartLegendItem) };  
                    PieChart1.DefaultView.ChartLegend.LegendItemStyle.Setters.Add(new Setter() { Property = Control.BackgroundProperty, Value = new SolidColorBrush(Colors.Cyan) }); 
    But when i try to bind a color to the value, nothing happens and the application goes in error.
    PieChart1.DefaultView.ChartLegend.LegendItemStyle = new Style() { TargetType = typeof(ChartLegendItem) };  
    PieChart1.DefaultView.ChartLegend.LegendItemStyle.Setters.Add(new Setter() { Property = Control.BackgroundProperty, Value = "{Binding DataItem.Kleur}" }); 

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
    Timestamp: Tue, 30 Mar 2010 12:09:51 UTC

    Message: Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
       at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
       at System.Windows.FrameworkElement.set_Style(Style value)
       at Telerik.Windows.Controls.Charting.ChartLegend.PrepareContainerForItemOverride(DependencyObject element, Object item)
       at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
       at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
       at System.Windows.Controls.ItemsControl.AddVisualChild(Int32 index, DependencyObject container, Boolean needPrepareContainer)
       at System.Windows.Controls.ItemsControl.AddContainers()
       at System.Windows.Controls.ItemsControl.RecreateVisualChildren(IntPtr unmanagedObj)    

    Line: 56
    Char: 13
    Code: 0
    URI: http://localhost:52677/pieclickeventTestPage.aspx

    Any help here?

    Kind regards,

    Gertjan

  7. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 02 Apr 2010 Link to this post

    Hi Grtjn,

    I can see this question has been answered in another forum thread and it seems it fits your needs.

    Kind regards,
    Ves
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WPF is Visual Studio 2017 Ready