Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Legend doesn't add Series
posted

I use the sample project too test my implementation with the XamDataChart. 

Unfortunately the Legend appears, but there no Items shown. 

<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Module1.Views"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:ig="http://schemas.infragistics.com/xaml"
             xmlns:sapmleData="clr-namespace:HAWO.SapmleData;assembly=HAWO.SapmleData"
             xmlns:viewModels="clr-namespace:Module1.ViewModels"
             x:Class="Module1.Views.ViewA"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
              
             prism:ViewModelLocator.AutoWireViewModel="True" >
    <Grid>
        <ig:XamDataChart x:Name="Chart" Legend="{Binding ElementName=ItemLegend}">
            <ig:XamDataChart.Resources>
                <sapmleData:EnergyDataSource x:Key="data" />
            </ig:XamDataChart.Resources>
            <ig:XamDataChart.Axes>
                <ig:NumericYAxis x:Name="YAxis"  />
                <ig:CategoryXAxis x:Name="XAxis" ItemsSource="{StaticResource data}"
                                  Label="{}{Country}"
                                  />
            </ig:XamDataChart.Axes>
            <ig:XamDataChart.Series>
                <ig:LineSeries ItemsSource="{StaticResource data}" ValueMemberPath="Coal" Title="Coal"
                               XAxis="{Binding ElementName=XAxis}"
                               YAxis="{Binding ElementName=YAxis}">
                </ig:LineSeries>
                <ig:LineSeries ItemsSource="{StaticResource data}" ValueMemberPath="Hydro" Title="Hydro"
                               XAxis="{Binding ElementName=XAxis}"
                               YAxis="{Binding ElementName=YAxis}">
                </ig:LineSeries>
                <ig:LineSeries ItemsSource="{StaticResource data}" ValueMemberPath="Nuclear" Title="Nuclear"
                               XAxis="{Binding ElementName=XAxis}"
                               YAxis="{Binding ElementName=YAxis}">
                </ig:LineSeries>
                <ig:LineSeries ItemsSource="{StaticResource data}" ValueMemberPath="Gas" Title="Gas"
                               XAxis="{Binding ElementName=XAxis}"
                               YAxis="{Binding ElementName=YAxis}">
                </ig:LineSeries>
                <ig:LineSeries ItemsSource="{StaticResource data}" ValueMemberPath="Oil"  Title="Oil"
                               XAxis="{Binding ElementName=XAxis}"
                               YAxis="{Binding ElementName=YAxis}">
                </ig:LineSeries>
            </ig:XamDataChart.Series>
        </ig:XamDataChart >
        <ig:ItemLegend x:Name="ItemLegend" Content="content" Margin="0,10,40,0" Height="64"/>
    </Grid>
</UserControl>

I guess this should work without code behind. 

Best Nic,

Parents
No Data
Reply
  • 34830
    Verified Answer
    Offline posted

    Hello Nic,

    It appears that you are attempting to use an ItemLegend element in this case. This is the wrong type of legend for the LineSeries series type, as ItemLegend is generally used for the XamPieChart, XamDoughnutChart, and I believe the BubbleSeries for the XamDataChart as that behaves a bit differently than other series.

    I would recommend using the Legend element, as this should display your series when used.

    Please let me know if you have any other questions or concerns on this matter.

Children