This question is locked. New answers and comments are not allowed.
Hello!
I am displaying a legend at the top of a chart. Unfortunately I don't have that much space for displaying the chart so I want it to be as small as possible. Everything is working well, except the fact that the legend has to much space reserved at the top and at the botton. How can I remove the space here? There should be zero pixels above and zero pixels below the chart legend. That would be great! Any ideas? Thanks a lot, Tim.
I am displaying a legend at the top of a chart. Unfortunately I don't have that much space for displaying the chart so I want it to be as small as possible. Everything is working well, except the fact that the legend has to much space reserved at the top and at the botton. How can I remove the space here? There should be zero pixels above and zero pixels below the chart legend. That would be great! Any ideas? Thanks a lot, Tim.
5 Answers, 1 is accepted
0
Tim
Top achievements
Rank 1
answered on 15 Mar 2012, 07:44 PM
Currently I am using this style:
<
telerik:RadChart.LegendStyle
>
<
Style
TargetType
=
"telerik:ChartLegend"
>
<
Setter
Property
=
"ItemsPanel"
>
<
Setter.Value
>
<
ItemsPanelTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
HorizontalAlignment
=
"Right"
/>
</
ItemsPanelTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
telerik:RadChart.LegendStyle
>
0
Hello Tim,
Please try to set the chart legend's margin and padding to be 0:
and remove the chart legend's header:
I hope that this will help.
Kind regards,
Sia
the Telerik team
Please try to set the chart legend's margin and padding to be 0:
Chart.DefaultView.ChartLegend.Margin =
new
Thickness(0);
Chart.DefaultView.ChartLegend.Padding =
new
Thickness(0);
and remove the chart legend's header:
Chart.DefaultView.ChartLegend.Header =
""
;
I hope that this will help.
Kind regards,
Sia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tim
Top achievements
Rank 1
answered on 20 Mar 2012, 10:13 AM
Hi Sia,
thanks a lot for your reply. Header was already set to "", setting margin and padding did not change anything - don't know why but I also added the following:
There is still a little space but I think I will leave it this way...
Thanks again! All the best,
Tim.
thanks a lot for your reply. Header was already set to "", setting margin and padding did not change anything - don't know why but I also added the following:
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:ChartLegend"
> <
Border
Background
=
"{TemplateBinding Background}"
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
<
Grid
Margin
=
"0"
> <
ItemsPresenter
/> </
Grid
> </
Border
> </
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
There is still a little space but I think I will leave it this way...
Thanks again! All the best,
Tim.
0
Accepted
Hello Tim,
Actually the default template is as follows:
You can see that the Margin that you set to be 0 is template-binded to the Padding property of the control. That is why I said that you need to set the Padding to be 0. Such setting should have the same effect.
Nevertheless we are happy to hear that you managed to resolve your issue.
All the best,
Sia
the Telerik team
Actually the default template is as follows:
<
ControlTemplate
TargetType
=
"telerikCharting:ChartLegend"
>
<
Border
Background
=
"{TemplateBinding Background}"
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
<
Grid
Margin
=
"{TemplateBinding Padding}"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
ContentControl
Foreground
=
"{TemplateBinding Foreground}"
HorizontalAlignment
=
"Stretch"
HorizontalContentAlignment
=
"Stretch"
FontWeight
=
"{TemplateBinding HeaderFontWeight}"
Content
=
"{TemplateBinding Header}"
ContentTemplate
=
"{TemplateBinding HeaderTemplate}"
/>
<
ItemsPresenter
Grid.Row
=
"1"
HorizontalAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment
=
"{TemplateBinding VerticalContentAlignment}"
/>
</
Grid
>
</
Border
>
</
ControlTemplate
>
You can see that the Margin that you set to be 0 is template-binded to the Padding property of the control. That is why I said that you need to set the Padding to be 0. Such setting should have the same effect.
Nevertheless we are happy to hear that you managed to resolve your issue.
All the best,
Sia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Tim
Top achievements
Rank 1
answered on 23 Mar 2012, 09:00 AM
Hello Sia,
thanks for your input and clarifying!
All the best,
Tim.
thanks for your input and clarifying!
All the best,
Tim.