Multiple YAxes not showing up

2 posts, 0 answers
  1. N Ahmed
    N Ahmed avatar
    1 posts
    Member since:
    Nov 2009

    Posted 11 Dec 2009 Link to this post

    Hi,

    I am having problems displaying multiple y axes on the Telerik RadChart.

    Basically I want the x axis to display my product name and two y axes representing number of transactions and total value (barchart)

    However both my sets of points are using the same Y axis

    Here is the code.Can anyone tell me what am i doing wrong.

    XAML

    <

     

    UserControl x:Class="Innovation_Navigation.ProductValueView"

     

     

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     

     

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     

     

    xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"

     

     

    xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"

     

     

    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls">

     

     

     

    <ScrollViewer>

     

     

     

    <Grid x:Name="LayoutRoot" Background="White">

     

     

     

    <Grid>

     

     

     

    <Grid.RowDefinitions>

     

     

     

    <RowDefinition Height="*"></RowDefinition>

     

     

     

    <RowDefinition Height="50"></RowDefinition>

     

     

     

    </Grid.RowDefinitions>

     

     

     

    <!-- Bar Chart-->

     

     

     

    <telerikChart:RadChart Grid.Row="0" UseDefaultLayout="True" telerik:StyleManager.Theme="Office_Black">

     

     

     

    <telerikCharting:ChartArea x:Name="ProductValueChart"

     

     

    HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Black"/>

     

     

     

    </telerikChart:RadChart>

     

     

     

    <Button Content="Main Page" Grid.Row="1" Height="30" Width="100" Click="Button_Click"></Button>

     

     

     

    </Grid>

     

     

     

    </Grid>

     

     

     

    </ScrollViewer>

     

    </

     

    UserControl>


    Code Behind


     

     

    internal void FillProductData()

     

    {

     

     

     

     

    ProductValueChart.DataSeries.Add(GenerateValueDataSeries(

    "Total Value per Product", "primary"));

     

    ProductValueChart.DataSeries.Add(GenerateCountDataSeries(

    "Transaction Count Per Product", "secondary", new BarSeriesDefinition()));

     

     

    }

     


     

     

     

    private DataSeries GenerateValueDataSeries(string legendLabel, string axisName)

     

    {

     

    DataSeries productValueSeries = new DataSeries();

     

     

    //productValueSeries.Definition = definition;

     

     

     

     

     

    productValueSeries.LegendLabel = legendLabel;

     

    //productValueSeries.Definition.AxisName = axisName;

     

     

     

     

     

     

     

    foreach (ProductTotalValue currProductValue in _productViewModel.productValueList)

     

    {

     

    DataPoint point = new DataPoint();

     

    point.XCategory = currProductValue.Name;

    point.YValue = currProductValue.TotalValue;

    productValueSeries.Add(point);

    }

     

    return productValueSeries;

     

    }

     

    private DataSeries GenerateCountDataSeries(string legendLabel, string axisName, ISeriesDefinition definition)

     

    {

     

    DataSeries productCountSeries = new DataSeries();

     

     

    //productCountSeries.Definition = definition;

     

     

     

     

     

    productCountSeries.LegendLabel = legendLabel;

     

    // productCountSeries.Definition.AxisName = axisName;

     

     

     

     

     

     

     

    foreach (ProductCount currProductCount in _productViewModel.productCountList)

     

    {

     

    DataPoint point = new DataPoint();

     

    point.XCategory = currProductCount.productName;

    point.YValue = currProductCount.transactionCount;

    productCountSeries.Add(point);

    }

     

    return productCountSeries;

     

    }

     

     

  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 15 Dec 2009 Link to this post

    Hi N Ahmed,

    You need to add an AxisY obejct to the AdditionalAxes collection of the ChartArea. You need to set the AxisName property of this axis, so that you can populate the SeriesDefinition.AxisName property with the same value. You can find an example here - Multiple Y Axis Support.


    Best regards,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top