Hi jacques labuschagne,
I have provided a solution in another thread with same problem, and you can update the chart via DataBind method.
Here is a code example:
public Form1()
{
InitializeComponent();
timer1.Start();
CreateCharts();
timer2.Start();
timer2.Interval = 2000;
}
private void timer2_Tick(object sender, EventArgs e)
{
UpdateUserScanRatesHourlyDaily();
UpdateCharts();
}
List<Scanner> MyList = new List<Scanner>();
private void CreateCharts()
{
Series s = new Series();
s.XValueMember = "UserName";
s.YValueMembers = "HuPackedDay";
MyList.Add(new Scanner("A",1));
MyList.Add(new Scanner("D", 2));
MyList.Add(new Scanner("F", 3));
chart1.DataSource = MyList;
chart1.Series.Add(s);
chart1.DataBind();
}
int i = 1;
private void UpdateUserScanRatesHourlyDaily()
{
var found = MyList.FirstOrDefault(c => c.HuPackedDay == i);
found.HuPackedDay =i+1;
i++;
}
private void UpdateCharts()
{
chart1.DataBind();
}
public class Scanner
{
String username;
int huPackedDay=0;
public string UserName
{
get { return username; }
set { username = value; }
}
public int HuPackedDay
{
get { return huPackedDay; }
set { huPackedDay = value; }
}
public Scanner(string un, int h)
{ UserName = un; HuPackedDay = h; }
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.