Currently the only two chart types that have been tried which do not line up are OHLC and line.
I would post a snapshot if I could work out how via your forum.
4 Answers, 1 is accepted
You can align 2 charts horizontally by making their Y-axis the same size. One way of doing this is by applying a label style that sets the width of the labels to a predefined one. Here is some code:
<
Style
x:Key
=
"labelStyle"
TargetType
=
"TextBlock"
>
<
Setter
Property
=
"Width"
Value
=
"42"
/>
<
Setter
Property
=
"TextAlignment"
Value
=
"Right"
/>
<
Setter
Property
=
"Margin"
Value
=
"0,0,3,0"
/>
</
Style
>
Here is how you can apply it:
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
LabelStyle
=
"{StaticResource labelStyle}"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
I have attached a sample project that demonstrates this approach.All the best,
Yavor
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
var xaml = @"
<RadCartesianChart xmlns=""http://schemas.telerik.com/2008/xaml/presentation""> <RadCartesianChart.VerticalAxis> <LinearAxis LabelStyle=""{StaticResource labelStyle}"" /> </RadCartesianChart.VerticalAxis> </RadCartesianChart> "; var chart = System.Windows.Markup.XamlReader.Load(xaml) as RadCartesianChart; Any ideas on how I should configure the xmlns? It is saying that it doesn't understand the StaticResource
You need to add also these xaml namespaces:
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Here is how your definition should look like in order for the xaml parser to properly read it:
<
telerik:RadCartesianChart
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
/>
As I mentioned in my previous reply, in order for your horizontal axes align you have to be sure, that the vertical axes have the same ActualWidth. If everything else is the same (ticks length, axis thickness, title), then the only thing different are the labels. Setting a label style that gives them a constant width will make both of the vertical axes the same size.
I have attached a modified version of my previous test app that shows a line and OHLC series that have aligned horizontal axes.
Yavor
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.