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

…衆ロ難τιáo~ 提交于 2019-12-13 17:53:14

问题


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 wherever 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?


回答1:


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);


来源:https://stackoverflow.com/questions/6603151/plotting-data-with-gaps-in-zedgraph-using-nullable-types-null-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!