Jump to content
Software FX Community

Problem with date and 5 minutes interval


Anders
 Share

Recommended Posts

I have placed a chart on my page(xaml) and I have big problems. The chart is freezing if i places data that spends over 24 hours with 5 minute intervals.

If i show items with 5 minutes intervals from (dd/mm-yyyy) 20/07-2007 00:00 to 20/07-2007 23:59, it works just fine.

If i show items with 5 minutes intervals from (dd/mm-yyyy) 20/07-2007 00:00 to 21/07-2007 00:00, the chart frezes.

If i show items with 11 minutes intervals from (dd/mm-yyyy) 20/07-2007 00:00 to 21/07-2007 00:00, it works just fine.

The problem only occurs if im using intervals lesser than 11 minutes, and the intervals in total is more than 24 hours.

Example code:

Graph (Initialize):

public Page1() {

  InitializeComponent(); 

this.Chart1.Background = System.Windows.Media.Brushes.White;

this.Chart1.AxisX.LabelsFormat.Format = AxisFormat.DateTime;

 }

Add data:

private void ButtonClick(object sender, RoutedEventArgs args) {

  this.Chart1.Series.Clear();

  this.Chart1.Gallery = Gallery.Area;

  Series series = new Series();

  ChartItemCollection source = new ChartItemCollection(true);

  series.ItemsSource = source;

series.BindingPathX = "CreationDate";

  series.BindingPath = "Quantity";

  series.Stroke = null;

  Brush b = new LinearGradientBrush(Colors.Blue, Colors.WhiteSmoke, 90);

  series.Fill = b;

  series.MarkerVisibility = Visibility.Hidden;

  this.Chart1.Series.Add(series);

}

This is my data items:

public class ChartItem {

  private DateTime creationDate;

  private int quantity;

  public ChartItem(DateTime creationDate, int quantity) {

  this.creationDate = creationDate;

  this.quantity = quantity;

  }

  Y-Axis

  public int Quantity {

  get { return quantity; }

  set { quantity = value; }

  }

  X-Axis

  public DateTime CreationDate {

  get { return creationDate; }

  set { creationDate = value; }

  }

 }

This is how I generate ChartItems (288 items that works when displayed in the chart):

Date of first item: 01-01-2007 00:00:00

Date of last Item: 01-01-2007 23:55:00

Random r1 = new Random();

DateTime dt = new DateTime(2007,01,01,00,00,00,00);

for (int i = 0; i < 288;i++ )

{

 this.Add(new ChartItem(dt, r1.Next(0, 8)));

 dt = dt.AddMinutes(5);

}

This is how I generate ChartItems (289 items that causes the chart to freeze):

Date of first item: 01-01-2007 00:00:00

Date of last Item: 02-01-2007 00:00:00

Random r1 = new Random();

DateTime dt = new DateTime(2007,01,01,00,00,00,00);

for (int i = 0; i < 289;i++ ){

 this.Add(new ChartItem(dt, r1.Next(0, 8)));

 dt = dt.AddMinutes(5);

}

This is how I generate ChartItems (289 items with 11 minutes interval that works fine):

Date of first item: 01-01-2007 00:00:00

Date of last Item: 03-01-2007 04:48:00

Random r1 = new Random();

DateTime dt = new DateTime(2007,01,01,00,00,00,00);

for (int i = 0; i < 289;i++ ){

 this.Add(new ChartItem(dt, r1.Next(0, 8)));

 dt = dt.AddMinutes(11);

}

Link to comment
Share on other sites

We are unable to reproduce the problem.

I created a new Web Form and added a chart and the following code in the FormLoad event:

Chart1.Gallery = Gallery.Area;

Chart1.AxisX.LabelsFormat.Format =

AxisFormat.DateTime;Random r1 = new Random();DateTime dt = new DateTime(2007,01,01,00,00,00,00);

Chart1.Data.Series = 1;

Chart1.Data.Points = 289;

for (int i = 0; i < 289;i++ ){

Chart1.Data.X[0,i] = dt.ToOADate();

Chart1.Data.Y[0,i] = r1.Next(0,8);

dt = dt.AddMinutes(5);

}

This is the data that you said caused the problem. There may be some other code that you didn't post that is causing the problem in combination with this data.

Please post a complete sample that reproduces the issue so that we can determine what the problem is.

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.

 Share

×
×
  • Create New...