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

Many Point Data Problem

3 Answers 126 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Emily
Top achievements
Rank 1
Emily asked on 14 Oct 2010, 06:13 AM


Binding to the DataTable when DataBinding multiple Row to the error

DataCode
public DataTable GetDataTable()
{
    DataTable dataTable = new DataTable();
    dataTable.Columns.Add("Time", typeof(DateTime));
    dataTable.Columns.Add("DoubleData", typeof(double));
    dataTable.Columns.Add("Time2", typeof(DateTime));
    dataTable.Columns.Add("DoubleData2", typeof(double));
      
    for (int index = 0; index <1000; index++)
    {
        DataRow dataRow = dataTable.NewRow();
        dataRow["DoubleData"] = 21.7003078460693;
        dataRow["DoubleData2"] = 21.7003078460693 + 10;
        dataRow["Time"] = DateTime.Now.AddSeconds(index);
        dataRow["Time2"] = DateTime.Now.AddSeconds(index+1);
        dataTable.Rows.Add(dataRow);
    }
    return dataTable;
}


Chart Code
        radChart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Auto;
            radChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
            radChart.DefaultView.ChartArea.AxisX .DefaultLabelFormat = "hh:mm MM:ss";
            radChart.DefaultView.ChartArea.AxisX.AutoRange = true;
  
            SeriesMapping seriesMapping = new SeriesMapping();
            LineSeriesDefinition lineSeriesDefinition = new LineSeriesDefinition();
            ItemMapping YItem = new ItemMapping("DoubleData", DataPointMember.YValue);
            ItemMapping XItem = new ItemMapping("Time", DataPointMember.XValue);
            seriesMapping.LegendLabel = "1";
            lineSeriesDefinition.ShowItemLabels = false;
            lineSeriesDefinition.ShowPointMarks = false;
            seriesMapping.SeriesDefinition = lineSeriesDefinition;
            seriesMapping.ItemMappings.Add(YItem);
            seriesMapping.ItemMappings.Add(XItem);
            lineSeriesDefinition.ShowItemToolTips = true;    
            radChart.SeriesMappings.Add(seriesMapping);
              
            SeriesMapping seriesMapping2 = new SeriesMapping();
            LineSeriesDefinition lineSeriesDefinition2 = new LineSeriesDefinition();
            ItemMapping YItem2 = new ItemMapping("DoubleData2", DataPointMember.YValue);
           ItemMapping XItem2 = new ItemMapping("Time2", DataPointMember.XValue);
            seriesMapping2.LegendLabel = "2";
            lineSeriesDefinition2.ShowItemLabels = false;
            lineSeriesDefinition2.ShowPointMarks = false;
            lineSeriesDefinition2.ItemLabelFormat = "mm:dd hh:MM:ss";
            seriesMapping2.SeriesDefinition = lineSeriesDefinition2;
            seriesMapping2.ItemMappings.Add(YItem2);
            seriesMapping2.ItemMappings.Add(XItem2);
            radChart.SeriesMappings.Add(seriesMapping2);
  
  
  
            radChart.ItemsSource = GetDataTable(); <-- Error

Error
No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

What should I do?

3 Answers, 1 is accepted

Sort by
0
Emily
Top achievements
Rank 1
answered on 15 Oct 2010, 05:53 AM
When databinding to DataTable need to specify the field type
0
Evgenia
Telerik team
answered on 20 Oct 2010, 11:22 AM
Hello Emily,

I was able to reproduce your issue. This type of error appears because you are binding RadChart to DataTable. DataTable is from .NET 1.0 and it doesn't support Generics as they are new to the .net framework (.NET version 3.5 ). To use DateTime in your DataTable you should cast it to double. Here is how you can achieve this:

YItem.FieldType = typeof(double);
Have in mind that you should cast your YItem2 to double too.
I hope this information helps.

All the best,
Evgenia
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
Emily
Top achievements
Rank 1
answered on 21 Oct 2010, 03:09 AM
Thanks~~
Tags
Chart
Asked by
Emily
Top achievements
Rank 1
Answers by
Emily
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or