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

Zoom not working on custom itemmappings specified?

3 Answers 31 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 2
Rahul asked on 08 Mar 2011, 08:21 AM
Zoom is working fine in the following Case. Have a look at the code
.
 foreach (var t in e.Result.lstMeasureData)
 {
      tempData.Add(new MeasureData { Datetaken = t.Datetaken, A1C = t.A1C, DBP = t.DBP, HDL = t.HDL, LDL = t.LDL, SBP = t.SBP, Weight = t.Weight });
 }

radChart1.DefaultSeriesDefinition = new LineSeriesDefinition();
             
radChart1.DefaultSeriesDefinition.ShowItemLabels = false;
radChart1.DefaultView.ChartArea.EnableAnimations = true;
radChart1.DefaultView.ChartArea.EnableTransitionAnimations = true;
 
radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1;
radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.001;
radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
 
radChart1.DefaultView.ChartArea.AxisY.Title = "Measures";
radChart1.DefaultView.ChartArea.AxisX.Title = "Dates";
 
radChart1.ItemsSource = tempData;

However if define custom series mappings and item mapping zoom is not working.
Even after zooming on chart data remains as it is.
Check the following code in which zoom is not working.

foreach (var t in e.Result.lstMeasureData)
 {
      tempData.Add(new MeasureData { Datetaken = t.Datetaken, A1C = t.A1C, DBP = t.DBP, HDL = t.HDL, LDL = t.LDL, SBP = t.SBP, Weight = t.Weight });
 }

 
radChart1.DefaultSeriesDefinition = new LineSeriesDefinition();
              
 radChart1.DefaultSeriesDefinition.ShowItemLabels = false;
 radChart1.DefaultView.ChartArea.EnableAnimations = true;
 radChart1.DefaultView.ChartArea.EnableTransitionAnimations = true;
 
 radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1;
 radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.001;
 radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
  
 radChart1.DefaultView.ChartArea.AxisY.Title = "Measures";
 radChart1.DefaultView.ChartArea.AxisX.Title = "Dates";
 
 
 SeriesMapping seriesMapping1 = new SeriesMapping() { LegendLabel = "Weight" };
 seriesMapping1.ItemMappings.Add(new ItemMapping("Weight", DataPointMember.YValue));
 
 SeriesMapping seriesMapping2 = new SeriesMapping() { LegendLabel = "HDL" };
 seriesMapping2.ItemMappings.Add(new ItemMapping("HDL", DataPointMember.YValue));
 
 SeriesMapping seriesMapping3 = new SeriesMapping() { LegendLabel = "LDL" };
 seriesMapping3.ItemMappings.Add(new ItemMapping("LDL", DataPointMember.YValue));
 
 SeriesMapping seriesMapping4 = new SeriesMapping() { LegendLabel = "Datetaken" };
 seriesMapping4.ItemMappings.Add(new ItemMapping("Datetaken", DataPointMember.XCategory));
 
 SeriesMappingCollection seriesMappings = new SeriesMappingCollection() { seriesMapping1, seriesMapping2, seriesMapping3 };
 radChart1.SeriesMappings = seriesMappings;
 
radChart1.ItemsSource = tempData;

3 Answers, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 2
answered on 08 Mar 2011, 09:47 AM
Admins plz answer this post as soon as possible. I'm completely stucked here.
0
Accepted
Evgenia
Telerik team
answered on 11 Mar 2011, 09:12 AM
Hi Rahul,

The issue you are facing is caused because you are setting XCategory as new SeriesMapping. Instead you should add it as new ItemsMapping in your existing series mappings. Here is how you can achieve this:

RadChart1.DefaultSeriesDefinition = new LineSeriesDefinition();
           RadChart1.DefaultSeriesDefinition.ShowItemLabels = false;
           RadChart1.DefaultView.ChartArea.EnableAnimations = true;
           RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1;
           RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.001;
           RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
           RadChart1.DefaultView.ChartArea.AxisY.Title = "Measures";
           RadChart1.DefaultView.ChartArea.AxisX.Title = "Dates";
           SeriesMapping seriesMapping1 = new SeriesMapping() { LegendLabel = "Weight" };
           seriesMapping1.ItemMappings.Add(new ItemMapping("Weight", DataPointMember.YValue));
           seriesMapping1.ItemMappings.Add(new ItemMapping("Datetaken", DataPointMember.XCategory));
           SeriesMapping seriesMapping2 = new SeriesMapping() { LegendLabel = "HDL" };
           seriesMapping2.ItemMappings.Add(new ItemMapping("HDL", DataPointMember.YValue));
           seriesMapping2.ItemMappings.Add(new ItemMapping("Datetaken", DataPointMember.XCategory));
           SeriesMapping seriesMapping3 = new SeriesMapping() { LegendLabel = "LDL" };
           seriesMapping3.ItemMappings.Add(new ItemMapping("LDL", DataPointMember.YValue));
           seriesMapping3.ItemMappings.Add(new ItemMapping("Datetaken", DataPointMember.XCategory));
           SeriesMappingCollection seriesMappings = new SeriesMappingCollection() { seriesMapping1, seriesMapping2, seriesMapping3};
           RadChart1.SeriesMappings = seriesMappings;

Greetings,
Evgenia
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Rahul
Top achievements
Rank 2
answered on 11 Mar 2011, 10:23 AM
Thanx for reply. Thats what i want.
Tags
Chart
Asked by
Rahul
Top achievements
Rank 2
Answers by
Rahul
Top achievements
Rank 2
Evgenia
Telerik team
Share this question
or