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

Overlapping labels and go off the screen

5 Answers 78 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Nikolay Velizhanin
Top achievements
Rank 1
Nikolay Velizhanin asked on 06 Dec 2010, 05:46 AM
Overlapping labels and go off the screen. How to fix this ?


ChrtbottomHole.DefaultView.ChartArea.EnableAnimations = false;
chrtbottomHole.DefaultView.ChartArea.EnableTransitionAnimations = true;
chrtbottomHole.DefaultView.ChartArea.SmartLabelsEnabled = true;

chrtbottomHole.DefaultView.ChartArea.AxisX.AutoRange = true;
chrtbottomHole.DefaultView.ChartArea.AxisX.Title = "Сутки";
chrtbottomHole.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;
chrtbottomHole.DefaultView.ChartArea.AxisX.LayoutMode =AxisLayoutMode.Between;
chrtbottomHole.DefaultView.ChartArea.AxisY.AutoRange = true;
chrtbottomHole.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible;
chrtbottomHole.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Visible;
chrtbottomHole.DefaultView.ChartArea.AxisY.Title = "Глубина скважины, м";
chrtbottomHole.DefaultView.ChartArea.AxisY.IsZeroBased = true;

// три строчки, чтобы значения шли вниз
chrtbottomHole.ItemDataBound += chrtbottomHole_ItemDataBound;

chrtbottomHole.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{##;##;0}";
chrtbottomHole.DefaultSeriesDefinition.ItemLabelFormat = "#Y{##;##;0}";



LineSeriesDefinition lineDefinition = new LineSeriesDefinition
{

ShowItemLabels = true,
ShowPointMarks = false,
LabelSettings = {ShowConnectors = true},
ShowItemToolTips = true,
ItemToolTipFormat = "Сутки-#X Глубина#Y"
};


SeriesMapping temperatureMapping = new SeriesMapping {SeriesDefinition = lineDefinition};
temperatureMapping.SeriesDefinition.SeriesItemLabelStyle = Resources["BarLabelStyle"] as Style;
temperatureMapping.SeriesDefinition.Appearance.Foreground = new SolidColorBrush(Colors.Black);

temperatureMapping.ItemMappings.Add(new ItemMapping("Argument", DataPointMember.Xvalue));


ItemMapping yItemMapping = new ItemMapping("Value", DataPointMember.Yvalue);

temperatureMapping.ItemMappings.Add(yItemMapping);
temperatureMapping.LegendLabel = "Фактический график строительства";
chrtbottomHole.SeriesMappings.Add(temperatureMapping);

5 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 09 Dec 2010, 08:19 AM
Hello Nikolay,

As I saw from your XAML snippet you are setting:
temperatureMapping.SeriesDefinition.SeriesItemLabelStyle = Resources["BarLabelStyle"] as Style;
Could you send us the Style (x:Key = "BarLabelStyle") that you are setting?

Also try what will happen if you change the Distance property of the Labelsettings as shown in our help topic - http://www.telerik.com/help/silverlight/radchart-features-smart-labels.html#Configure_the_Smart_Labels_feature.

Regards,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Nikolay Velizhanin
Top achievements
Rank 1
answered on 10 Dec 2010, 09:53 AM
<Style x:Key="BarLabelStyle" TargetType="telerik:SeriesItemLabel" >
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="telerik:SeriesItemLabel" >
<Canvas>
<Polyline x:Name="PART_Connector"
Points="{TemplateBinding ConnectorPoints}"
Visibility="{Binding Converter={StaticResource LabelVisibilityConverter1}}"
Style="{TemplateBinding ConnectorStyle}"
Stroke="{TemplateBinding Stroke}"
StrokeThickness="{TemplateBinding StrokeThickness}" />
<Border x:Name="PART_TextContainer"

Background="{TemplateBinding Background}"
BorderThickness="1"
BorderBrush="Black"
Visibility="{Binding Converter={StaticResource LabelVisibilityConverter1}}" >
<TextBlock
TextAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
Text="{Binding DataItem.WorkType}"
TextWrapping="Wrap" />
</Border>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
0
Evgenia
Telerik team
answered on 14 Dec 2010, 12:40 PM
Hi Nikolay,

Should I assume that the issue you were facing is now resolved as you have marked as answer my post?

Greetings,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Nikolay Velizhanin
Top achievements
Rank 1
answered on 14 Dec 2010, 12:43 PM
No. Issue is not resolved.
0
Evgenia
Telerik team
answered on 16 Dec 2010, 01:53 PM
Hello Nikolay ,

To be able to have clearer visualization of Smart Labels (without overlapping) try to position the Line Series as far as possible from the left-most and right-most sides of the ChartArea. You can achieve this by setting different range for the XAxis (different MinValue and MaxValue) and more specially set bigger Step for it . To do it turn off AutoRange property of the Axis.
Setting a bigger step for the XAxis will be very helpful as I saw that you have points that are with very close values. That causes their Labels to overlap. If you don't want to change the axis range then remove one of the labels for those points that are very close to one another.
I hope this suggestion helps.

Greetings,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Chart
Asked by
Nikolay Velizhanin
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Nikolay Velizhanin
Top achievements
Rank 1
Share this question
or