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

[Solved] Problem with YValue in ItemMapping

2 Answers 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric
Top achievements
Rank 1
Eric asked on 06 Aug 2011, 07:04 AM
Hi everyone,

I'm trying to dynamically databind to series information that I will be receiving from an outside source.

I have a RadTimeBar using sparklines which, when an interval is selected, will display the subset of data in a RadChart (LineSeriesDefinition).  The X-Axis is DateTime, and the Y-Axis is a double.

Almost everything works, except that when I click on an interval in the RadTimeBar, the series appears in the RadChart, the dates are correctly displayed, and the labels on each point display the correct value, but the points themselves are all visually settled at 0.  It is basically a straight line on the bottom of the chart with labels that have the correct values.

It is also important to note that the Sparklines displayed in the RadTimeBar are being shown properly.  Only the RadChart is displaying the data in a horizontal line.

Here is my XAML, and I populate the series information in the code-behind.  Please let me know if there is something I'm missing:

<UserControl x:Class="SiteDataChart.MainPage"
    xmlns:me="clr-namespace:SiteDataChart"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <me:DataOverTime x:Key="ViewModel" x:Name="viewModel" />
  
        <Style x:Key="TransitionControlStyle" TargetType="telerik:RadTransitionControl">
            <Setter Property="Transition">
                <Setter.Value>
                    <telerik:FadeTransition />
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
          
        <Button Content="Refresh" Click="Button_Click" Height="20" VerticalAlignment="Top" />
          
        <telerik:RadTimeBar x:Name="DataTimeBar" Grid.Row="0" Margin="0,20,0,0"
                            PeriodStart="{Binding Path=StartDate, Mode=TwoWay}"
                            PeriodEnd="{Binding Path=EndDate, Mode=TwoWay}"
                            VisiblePeriodStart="{Binding Path=VisibleStartDate, Mode=TwoWay}"
                            VisiblePeriodEnd="{Binding Path=VisibleEndDate, Mode=TwoWay}"
                            IsSnapToIntervalEnabled="True">
            <telerik:RadTimeBar.Intervals>
                <telerik:WeekInterval />
                <telerik:DayInterval />
                <telerik:HourInterval />
            </telerik:RadTimeBar.Intervals>
            <telerik:RadLinearSparkline ItemsSource="{Binding Path=DataPoints}"  
                                        XValuePath="TimeStamp" YValuePath="Value" />
        </telerik:RadTimeBar>
  
        <telerik:RadChart Grid.Row="1" x:Name="Chart">
            <telerik:RadChart.TimeBar>
                <Binding ElementName="DataTimeBar" />
            </telerik:RadChart.TimeBar>
            <telerik:RadChart.ItemsSource>
                <Binding Path="DataPoints" />
            </telerik:RadChart.ItemsSource>
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping LegendLabel="{Binding Path=UnitLabel}" >
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:LineSeriesDefinition />
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping FieldName="TimeStamp" DataPointMember="XCategory" />
                        <telerik:ItemMapping FieldName="Value" DataPointMember="YValue" />
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
              
            <telerik:RadChart.DefaultView>
                <telerik:ChartDefaultView>
                    <telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartLegend x:Name="legend" Header="Legend" />
                    </telerik:ChartDefaultView.ChartLegend>
                    <telerik:ChartDefaultView.ChartTitle>
                        <telerik:ChartTitle Content="Selected Data Points" />
                    </telerik:ChartDefaultView.ChartTitle>
                    <telerik:ChartDefaultView.ChartArea>
                        <telerik:ChartArea LegendName="legend"
                                           EnableAnimations="False"
                                           EnableTransitionAnimations="True"
                                           TransitionControlStyle="{StaticResource TransitionControlStyle}">
                            <telerik:ChartArea.AxisX>
                                <telerik:AxisX AxisName="Time" IsDateTime="True" LabelStep="6" />
                            </telerik:ChartArea.AxisX>
                            <telerik:ChartArea.AxisY>
                                <telerik:AxisY AxisName="{Binding Path=UnitLabel}" />
                            </telerik:ChartArea.AxisY>
                        </telerik:ChartArea>
                    </telerik:ChartDefaultView.ChartArea>
                </telerik:ChartDefaultView>
            </telerik:RadChart.DefaultView>
        </telerik:RadChart>
    </Grid>
</UserControl>

I want the series being shown in the RadChart to appear like the sparklines in the RadTimeBar, changing their vertical position as they should be doing (according to any example I've seen when using the RadChart in conjunction with the RadTimeBar)

Any help would be appreciated.  Thanks!

2 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 06 Aug 2011, 07:45 PM
Further information: I am using the 2011 Q1 SP1 release of the telerik controls.

As I mentioned, everything databinds correctly - I am seeing correct values and dates, but the Y values are not actually being plotted as a graph, just a straight line with the values as labels.  This behavior occurs with all of the different types of series definitions, not just the LineSeriesDefinition.

I would update to the latest version, but there is an issue in a different project of mine that throws an error when I try to open a RadWindow.  So, I am stuck using 2011 Q1 SP1 for now.

Thank you for any help on this matter!
~Eric

(Will attach files for the project later when I am able to unbind it from source control)
0
Eric
Top achievements
Rank 1
answered on 06 Aug 2011, 08:29 PM
No need to attach files.  I fixed it.

In my XAML above, I was using "AxisName" to try to label the axis.  Using "Title" instead of "AxisName" fixed the issue.

~Eric
Tags
Chart
Asked by
Eric
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Share this question
or