No IEnumerable item found at index

2 posts, 0 answers
  1. guillaume cros
    guillaume cros avatar
    15 posts
    Member since:
    Apr 2010

    Posted 30 Jul 2010 Link to this post

    Hello,

    I have a little problem with my chart.

    In my project containt a RadGridView and a RadChart. the itemSource of radChart are the ItemSelected of Grid.

    For Draw my chart I use this function :
    private void PopulateChart(List<DataItemViewModel> listDataViewModel)
     {
    SeriesMappingCollection seriesMapping = new SeriesMappingCollection();
                        ObservableCollection<List<DataItemViewModel>> itemSourceList = new ObservableCollection<List<DataItemViewModel>>();
                        foreach (GroupDescription groupDesc in _groupList)
                        {
                            SeriesDefinition seriesDef = this.GetSeriesDefinition("Bubble");
                            SeriesMapping seriesMap = new SeriesMapping();
                            ItemMapping itemMapX;
                            ItemMapping itemMapY;
                            SeriesDescription seriesDesc = _seriesList.First<SeriesDescription>(desc => desc.SeriesDefinition.Equals("Bubble"));
     
                            itemMapY = new ItemMapping(String.Concat("DrawnItem.", seriesDesc.Criterium), DataPointMember.YValue);
                            seriesMap.ItemMappings.Add(new ItemMapping(String.Concat("DataItem.Lbl", seriesDesc.Criterium), DataPointMember.Label));
                            seriesMap.ItemMappings.Add(itemMapY);
     
                            if (_xSeries.DataType.Equals("double") || _xSeries.DataType.Equals("long"))
                            {
                                itemMapX = new ItemMapping(String.Concat("DrawnItem.", _xSeries.Criterium), DataPointMember.XValue);
                            }
                            else
                            {
                                if (!_xSeries.Criterium.Equals("LABEL"))
                                    itemMapX = new ItemMapping(String.Concat("DrawnItem.S", _xSeries.Criterium), DataPointMember.XCategory);
                                else
                                    itemMapX = new ItemMapping(String.Concat("DrawnItem.", _xSeries.Criterium), DataPointMember.XCategory);
     
                            }
                            seriesDef.ItemToolTipFormat = "#LABEL";
     
                            seriesMap.ItemMappings.Add(itemMapX);
                            seriesMap.SeriesDefinition = seriesDef;
     
                            List<DataItemViewModel> listDataView = listDataViewModel.Where<DataItemViewModel>(dataItemTemp => dataItemTemp.DrawnItem.Grp == groupDesc.Num).ToList<DataItemViewModel>();
                            if (listDataView.Count > 0)
                            {
                                itemSourceList.Add(listDataView);
                                seriesMap.CollectionIndex = itemSourceList.Count - 1;
                                seriesMap.LegendLabel = groupDesc.Label;
                                seriesMapping.Add(seriesMap);
                            }
                        }
                        radChart.SeriesMappings = seriesMapping;
                        radChart.ItemsSource = itemSourceList;
    radChart.DefaultView.ChartArea.AxisY.AutoRange = true;
     
    }


    I made DataItemViewModel class, it's containt my data. A properties in this class are the group number of point. the number of series in the chart are the number of group in the parameter list.

    When start my project, all works, the funtion PopulateChart take All Data in parameter.

    But after, when I change the grid selection, it's works only when parameters list containt datas with the same group.

    When group are different I have, in the instruction : radChart.SeriesMappings = seriesMapping; this Exception :
    No IEnumerable item found at index: 1 in the ItemsSource!

    I don't understand why I have this exception, the type of data are the same, the processing are the same.

    If someone have an idea or a clue.
  2. guillaume cros
    guillaume cros avatar
    15 posts
    Member since:
    Apr 2010

    Posted 02 Aug 2010 Link to this post

    I solved my problem.

    When I have data with different groups, in the item source I have one list per group.

    But I put values in itemsource of chart after the series, and the program search values in the second list at index 1. But there is not yet a second list :

    radChart.SeriesMappings = seriesMapping;
    radChart.ItemsSource = itemSourceList;


    I just reverse the place of instuctions and it's works!

    radChart.ItemsSource = itemSourceList;
    radChart.SeriesMappings = seriesMapping;


    Sorry for disturbance.
Back to Top