kelias Posted December 23, 2009 Report Share Posted December 23, 2009 When I attempt to zoom a chart I'm getting an exception being thrown by ChartFx: ArgumentOutOfRangeException. I have a basic chart, and I add a Line series that uses Dates as the X axis. Then I bind to an observablecollection that has the data points. The chart displays fine but when I click on button2 to do a zoom I get the error. Any ideas why this is happening? private void button2_Click(object sender, RoutedEventArgs e) { chart1.Zoom.Mode = ZoomMode.Selection; } private void NormalLineChart() { chart1.Series.Clear(); chart1.AxesY.Clear(); chart1.LegendBox.Visibility = Visibility.Visible; Axis a = new Axis(); a.Min = 0; a.Max = 50; SeriesAttributes series = new SeriesAttributes("What"); series.BindingPathX = "When"; series.Gallery = Gallery.Line; series.AxisY = a; series.Marker.Visibility = Visibility.Collapsed; series.StrokeThickness = 2; chart1.Series.Add(series); chart1.AxisX.Labels.Format = AxisFormat.Date; chart1.ItemsSource = LoadRandomDateTimeData(10, 0, 50, 10); } private ObservableCollection LoadRandomDateTimeData(int seed, int min, int max, int correlation) { ObservableCollection dps = new ObservableCollection(); Random rnd = new Random(seed); int last = min; for (int i = 0; i < 100; i++) { int itm = rnd.Next(last - correlation, last + correlation); if (itm < min) itm = rnd.Next(min, last + correlation); if (itm > max) itm = rnd.Next(last - correlation, max); last = itm; dps.Add(new DataPoint(itm, DateTime.Today.AddDays(i))); } return dps; } public class DataPoint : INotifyPropertyChanged { private double what; private DateTime when; public DataPoint() { } public DataPoint(double what, DateTime when) { What = what; When = when; } public double What { get { return what; } set { what = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("What")); } } public DateTime When { get { return when; } set { when = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("When")); } } public event PropertyChangedEventHandler PropertyChanged; } Quote Link to comment Share on other sites More sharing options...
kelias Posted January 4, 2010 Author Report Share Posted January 4, 2010 Any ideas? Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 5, 2010 Report Share Posted January 5, 2010 We expect any axis used in the chart to be in either the AxesY or AxesX collection, please add this line of code after you customize your new axis chart1.AxesY.Add(a); e.g. Axis a = new Axis(); a.Min = 0; a.Max = 50; chart1.AxesY.Add(a); ... I Apologize for our delay answering this question. JuanC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.