receive data and create chart in real time
Posted: Fri Jul 16, 2010 3:35 pm
Hi,
----> I would like to build a chart with a CSV file which is update every 100ms.
I began to write the following code :
And I see an example on the documentation, but it's not really adapt at WPF code.
I use Visual studio 2008 ( WPF code ) with Teechart 3.5.3188.18562
----> I would like to build a chart with a CSV file which is update every 100ms.
I began to write the following code :
Code: Select all
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 Steema.TeeChart.WPF.Styles;
using Steema.TeeChart.WPF.Tools;
using Steema.TeeChart.WPF.Themes;
using Steema.TeeChart.WPF;
using Steema.TeeChart.WPF.Drawing;
using Steema.TeeChart;
using Steema.TeeChart.WPF.Editors;
using Steema.TeeChart.WPF.Export;
using Steema.TeeChart.WPF.Data;
using Steema.TeeChart.WPF.Functions;
using System.Drawing;
using System.Data;
namespace CSV_real_time
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
// disable of view in 3D
this.tChart1.Aspect.View3D = false;
//display or not the legend of chart
this.tChart1.Legend.Visible = false;
tChart1.AutoRepaint = true;
// title of chart
this.tChart1.Header.Text = " CSV file in real time ";
// new fastline of steema library
FastLine fast1;
// add fastline of chart
fast1 = new Steema.TeeChart.WPF.Styles.FastLine(tChart1.Chart);
// Path of CSV file
TextSource textsource1 = new TextSource("C:\\Users\\ljoly\\testone.csv");
// Decimale Separator of each data
textsource1.DecimalSeparator = ',';
// Number of header ( here it is X and Y )
textsource1.HeaderLines = 2;
// Separator of each data
textsource1.Separator = Convert.ToChar("\t");
// link fastline and data on CSV file
fast1.DataSource = textsource1;
// X field data of CSV file
textsource1.Fields.Add(0, "X");
// Y field data of CSV file
textsource1.Fields.Add(1, "Y");
// Active fastlien serie which come from CSV file
textsource1.Series.Active = true;
// link serie of fastline of CSV file
textsource1.Series = fast1;
// make a check of datasource
fast1.CheckDataSource();
}
}
}
I use Visual studio 2008 ( WPF code ) with Teechart 3.5.3188.18562