This question is locked. New answers and comments are not allowed.
Hi,
I would like to use RadChart to show a series of stacked bars (based on time as XCategory). as shown in the attachment 'MockUpChart'.
The Xaml I have is below. This creates the four series definitions and hooks up the YValue and XCategory elements. However, I am not sure how to hook up the series to the underlying data in the binding. The underlying data has the following structure:-
RiskID: the primary key
Period: a String in the format YYYY-MM (XCategory)
Category: The series (i.e. there are four categories in the data and therefore four series defined below)
DriverScore: The value of the category for the period (YValue)
How do I hook up the Category field to the series so that the chart uses the values provided by the datasource?
When I generate the chart (see attachment 'CurrentChart') the values in the bars seems to repeat for each category and the two periods report the same values where the correct values can be seen in the attachment 'dataset'.
What am I doing wrong?
Regards,
Alan
<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="StackedBarControl.StackedBarChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="700">
<Grid x:Name="LayoutRoot" Background="White">
<telerik:RadChart x:Name="radChart" Height="400" Width="700" VerticalAlignment="Top"
ItemsSource="{Binding Screen.qryDriverScoreLast12Periods}">
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView ChartLegendPosition="Bottom">
<telerik:ChartDefaultView.ChartLegend>
<telerik:ChartLegend x:Name="chartLegend" Header="Risk Type" UseAutoGeneratedItems="False"/>
</telerik:ChartDefaultView.ChartLegend>
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea LegendName="chartLegend">
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
<telerik:RadChart.SeriesMappings>
<!--Series 0 - Financial Risk-->
<!--=========================-->
<telerik:SeriesMapping LegendLabel="Financial">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 1 - Strategic Risk-->
<!--=========================-->
<telerik:SeriesMapping LegendLabel="Strategic">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 2 - Operational Risk-->
<!--===========================-->
<telerik:SeriesMapping LegendLabel="Operational">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 3 - Hazard Risk-->
<!--===========================-->
<telerik:SeriesMapping LegendLabel="Hazard">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>
</telerik:RadChart>
</Grid>
</UserControl>
I would like to use RadChart to show a series of stacked bars (based on time as XCategory). as shown in the attachment 'MockUpChart'.
The Xaml I have is below. This creates the four series definitions and hooks up the YValue and XCategory elements. However, I am not sure how to hook up the series to the underlying data in the binding. The underlying data has the following structure:-
RiskID: the primary key
Period: a String in the format YYYY-MM (XCategory)
Category: The series (i.e. there are four categories in the data and therefore four series defined below)
DriverScore: The value of the category for the period (YValue)
How do I hook up the Category field to the series so that the chart uses the values provided by the datasource?
When I generate the chart (see attachment 'CurrentChart') the values in the bars seems to repeat for each category and the two periods report the same values where the correct values can be seen in the attachment 'dataset'.
What am I doing wrong?
Regards,
Alan
<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="StackedBarControl.StackedBarChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="700">
<Grid x:Name="LayoutRoot" Background="White">
<telerik:RadChart x:Name="radChart" Height="400" Width="700" VerticalAlignment="Top"
ItemsSource="{Binding Screen.qryDriverScoreLast12Periods}">
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView ChartLegendPosition="Bottom">
<telerik:ChartDefaultView.ChartLegend>
<telerik:ChartLegend x:Name="chartLegend" Header="Risk Type" UseAutoGeneratedItems="False"/>
</telerik:ChartDefaultView.ChartLegend>
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea LegendName="chartLegend">
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
<telerik:RadChart.SeriesMappings>
<!--Series 0 - Financial Risk-->
<!--=========================-->
<telerik:SeriesMapping LegendLabel="Financial">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 1 - Strategic Risk-->
<!--=========================-->
<telerik:SeriesMapping LegendLabel="Strategic">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 2 - Operational Risk-->
<!--===========================-->
<telerik:SeriesMapping LegendLabel="Operational">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
<!--Series 3 - Hazard Risk-->
<!--===========================-->
<telerik:SeriesMapping LegendLabel="Hazard">
<telerik:SeriesMapping.SeriesDefinition>
<telerik:StackedBarSeriesDefinition ShowItemLabels="False" ShowItemToolTips="False"></telerik:StackedBarSeriesDefinition>
</telerik:SeriesMapping.SeriesDefinition>
<telerik:ItemMapping DataPointMember="YValue" FieldName="DriverScore"></telerik:ItemMapping>
<telerik:ItemMapping DataPointMember="XCategory" FieldName="Period"></telerik:ItemMapping>
</telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>
</telerik:RadChart>
</Grid>
</UserControl>