Jump to content
Software FX Community

Zoom Problem


kelias

Recommended Posts

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;

}

Link to comment
Share on other sites

  • 2 weeks later...

 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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...