create step line chart in WPF

Apr 1, 2010 at 8:10 AM

Hi Experts,

 

Can anyone guide me how to make step line chart in WPF? 

 

Thanks.

Apr 6, 2010 at 11:58 AM

Hi,

I am trying like this to duplicate my keys and values and then passing it to itemsource of chart. Still not showing right way. Any guidance??

 

  List<KeyValuePair<int, int>> series = new List<KeyValuePair<int, int>>();
  series.Add(new KeyValuePair<int, int>(10, 100));
  series.Add(new KeyValuePair<int, int>(20, 130));
  series.Add(new KeyValuePair<int, int>(30, 150));
  series.Add(new KeyValuePair<int, int>(40, 125));
  series.Add(new KeyValuePair<int, int>(50, 155));
  ((LineSeries)Chart1.Series[0]).ItemsSource = CreateStepLineSeries<int, int>(series);
......

List<KeyValuePair<T, U>> CreateStepLineSeries<T, U>(List<KeyValuePair<T, U>> source)
{
  List<KeyValuePair<T, U>> returnValue = new List<KeyValuePair<T, U>>();
  for (int i = 0; i < source.Count; i++)
  {
    KeyValuePair<T, U> currentValue = source[i];
    returnValue.Add(currentValue);
    if (i < source.Count - 1)
    {
      KeyValuePair<T, U> nextValue = source[i + 1];
      returnValue.Add(new KeyValuePair<T, U>(nextValue.Key, currentValue.Value));
    }
  }
  return returnValue;
}
Apr 7, 2010 at 8:24 AM

here is the solution

for someone else in need.

http://cid-51b2fdd068799d15.skydrive.live.com/self.aspx/.Public/Untitled.png#resId/51B2FDD068799D15!159