dimabima
dimabima

Reputation: 23

Avoiding null values when charting in C#

So, the premise of my program is to take in information that a user inputs from a textbox and then charting it. Unfortunately, I have to make it so that a user can leave some input blank. As a result, I am left trying to graph null data. The chart will just stop graphing at that point, even if there is data afterwards to be graphed. Is there any way for the chart to ignore null values?

Upvotes: 2

Views: 3558

Answers (2)

V4Vendetta
V4Vendetta

Reputation: 38210

Assuming you have got X axis values and at times the corresponding Y values are null then you should be looking at the EmptyPointStyle of the Series. here you can control the appearance and also set a specific label like "No Value" or "Value Needed" which would be seen on the graph.

In case you want to skip the value and join the adjacent points then set the Color property of the EmptyPointStyle

Chart1.Series[2].EmptyPointStyle.Color = System.Drawing.Color.Green;

Upvotes: 3

James Black
James Black

Reputation: 41858

Without more detail of how you are doing the processing, you just need to have some method that can look at all of the textboxes and then pick which graph to generate, so, for example, if you have textboxes for company, department and building, and someone fills in company and building then you may need to call a separate class that extends the main graphing abstract class and it will know how to process the results.

Now, if you have 10 textboxes then covering all the bases is harder, but even then, you may need to dynamically generate the query to pull in the data and once you have the data then you just graph everything that was returned.

Upvotes: 0

Related Questions