I am new to the xamChart, and to WPF. I really like the xamTrader sample, especially the xamChart you use. There is a whole lot of xaml to dig through, which I have to get the basic configuration of the chart. However, I am puzzled by two features which I really like, but dont have the faintest idea how to configure. 1) What style of line was used? I was thinking something like a bezier curve to render the line chart data, but I cant tell. 2) How did you get the line chart to scroll to the right when new data was introduced?
Thanks!
Hi,
This is a simplified sample which shows how to create a data scrolling. It is based on a timer event and changes made to the first and the last data point of the series.
Always use RefreshEnabled property to improve performance when data are changed in run time.
XAML:
<igCA:XamChart Margin="20,16,14,12" Name="xamChart1" />
C#:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Infragistics.Windows.Chart;using System.Windows.Threading;
namespace WpfApplication10{ /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); }
private readonly DispatcherTimer timerClock = new DispatcherTimer(); Random rnd = new Random(); protected override void OnInitialized(EventArgs e) { base.OnInitialized(e);
timerClock.Tick += new EventHandler(timerClock_Tick); timerClock.Interval = new TimeSpan(0, 0, 1); timerClock.IsEnabled = true;
xamChart1.RefreshEnabled = false; xamChart1.Series.Add(new Series()); xamChart1.Series[0].Fill = Brushes.Red; xamChart1.Series[0].Stroke = Brushes.Red; for( int index = 0; index <=100; index++) { DataPoint dataPoint = new DataPoint(); dataPoint.Value = rnd.NextDouble() * 50; xamChart1.Series[0].DataPoints.Add(dataPoint); } xamChart1.RefreshEnabled = true; }
void timerClock_Tick(object sender, EventArgs e) { xamChart1.RefreshEnabled = false; xamChart1.Series[0].DataPoints.RemoveAt(0); DataPoint dataPoint = new DataPoint(); dataPoint.Value = rnd.NextDouble() * 50; xamChart1.Series[0].DataPoints.Add(dataPoint); xamChart1.RefreshEnabled = true; } }}
Thanks,
Thanks for the sample; simple for me to understand. The first portion, was also a curiosity. What configuration do I use to style the line like xamTrader?
Thanks again!