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

aligning categorical style over more than one series

4 Answers 44 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 21 Sep 2012, 12:39 PM
Is there a sensible way to align the category that a series is plotted against for charts that are kept inside a StackPanel?

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

Sort by
0
Yavor
Telerik team
answered on 26 Sep 2012, 10:50 AM
Hello Steven,

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.

0
Steven
Top achievements
Rank 1
answered on 27 Sep 2012, 02:57 PM
That example you posted works.  I was attempting to do this afterwards:

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
0
Steven
Top achievements
Rank 1
answered on 27 Sep 2012, 11:35 PM
thanks for your example.  I integrated these ideas into my code, and I still can't get the categories to line up.  i.e. one chart has open high low close, the other has a simple line plot.  It just doesn't line up.

0
Yavor
Telerik team
answered on 02 Oct 2012, 09:03 AM
Hi Steven,

You need to add also these xaml namespaces:


Here is how your definition should look like in order for the xaml parser to properly read it:
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                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.

Greetings,
Yavor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Steven
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Steven
Top achievements
Rank 1
Share this question
or