private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
public Form1()
{
InitializeComponent();
this.Load += Form1_Load;
…….
this.timer.Interval = 900;
this.timer.Tick += new EventHandler(this.timer_Tick);
}
private void Form1_Load(object sender, EventArgs e)
{
timer.Start();
}
|
For more details, please refer below kb to clear the cache:
|
List<DateTime> ListOfDate = new List<DateTime>();
public Form1()
{
InitializeComponent();
chartSeries.Style.Symbol.Shape = ChartSymbolShape.Circle;
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Category;
this.chartControl1.ChartFormatAxisLabel += ChartControl1_ChartFormatAxisLabel;
}
private void ChartControl1_ChartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
if (e.AxisOrientation == ChartOrientation.Horizontal)
{
if (ListOfDate.Count > 0)
{
e.Label = ListOfDate[Convert.ToInt32(e.Label)].ToString("HH:mm:ss");
e.Handled = true;
}
}
}
private void timer_Tick(object sender, EventArgs e)
{
this.timer.Enabled = false;
try
{
…..
chartSeries.Points.Clear();
ListOfDate.Clear();
if (this.chartControl1.Series[0].Trendlines.Count > 0) this.chartControl1.Series[0].Trendlines.Remove(trendline);
int index = 0;
foreach (Monitor ElementoCorrente in UltimiN)
{
chartSeries.Points.Add(index.ToString(), ElementoCorrente.TP1);
ListOfDate.Add(ElementoCorrente.Time);
index++;
}
……
}
|
public Form1()
{
….
this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Category;
this.chartControl1.ChartFormatAxisLabel += ChartControl1_ChartFormatAxisLabel;
chartSeries.SortPoints = false;
} |