A value of type 'AreaSeries' cannot be added to a collection of dictionary of type presenter Collection '1'.

2 posts, 0 answers
  1. Ahmad
    Ahmad avatar
    3 posts
    Member since:
    Jan 2014

    Posted 06 Jan 2014 Link to this post

    Plz help me with this I have to use the AreaSeries inside CartesianChart along side with another charts but i cannot be cause of the error "A value of type 'AreaSeries' cannot be added to a collection of dictionary of type presenter Collection '1'."
    and here is my code:
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 x:Class="Concord.HIS.Dashboard.UserControls.LabTestOverallUserControl"
                 mc:Ignorable="d"
                 d:DesignHeight="800"
                 d:DesignWidth="900">
        <Grid>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <ListBox x:Name="TopTenLabTestsListBox"
                             ItemsSource="{Binding TopTenLabTests}"
                             ItemContainerStyle="{StaticResource ToptenListItem}" />
                    <telerik:RadChart MaxWidth="300"
                                      MaxHeight="200"
                                      ItemsSource="{Binding ClinicPieChartdata}"
                                      Margin="15 0 15 0">
                        <telerik:RadChart.SeriesMappings>
                            <telerik:SeriesMapping>
                                <telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:PieSeriesDefinition ItemLabelFormat="#%{p0}"
                                                                 ShowItemLabels="True" />
                                </telerik:SeriesMapping.SeriesDefinition>
                                <telerik:SeriesMapping.ItemMappings>
                                    <telerik:ItemMapping  DataPointMember="YValue"
                                                          FieldName="Count" />
                                    <telerik:ItemMapping  DataPointMember="LegendLabel"
                                                          FieldName="Lable" />
                                </telerik:SeriesMapping.ItemMappings>
                            </telerik:SeriesMapping>
                        </telerik:RadChart.SeriesMappings>
                    </telerik:RadChart>
                    <telerik:RadChart MaxWidth="300"
                                      MaxHeight="200"
                                      ItemsSource="{Binding ClinicPieChartdata}">
                        <telerik:RadChart.DefaultView>
                            <telerik:ChartDefaultView>
                                <telerik:ChartDefaultView.ChartLegend>
                                    <telerik:ChartLegend Width="0" />
                                </telerik:ChartDefaultView.ChartLegend>
                            </telerik:ChartDefaultView>
                        </telerik:RadChart.DefaultView>
                        <telerik:RadChart.SeriesMappings>
                            <telerik:SeriesMapping>
                                <telerik:SeriesMapping.ItemMappings>
                                    <telerik:ItemMapping  DataPointMember="YValue"
                                                          FieldName="Count" />
                                    <telerik:ItemMapping  DataPointMember="XValue"
                                                          FieldName="Lable" />
                                </telerik:SeriesMapping.ItemMappings>
                            </telerik:SeriesMapping>
                        </telerik:RadChart.SeriesMappings>
                    </telerik:RadChart>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0 5 0 0">
                    <StackPanel Width="{Binding ElementName=TopTenLabTestsListBox,Path=Width}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Width="175">
                                <TextBlock Text="Most used lab test:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.Name}" VerticalAlignment="Center" Margin="5 0 0 0"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Clinic ordered this test the most:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.ClinicName}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Doctor ordered this test the most:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.DoctorName}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Most orders in one day:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.MostOrderedInOneDay}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Most diagnosis this lab test was ordered for:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.MostDiagnosis}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Number of children who used this test:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.ChildrenNumber}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Number of children who used this test:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.ChildrenNumber}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"
                                    Margin="0 5 0 0">
                            <StackPanel Width="175">
                                <TextBlock Text="Lab test total orders:"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                            <TextBlock Text="{Binding MostUsedLabTest.TotalUsed}"
                                       VerticalAlignment="Center"
                                       Margin="5 0 0 0" />
                        </StackPanel>
                    </StackPanel>
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <telerik:RadChart MaxWidth="200"
                                              MaxHeight="200"
                                              ItemsSource="{Binding ClinicPieChartdata}"
                                              Margin="15 0 15 0">
                                <telerik:RadChart.SeriesMappings>
                                    <telerik:SeriesMapping>
                                        <telerik:SeriesMapping.SeriesDefinition>
                                            <telerik:PieSeriesDefinition ItemLabelFormat="#%{p0}"
                                                                         ShowItemLabels="True" />
                                        </telerik:SeriesMapping.SeriesDefinition>
                                        <telerik:SeriesMapping.ItemMappings>
                                            <telerik:ItemMapping  DataPointMember="YValue"
                                                                  FieldName="Count" />
                                            <telerik:ItemMapping  DataPointMember="LegendLabel"
                                                                  FieldName="Label" />
                                        </telerik:SeriesMapping.ItemMappings>
                                    </telerik:SeriesMapping>
                                </telerik:RadChart.SeriesMappings>
                            </telerik:RadChart>
                            <telerik:RadChart MaxWidth="200"
                                              MaxHeight="200"
                                              ItemsSource="{Binding ClinicPieChartdata}">
                                <telerik:RadChart.DefaultView>
                                    <telerik:ChartDefaultView>
                                        <telerik:ChartDefaultView.ChartLegend>
                                            <telerik:ChartLegend Width="0" />
                                        </telerik:ChartDefaultView.ChartLegend>
                                    </telerik:ChartDefaultView>
                                </telerik:RadChart.DefaultView>
                                <telerik:RadChart.SeriesMappings>
                                    <telerik:SeriesMapping>
                                        <telerik:SeriesMapping.ItemMappings>
                                            <telerik:ItemMapping  DataPointMember="YValue"
                                                                  FieldName="Count" />
                                            <telerik:ItemMapping  DataPointMember="XValue"
                                                                  FieldName="Label" />
                                        </telerik:SeriesMapping.ItemMappings>
                                    </telerik:SeriesMapping>
                                </telerik:RadChart.SeriesMappings>
                            </telerik:RadChart>
                            <telerik:RadChart MaxWidth="200"
                                              MaxHeight="200"
                                              ItemsSource="{Binding ClinicPieChartdata}"
                                              Margin="15 0 0 0">
                                <telerik:RadChart.SeriesMappings>
                                    <telerik:SeriesMapping>
                                        <telerik:SeriesMapping.SeriesDefinition>
                                            <telerik:PieSeriesDefinition ItemLabelFormat="#%{p0}"
                                                                         ShowItemLabels="True" />
                                        </telerik:SeriesMapping.SeriesDefinition>
                                        <telerik:SeriesMapping.ItemMappings>
                                            <telerik:ItemMapping  DataPointMember="YValue"
                                                                  FieldName="Count" />
                                            <telerik:ItemMapping  DataPointMember="LegendLabel"
                                                                  FieldName="Label" />
                                        </telerik:SeriesMapping.ItemMappings>
                                    </telerik:SeriesMapping>
                                </telerik:RadChart.SeriesMappings>
                            </telerik:RadChart>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="12,6,0,20">
                                <TextBlock>
                    <Run Text="Date:" FontFamily="Segoe UI" FontSize="12" />
                    <Run x:Name="date" Text="Mar 18, 2012" FontFamily="Segoe UI" FontSize="16" />
                                </TextBlock>
                                <TextBlock Margin="10,0,0,0">
                    <Run Text="Count:" FontFamily="Segoe UI" FontSize="12" />
                    <Run x:Name="count" Text="5,976,129" FontFamily="Segoe UI" FontSize="16"  />
                                </TextBlock>
                            </StackPanel>
                            <telerik:RadCartesianChart Grid.Row="1" Margin="10,0,10,30"
                                     TrackBallLineStyle="{StaticResource trackBallLineStyle}"
                                     TrackBallInfoStyle="{StaticResource trackBallInfoStyle}"
                                       x:Name="cChart"
                                       Background="AliceBlue">
                                <telerik:RadCartesianChart.Resources>
                                    <DataTemplate x:Key="PointTemplate">
                                        <Ellipse Height="8" Width="8" Stroke="White" StrokeThickness="1" Fill="#1B9DDE" />
                                    </DataTemplate>
                                    <Style x:Key="BorderStyle" TargetType="Border">
                                        <Setter Property="Background" Value="#1B9DDE" />
                                    </Style>
                                </telerik:RadCartesianChart.Resources>
                                <telerik:RadCartesianChart.Behaviors>
                                    <telerik:ChartTooltipBehavior Placement="Top" HorizontalOffset="-6" VerticalOffset="1" />
                                    <telerik:ChartPanAndZoomBehavior ZoomMode="Horizontal" />
                                    <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True" TrackInfoUpdated="ChartTrackBallBehavior_TrackInfoUpdated" />
                                    <telerik:ChartTooltipBehavior Placement="Top" HorizontalOffset="-6" VerticalOffset="1" />
                                </telerik:RadCartesianChart.Behaviors>
                                <telerik:AreaSeries x:Name="Chart"
                                    CategoryBinding="RigestirationDate"
                                    ValueBinding="Count"
                                    Fill="#2625A0DA"
                                    Stroke="#FF25A0DA"
                                    telerik:StyleManager.Theme="Windows8"
                                    StrokeThickness="2"
                                    TrackBallTemplate="{StaticResource trackBallTemplate}"
                                    Visibility="Visible">
                                    <telerik:AreaSeries.VerticalAxis>
                                        <telerik:LinearAxis >
                                        </telerik:LinearAxis>
                                    </telerik:AreaSeries.VerticalAxis>
                                </telerik:AreaSeries>
                                <telerik:RadCartesianChart.HorizontalAxis>
                                    <telerik:DateTimeCategoricalAxis DateTimeComponent="Ticks" PlotMode="OnTicks" MajorTickInterval="30"  LabelFormat="dd MM yyyy"
                                                       MajorTickStyle="{StaticResource tickStyle}" />
                                </telerik:RadCartesianChart.HorizontalAxis>
                                <telerik:RadCartesianChart.VerticalAxis>
                                    <telerik:LinearAxis />
                                </telerik:RadCartesianChart.VerticalAxis>
                                <telerik:RadCartesianChart.Grid>
                                    <telerik:CartesianChartGrid StripLinesVisibility="None" MajorLinesVisibility="XY">
                                        <telerik:CartesianChartGrid.YStripeBrushes>
                                            <SolidColorBrush Color="#FFD7D7D7" Opacity="0.3" />
                                            <SolidColorBrush Color="Transparent" />
                                        </telerik:CartesianChartGrid.YStripeBrushes>
                                    </telerik:CartesianChartGrid>
                                </telerik:RadCartesianChart.Grid>
                            </telerik:RadCartesianChart>
     
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </UserControl>
  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 08 Jan 2014 Link to this post

    Hi,

    This happens because you are using the old RadChart control along with the newer one RadChartView with the same schema. In order to fix this you should use the appropriate namespaces for both controls. You can see this for example in the following demo:
    http://demos.telerik.com/silverlight/#TimeBar/FirstLook

    xmlns:charting="clr-namespace:Telerik.Charting;assembly=Telerik.Windows.Controls.Chart"
    xmlns:chart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Chart"
    xmlns:chartView="clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart"

    Hope this helps.

    Regards,
    Peshito
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top