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

Multiple YAxes not showing up

1 Answer 76 Views
Chart
This is a migrated thread and some comments may be shown as answers.
N Ahmed
Top achievements
Rank 1
N Ahmed asked on 11 Dec 2009, 06:10 PM
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;

 

}

 

 

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 15 Dec 2009, 07:12 AM
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.
Tags
Chart
Asked by
N Ahmed
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or