How to make added points as empty at runtime in WinForms Chart?
You can add new points to the existing series in the chart using the timer event in WinForms Chart. In the timer event, you can empty the particular points by setting the isEmpty property to true.
Step 1: Create simple charts with some points,
ChartControl chart = new ChartControl(); ChartSeries series = new ChartSeries("Series", ChartSeriesType.Spline); Random random = new Random(); public Form1() {
for(int i = 0; i < 10; i++) { series.Points.Add(i, random.Next(10, 40)); } chart.Series.Add(series); chart.Dock = DockStyle.Fill; chart.ShowLegend = false; chart.Skins = Skins.Metro; InitializeComponent(); this.Controls.Add(chart); } |
Step 2: Initialize the timer event.
Timer timer = new Timer(); public Form1() { timer.Interval = 2000; timer.Tick += Timer_Tick; timer.Start(); } |
Step 3: The isEmpty property to true for particular points in series’s Points collection in the timer event when adding the new points to the existing series.
private void Timer_Tick(object sender, EventArgs e) { series.Points.Add(series.Points.Count, random.Next(10, 40)); series.Points[5].IsEmpty = true; timer.Stop(); } |
The following screenshots illustrates the result when adding new points in the timer.
While rendering chart:
After setting the isEmpty property in the timer event:
Sample link: ChartSample
Conclusion
I hope you enjoyed learning about how to make added points as empty at runtime in the WinForms Chart.
You can refer to our WinForms Chart feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!