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

Label colors

9 Answers 130 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Grtjn
Top achievements
Rank 1
Grtjn asked on 14 Apr 2010, 09:26 AM
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 ?

9 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 14 Apr 2010, 10:34 AM
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.
0
Grtjn
Top achievements
Rank 1
answered on 14 Apr 2010, 10:48 AM
Thanks Freddie.
The style in the link did make the background transparent and now it looks much better!

kind regards,

Gertjan
0
Grtjn
Top achievements
Rank 1
answered on 15 Apr 2010, 08:21 AM
Hi,

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

Kind regards,

Gertjan
0
Giuseppe
Telerik team
answered on 15 Apr 2010, 08:32 AM
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.
0
Grtjn
Top achievements
Rank 1
answered on 15 Apr 2010, 08:42 AM
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
0
Giuseppe
Telerik team
answered on 15 Apr 2010, 09:11 AM
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.
0
Grtjn
Top achievements
Rank 1
answered on 15 Apr 2010, 10:35 AM
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

0
Siddhartha
Top achievements
Rank 1
answered on 07 Dec 2011, 10:59 PM
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!
0
Giuseppe
Telerik team
answered on 12 Dec 2011, 09:49 AM
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 >>

Tags
Chart
Asked by
Grtjn
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Grtjn
Top achievements
Rank 1
Siddhartha
Top achievements
Rank 1
Share this question
or