Ethankie Posted March 10, 2011 Report Share Posted March 10, 2011 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> See code below: private void Button_Click_1(object sender, RoutedEventArgs e) { var startDate = new DateTime(2008, 3, 7); var seed = new Random(); var isEstimated = false; //this.chart1.Series.Clear(); //this.chart1.Refresh(); var itemsSource = new List<ChartTestData>(); for (int i = 1; i <= this._count; i++) { itemsSource.Add(new ChartTestData { Date = startDate, Price = seed.Next(50,100), IsEstimated = isEstimated }); startDate = startDate.AddDays(7); isEstimated = i % 7 == 0 || i % 6 == 0; } this.chart1.Series.Add(new SeriesAttributes("Price") { ItemsSource = itemsSource, Content = "Price", Gallery = Gallery.Line, StrokeThickness = 1, Marker = new MarkerAttributes { Visibility = Visibility.Collapsed } }); startDate = new DateTime(2008, 3, 7); var date1 = startDate.AddDays(7); var itemsSource1 = new List<ChartTestData>(); itemsSource1.Add(new ChartTestData { Date = date1, Price = itemsSource.FirstOrDefault( x=> x.Date == date1).Price}); var date2 = startDate.AddDays(14); itemsSource1.Add(new ChartTestData { Date = date2, Price = itemsSource.FirstOrDefault(x => x.Date == date2).Price }); this.chart1.Series.Add(new SeriesAttributes("Price") { ItemsSource = itemsSource1, Content = "Price", Gallery = Gallery.Scatter, StrokeThickness = 1, Marker = new MarkerAttributes { Visibility = Visibility.Visible, Shape = MarkerShape.Triangle, Size = 10 } }); } public class ChartTestData { /// <summary> /// Gets or sets the date. /// </summary> /// <value>The date.</value>public DateTime Date { get; set; } /// <summary> /// Gets or sets the price. /// </summary> /// <value>The price.</value>public double? Price { get; set; } /// <summary> /// Gets or sets a value indicating whether this instance is estimated. /// </summary> /// <value> /// <c>true</c> if this instance is estimated; otherwise, <c>false</c>. /// </value>public bool IsEstimated { get; set; } } 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.