Item index Property getting reset when zoom settings selected

2 posts, 0 answers
  1. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 18 Nov 2010 Link to this post

    HI Team,

    I am working on telerik controls from past year, Your controls are awesome as well as your support, Now i struck again with RadChart,
    I build my chart with bar series , when number of bars are more than 7 ,I am applying zoom , So that a scroll bar will be visible and user can scroll. I am applying tooltip for every bar, to populate data I am taking Item index as the identifier, Until  and  unless i have  scroll bar everthing works fantastic, But when user scroll chart, irrespective of item number, the first bar series visible in chart gets item index as zero, so i am ending up with wrong values in my tool tips.

    Here goes my code.
    SeriesMapping series5 = new SeriesMapping();
               series5.SeriesDefinition = new LineSeriesDefinition();
               series5.SeriesDefinition.AxisName = "PCST";
               series5.SeriesDefinition.ShowItemToolTips = true;
               series5.SeriesDefinition.Appearance.Fill = new SolidColorBrush(Colors.Red);
               series5.SeriesDefinition.ItemLabelFormat = "N1";           
               ItemMapping series5_Mapping;
               ItemMapping catPCFMapping;
               ItemMapping PCFValMapping;
               series5.LegendLabel = "PC Sell Thru Actual";
               series5_Mapping = new ItemMapping("PCSTActual_Unit", DataPointMember.YValue);
               catPCFMapping = new ItemMapping("LevelName", DataPointMember.XCategory);
               PCFValMapping = new ItemMapping("LevelID", DataPointMember.XValue);
               if (Data.Count() > 7)
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 0;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 0.30;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = .001;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
                   rcCountryAttach_Summary.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2;
                   rcCountryAttach_Summary.DefaultView.ChartArea.AxisX.StepLabelLevelHeight = 15;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.001;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.None;
                   rcCountryAttach_Summary.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 0;
                   rcCountryAttach_Summary.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 1;
                   rcCountryAttach_Summary.DefaultView.ChartArea.AxisX.StepLabelLevelHeight = 15;
               rcCountryAttach_Summary.ItemsSource = Data;

    tooltip data

      void ChartArea_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e)
                // MessageBox.Show("Hello");
                int item = e.ItemIndex;
                //throw new NotImplementedException();
                Grid Tooltipgrid = new Grid();
                ColumnDefinition cd = new ColumnDefinition();
                RowDefinition rd = new RowDefinition();
    ///add columns , ROws,
      TextBlock tb12 = new TextBlock();
                tb12.Foreground = new SolidColorBrush(Colors.Black);
                tb12.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                tb12.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                tb12.Text = (TooltipData[e.ItemIndex].PCSTActual_Unit * 1000000).ToString("###,##");// +" M";
                Grid.SetRow(tb12, 1);
                Grid.SetColumn(tb12, 1);

    I am attaching my screen shots here, Even though both are different bars in chart , us and canada , they both have item index as zero when scroll bar selected, so it ends up with same tool tip values,

    SO my question is how to get item index of an item in chart,  irrespective of scroll bar ( Now what happening is I f i scroll my chart towards right, what ever the item comes first is getting item index as 0)

    Hope I explained my issue clearly.

  2. Kevin Tran
    Kevin Tran avatar
    40 posts
    Member since:
    Apr 2010

    Posted 18 Nov 2010 Link to this post

    I guess i fixed this issue instead of taking Item index as identifier take x-axis value
    add this piece of code in ur tooltip event

    string value = e.DataPoint.XCategory;
             List<BIWCFService.CountryAttachSummary> data_tooltip;
             data_tooltip = TooltipData.Where(x => x.LevelName == value).ToList();

Back to Top