Jump to content
Software FX Community

When put Line Gallery and Scatter Gallery in the same chart. The Scatter Series messes up the Axis X. Is there a way to fix this? Thanks .


Ethankie
 Share

Recommended Posts

<?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; }

}

 

Posted ImagePosted Image

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...