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

Custom smart labels

7 Answers 347 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 24 Apr 2014, 01:04 PM
I want to change color of smart label.

but I don't find example...

please help me...

7 Answers, 1 is accepted

Sort by
0
Klemens
Top achievements
Rank 1
answered on 24 Apr 2014, 01:40 PM
Hi,
Smart Labels

also in the Wpf examples:
ChartView -> SmartLabels

Regards Markus
0
Lee
Top achievements
Rank 1
answered on 25 Apr 2014, 12:00 AM
Thank you for reply.

This example is automatic form.

My 'RadCartesianChart' is created in 'Black Label Color'

I want to change this color.
0
Martin Ivanov
Telerik team
answered on 29 Apr 2014, 08:02 AM
Hello Lee,

Keep in mind that the smart labels are actually normal labels with a positioning strategy applied. The SmartLabels strategy is positioning the labels in such a way so they do not overlap one another. In order to customize the appearance of the labels of the chart's series you can define a LabelDefinition. Then you can change the color of the labels by setting the Foreground property of the element inside the template of the definition.
<telerik:LineSeries ShowLabels="True">
    <telerik:LineSeries.LabelDefinitions>
        <telerik:ChartSeriesLabelDefinition>
            <telerik:ChartSeriesLabelDefinition.Template>
                <DataTemplate>
                    <TextBlock Text="{Binding Value}" Foreground="White" />
                </DataTemplate>
            </telerik:ChartSeriesLabelDefinition.Template>
        </telerik:ChartSeriesLabelDefinition>
    </telerik:LineSeries.LabelDefinitions>
</telerik:LineSeries>

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Lee
Top achievements
Rank 1
answered on 29 Apr 2014, 10:38 AM
Thank you for your reply.

Additionally, I want to work in code-behind(Converter Class).

My converter is below that.

NumericalAxis verticalAxis = null;
LinearAxis axis = new LinearAxis();

axis.Foreground = new SolidColorBrush(Colors.White);
axis.FontSize = 11;

verticalAxis = axis;

return verticalAxis;
0
Martin Ivanov
Telerik team
answered on 30 Apr 2014, 02:49 PM
Hi Lee,

In order to set the color of the labels of the axis you can use the LabelStyle property of the axis. As for the changing of the foreground color of the series labels there is another approach slightly different than this I suggested in my last reply. Instead of defining template for the LabelDefinition you can set its DefaultVisualStyle property. You can use the following style (or similar) for both properties (LabelStyle and DefaultVisualStyle):

<Window.Resources>
    <Style x:Key="labelStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="Green" />
    </Style>
</Window.Resources>
To create a definition and set the styles in code-behind you can use the following code:

// Get the style
Style labelStyle = (Style)this.Resources["labelStyle"];
// Create new labelDefinition and set its DefaultVisualStyle property
ChartSeriesLabelDefinition labelDefinition = new ChartSeriesLabelDefinition() { DefaultVisualStyle = labelStyle };
 
// add the label definition in the LabelDefinitions collection of your series
myLineSeries.LabelDefinitions.Add(labelDefinition);
// set the style for the labels of the axis
axis.LabelStyle = labelStyle;

Please let me know if this information helps.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
karthikeyan
Top achievements
Rank 1
answered on 02 Mar 2017, 01:11 PM

Hi Lee,

        I want to add labelformat to vertical axis with display value as percentages can you help me out

Thanks,

Karthik

0
Martin Ivanov
Telerik team
answered on 06 Mar 2017, 11:24 AM
Hello Karthik,

You can try the LabelFormat or LabelTemplate properties of the axis. 

Regards,
Martin
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
Lee
Top achievements
Rank 1
Answers by
Klemens
Top achievements
Rank 1
Lee
Top achievements
Rank 1
Martin Ivanov
Telerik team
Lee
Top achievements
Rank 1
karthikeyan
Top achievements
Rank 1
Share this question
or