开发者

Plotting data with gaps in ZedGraph using nullable types / null values

开发者 https://www.devze.com 2023-03-18 07:35 出处:网络
This question is very similar: How to miss points in a zedgraph line graph in c. I am pulling data from SQL and plotting it using ZedGraph, but I am using nullable types (int?, float? etc.) and would

This question is very similar: How to miss points in a zedgraph line graph in c.

I am pulling data from SQL and plotting it using ZedGraph, but I am using nullable types (int?, float? etc.) and would like to create gaps in the plot whereve开发者_如何学Gor a null value exists.

Is there a way to have ZedGraph handle these null values, or do I need to convert them all to double.NaN?


Casting nullable types to double.NaN seems like the only option when creating the PointPairList for a ZedGraph LineItem (or whatever graph type). Using the null-coalescing operator (??) makes this rather simple:

// example, adding one data point to the list
int? SomeValue = null;
myPointPairList.Add(x, SomeValue ?? double.NaN);
0

精彩评论

暂无评论...
验证码 换一张
取 消