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

Inconsistent error using multiple datasources

2 Answers 64 Views
Chart
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 06 Jun 2011, 07:56 PM
I have a Chart using 3 domain datasources for loading data (displaying only one for demonstration)
<telerik:RadDomainDataSource AutoLoad="True" Height="0" Width="0"                                      
                                    x:Name="invoiceStatisticsDomainDataSource1" 
                                    QueryName="GetInvoiceStatisticsQuery"
                                    >
  <telerik:RadDomainDataSource.DomainContext>
    <my1:ExqiOfficeDomainContext />
  </telerik:RadDomainDataSource.DomainContext>
  <telerik:RadDomainDataSource.QueryParameters>
    <telerik:QueryParameter ParameterName="serviceId" Value="1"/>
    <telerik:QueryParameter ParameterName="months" Value="4"/>
  </telerik:RadDomainDataSource.QueryParameters>
</telerik:RadDomainDataSource>

I have made a chart based on the datasources:

<telerik:RadChart Grid.Row="1" Grid.Column="1">
  <telerik:RadChart.SeriesMappings>
    <telerik:SeriesMapping LegendLabel="title" ItemsSource="{Binding DataView, ElementName=invoiceStatisticsDomainDataSource1}">
      <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition StackGroupName="Description" ></telerik:StackedBarSeriesDefinition>
      </telerik:SeriesMapping.SeriesDefinition>
      <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Month" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="TotalAmount" ></telerik:ItemMapping>
      </telerik:SeriesMapping.ItemMappings>
    </telerik:SeriesMapping>
    <telerik:SeriesMapping LegendLabel="Test" ItemsSource="{Binding DataView, ElementName=invoiceStatisticsDomainDataSource2}">
      <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition StackGroupName="Description"></telerik:StackedBarSeriesDefinition>
      </telerik:SeriesMapping.SeriesDefinition>
      <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Month" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="TotalAmount"></telerik:ItemMapping>
      </telerik:SeriesMapping.ItemMappings>
    </telerik:SeriesMapping>
    <telerik:SeriesMapping LegendLabel="Free Invoices" ItemsSource="{Binding DataView, ElementName=invoiceStatisticsDomainDataSource3}">
      <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition StackGroupName="Description"></telerik:StackedBarSeriesDefinition>
      </telerik:SeriesMapping.SeriesDefinition>
      <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Month" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="TotalAmount"></telerik:ItemMapping>
      </telerik:SeriesMapping.ItemMappings>
    </telerik:SeriesMapping>
      
  </telerik:RadChart.SeriesMappings>
  <telerik:RadChart.DefaultView>
    <telerik:ChartDefaultView>
      <telerik:ChartDefaultView.ChartTitle>
        <telerik:ChartTitle Content="Invoiced Amount/Month"></telerik:ChartTitle>
      </telerik:ChartDefaultView.ChartTitle>
      <telerik:ChartDefaultView.ChartArea>
        <telerik:ChartArea LegendName="CustomLegend">
          <telerik:ChartArea.AxisX>
            <telerik:AxisX Title="Period" />
          </telerik:ChartArea.AxisX>
          <telerik:ChartArea.AxisY>
            <telerik:AxisY MajorGridLinesVisibility="Visible"
                                           MinorTicksVisibility="Visible"
                                           Title="Total Invoiced (EUR)"
                                           >
            </telerik:AxisY>
          </telerik:ChartArea.AxisY>
        </telerik:ChartArea>
      </telerik:ChartDefaultView.ChartArea>
      <telerik:ChartDefaultView.ChartLegend>
        <telerik:ChartLegend x:Name="CustomLegend" UseAutoGeneratedItems="True" BorderThickness="1,0,0,0" />
      </telerik:ChartDefaultView.ChartLegend>
    </telerik:ChartDefaultView>
  </telerik:RadChart.DefaultView>
</telerik:RadChart>

Sometimes i can run this chart without any problem, but from time to time (more often then not) i get following error (code breaks in XAML page on the UserControl tag)

System.Reflection.TargetInvocationException was unhandled by user code
  Message=[Arg_TargetInvocationException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.60401.00&File=mscorlib.dll&Key=Arg_TargetInvocationException
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at DashboardViewxaml.BindingOperation_66_74(Object BindingState, Action )
  InnerException: System.NullReferenceException
       Message=[Arg_NullReferenceException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.60401.00&File=mscorlib.dll&Key=Arg_NullReferenceException
       StackTrace:
            at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMapping(SeriesMapping seriesMapping, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState)
            at Telerik.Windows.Controls.Charting.DataBindingHelper.ProcessMappings(SeriesMappingCollection seriesMappings, QueryableCollectionView dataEngine, Int32 samplingThreshold, ZoomScrollSettings zoomScrollSettings, ISeriesDefinition defaultSeriesDefinition, AxisRangeState axisXRangeState)
            at Telerik.Windows.Controls.Charting.DataBindingHelper.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ISeriesDefinition defaultSeriesDefinition, ChartFilterDescriptorCollection globalFilterDescriptors, ChartSortDescriptorCollection globalSortDescriptors, SamplingSettings samplingSettings, ZoomScrollSettings zoomScrollSettings, AxisRangeState axisXRangeState)
            at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData, SeriesMappingCollection seriesMappings, ChartArea chartArea)
            at Telerik.Windows.Controls.RadChart.GenerateDataSeries(Object originalData)
            at Telerik.Windows.Controls.RadChart.Rebind(Object originalData)
            at Telerik.Windows.Controls.RadChart.Rebind()
            at Telerik.Windows.Controls.Charting.SeriesMapping.RebindChart()
            at Telerik.Windows.Controls.Charting.SeriesMapping.ManageChangeNotifications(Object originalData, Object oldData)
            at Telerik.Windows.Controls.Charting.SeriesMapping.ItemsSourcePropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
            at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
            at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
            at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
            at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
            at System.Windows.Data.BindingExpression.SendDataToTarget()
            at System.Windows.Data.BindingExpression.SourceAcquired()
            at System.Windows.Data.BindingExpression.PerformTargetLoaded()
            at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass1.<BreakOnSingleType>b__0()
       InnerException:

I can't make heads not tails about this

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 09 Jun 2011, 10:15 AM
Hi peter,

We have tested your scenario in our environment using 3 DomainDataSources pointing to the same RIA service. The test system makes a new call to the RIA service for data every 15 seconds, but unfortunately we couldn't reproduce the mentioned error. I have attached the test project so that you can test it in your environment.

If the problem persists please open a support ticket and attach your project so that we can investigate it and advice you how to proceed.

Kind regards,
Yavor Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
HDC
Top achievements
Rank 1
answered on 09 Jun 2011, 06:27 PM
Thanks a lot for taking the time to send a sample. I appreciate it.

I can't run the sample because i get an incompatibility exception with the version of the database but when i launch the code, i don't immediately get an error. The only difference i see is the fact that your code uses a timer to load the data. Is this is a requirement?

Meanwhile, i have decided to use a different approach to the same problem, using a single datasource and filterdescriptions i was able to solve my problem just today.

For those interested here is my code:

<telerik:RadChart x:Name="InvoiceChart" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding DataView, ElementName=invoiceStatisticsDomainDataSource1}">
  <telerik:RadChart.SeriesMappings>
    <telerik:SeriesMapping LegendLabel="ExqiPresenter">
      <telerik:SeriesMapping.FilterDescriptors>
        <telerik:FilterDescriptor Operator="IsEqualTo" Member="ServiceId" Value="1">
        </telerik:FilterDescriptor>
      </telerik:SeriesMapping.FilterDescriptors>
      <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition StackGroupName="Description" ></telerik:StackedBarSeriesDefinition>
      </telerik:SeriesMapping.SeriesDefinition>
      <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Month" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="TotalAmount" ></telerik:ItemMapping>            
      </telerik:SeriesMapping.ItemMappings>
    </telerik:SeriesMapping>
    <telerik:SeriesMapping LegendLabel="Test">
      <telerik:SeriesMapping.FilterDescriptors>
        <telerik:FilterDescriptor Operator="IsEqualTo" Member="ServiceId" Value="2">
        </telerik:FilterDescriptor>
      </telerik:SeriesMapping.FilterDescriptors>
      <telerik:SeriesMapping.SeriesDefinition>
        <telerik:StackedBarSeriesDefinition StackGroupName="Description" ></telerik:StackedBarSeriesDefinition>
      </telerik:SeriesMapping.SeriesDefinition>
      <telerik:SeriesMapping.ItemMappings>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Month" ></telerik:ItemMapping>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="TotalAmount" ></telerik:ItemMapping>
      </telerik:SeriesMapping.ItemMappings>
    </telerik:SeriesMapping>

This is in my oppinion a much better solution because it only executes one call to domainservices, the only challenge is that i have to merge my data coming from the Entity Framework. To this end i created a complex type on my Entity Model. I can then run multiple queries and merge the data together:

List<InvoiceStatistics> discountstatistics = discounts.ToList().Select(r => new InvoiceStatistics() { Month = r.Month, TotalAmount = r.TotalAmount }).ToList<InvoiceStatistics>();
      foreach (InvoiceStatistics discountstatistic in discountstatistics)
      {
        statistics.Add(new InvoiceStatistics() { ServiceId=-1, Description="Discount", Month = discountstatistic.Month, TotalAmount = discountstatistic.TotalAmount });
      }

It may not be solution if you have heavy statistics with many thousands of datapoints, but in my case i have 3 statistics that have the same data layout anyway and only one query (discounts) which is different. Because i don't have to execute 4 queries (but only 2) the performance of this solution is even better!

This suits my needs for now.

Thanks again for the sample!




Tags
Chart
Asked by
HDC
Top achievements
Rank 1
Answers by
Yavor
Telerik team
HDC
Top achievements
Rank 1
Share this question
or