Label colors

10 posts, 1 answers
  1. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 14 Apr 2010 Link to this post

    Hi all,

    When using the Q1 2010 version the labels appear above my chart and have a background color.
    How can I change this backgroundcolor?
    I did change the bars and the legenditems, and now the only thing that does still have a different color are these labels.

    Any help ?
  2. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 14 Apr 2010 Link to this post

    Hello Grtjn,

    Generally, if you customize the bar color through the Appearance API like this:

    DataSeries series = new DataSeries();
    series.Definition = new BarSeriesDefinition();
    series.Definition.Appearance.Fill = new SolidColorBrush(Colors.LightGray);
     
    series.Add(new DataPoint(40));
    series.Add(new DataPoint(30));
    series.Add(new DataPoint(20));
    series.Add(new DataPoint(50));
     
    RadChart1.DefaultView.ChartArea.DataSeries.Add(series);

    Or through the PaletteBrushes API like this:

    RadChart1.PaletteBrushes.Add(new SolidColorBrush(Colors.LightGray));
     
    DataSeries series = new DataSeries();
    series.Definition = new BarSeriesDefinition();
    series.Add(new DataPoint(40));
    series.Add(new DataPoint(30));
    series.Add(new DataPoint(20));
    series.Add(new DataPoint(50));
     
    RadChart1.DefaultView.ChartArea.DataSeries.Add(series);

    You will get matching label background out-of-the-box (no additional coding necessary).

    However, if you would like to make the series item label background transparent, you can use the approach demonstrated in this example here to achieve the desired effect.

    Hope this helps.


    Regards,
    Freddie
    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.
  3. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 14 Apr 2010 Link to this post

    Thanks Freddie.
    The style in the link did make the background transparent and now it looks much better!

    kind regards,

    Gertjan
  4. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 15 Apr 2010 Link to this post

    Hi,

    I still have a question on this subject.
    Is it possible to set the labels inside the bars ?

    Kind regards,

    Gertjan
  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 15 Apr 2010 Link to this post

    Hi Grtjn,

    Yes, this is possible -- we would suggest you to review the SmartLabels example here (you need to set the BarSeriesDefinition.LabelSettings.LabelDisplayMode property to Inside).

    Hope this helps.


    Greetings,
    Freddie
    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.
  6. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 15 Apr 2010 Link to this post

    Hi,

    I can't find the option u gave me...
    I only get LabelSettings.Equals or LabelSettings.ReferenceEquals

    RadChart.DefaultSeriesDefinition = new BarSeriesDefinition()  
                    {  
                        ShowItemLabels = true,  
                        ShowItemToolTips = true,  
                        ItemStyle = this.LayoutRoot.Resources["BarStyle"] as Style,  
                        SeriesItemLabelStyle = this.LayoutRoot.Resources["CustomLabelStyle"] as Style,  
                          
                    }; 

    Any help?

    Regards,

    Gertjan
  7. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 15 Apr 2010 Link to this post

    Hi Grtjn,

    You cannot set a complex property value within an object initializer -- you should set it like this:

    BarSeriesDefinition seriesDefinition = new BarSeriesDefinition()
    {
       //...
    };
    seriesDefinition.LabelSettings.LabelDisplayMode = LabelDisplayMode.Inside;
    RadChart1.DefaultSeriesDefinition = seriesDefinition;



    Kind regards,
    Freddie
    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.
  8. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 15 Apr 2010 Link to this post

    Awesome Freddie, works perfect !

    Do you happen to have any help for this thread i started ?
    http://www.telerik.com/community/forums/silverlight/chart/splinearea-color.aspx

    When i run my project the chart gets drawn properly. Now i have a clickevent on the radgauge that redraws the linechart with different data, but the colors layout changes to default and it's even the same method i call just with other parameter...

    Kind regards,

    Gertjan

  9. Siddhartha
    Siddhartha avatar
    2 posts
    Member since:
    Dec 2011

    Posted 07 Dec 2011 Link to this post

    Hi,

    I tried using the concept from the given code.

     <Style x:Key="CustomStyle" TargetType="charting:Bar">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="charting:Bar">
                                <Canvas>
                                    <Rectangle x:Name="PART_DefiningGeometry" 
                                       Height="{TemplateBinding ItemActualHeight}"
                                       Width="{TemplateBinding ItemActualWidth}"
                                       Fill="{Binding DataItem.PopulationColor}" />
                                    <Canvas.RenderTransform>
                                        <ScaleTransform x:Name="PART_AnimationTransform" ScaleY="0" />
                                    </Canvas.RenderTransform>
                                </Canvas>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>


    and called it in the following code:


    <chart:RadChart x:Name="chartCarDwell" Grid.Column="0" Grid.Row="1" telerik:StyleManager.Theme="Transparent" Margin="0, 25, 0, 0">
                <chart:RadChart.PaletteBrushes>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FF367fb6" Offset="0" />
                        <GradientStop Color="#FF095791" Offset="1" />
                    </LinearGradientBrush>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FFa11616" Offset="0" />
                            <!--<GradientStop Color="Crimson" Offset="0" />-->
                            <GradientStop Color="#FF720000" Offset="1" />
                    </LinearGradientBrush>
                </chart:RadChart.PaletteBrushes>
                <chart:RadChart.SeriesMappings>
                    <charting:SeriesMapping LegendLabel="Car Dwell">
                        <charting:SeriesMapping.SeriesDefinition>
                                <charting:BarSeriesDefinition ShowItemLabels="True" ShowItemToolTips="True" ItemStyle="{StaticResource CustomStyle}">
                                    <charting:BarSeriesDefinition.LabelSettings>
                                        <charting:BarLabelSettings LabelDisplayMode="MidPoint" Distance="0" />
                                    </charting:BarSeriesDefinition.LabelSettings>


                                </charting:BarSeriesDefinition> 
                        </charting:SeriesMapping.SeriesDefinition>
                        <charting:ItemMapping DataPointMember="YValue" FieldName="AverageDwell"  />
                        <charting:ItemMapping DataPointMember="XCategory" FieldName="ExtendedDay" />
                    </charting:SeriesMapping>
                </chart:RadChart.SeriesMappings>


                <chart:RadChart.DefaultView>
                    <charting:ChartDefaultView>
                        <charting:ChartDefaultView.ChartLegend>
                            <charting:ChartLegend Visibility="Collapsed" />
                        </charting:ChartDefaultView.ChartLegend>
                        <charting:ChartDefaultView.ChartArea>
                            <charting:ChartArea ItemClick="ChartArea_ItemClick"/>
                              


                            </charting:ChartDefaultView.ChartArea>
                        
                    </charting:ChartDefaultView>
                </chart:RadChart.DefaultView>
            </chart:RadChart>


    Still I am getting the default location of the seriesitemlabels within the blocks of color same as the bars.
    Please help me!
  10. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 12 Dec 2011 Link to this post

    Hi Siddhartha,

    We were unable to reproduce the problematic behavior in our local tests -- see the attached sample application that uses your code and works as expected.


    Greetings,
    Giuseppe
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top