Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

CNiGraph: best way to reflect data status on plots

Hello

I'm developing C++ application which is able to plot data as function of time using various data sources (databases, devices, etc). So far, my data consisted of time/value pairs only, so it was simple: I'd make one plot for each data "channel" and use Plot::PlotXvsY function.
Yesterday I got new device I have to plot data from, and it returns data as triples: time/value/status. Status is simple boolean Success or Failure, as this device (gas meter using proprietary protocol) can sometimes fail during data acquisition. Such failure is also important event and should be (somehow) visually marked.

My first thought was to make simple "holes" or "broken areas" on plot. You know: first three samples are OK so line connects them, fourth to eight ones are bad so no lines here, line starts again at the ninth sample and continues...and so on. Unfortunately, I found out (looking at the documentation and searching forums here) that this is not possible.
After several hours of thinking, digging in forums and documentation and playing with CNiGraph I came up with following solutions:
Solution #1:
Use several plots with same color, instead of one, to provide visual "holes" in plot. Big disadvantage of this solution is overhead caused by many plots. Say I have four channels of data, each of them has something about 100 "holes", I'd have to create about 400 plots!!!
Solution #2:
Use annotations to mark "begin of hole" and "end of hole" as many times as needed on single plot. This way I have humble number of plots but big number of annotations.

My questions are (and I'd be very grateful if someone more experienced than me, possibly CNiGraph developer could answer them):
1) Do I miss something? Maybe there's a better way, elegant and efficient solution #0 ? 🙂
2) Which solution (#1 or #2) seems to be better one? I like #1 better, because this could give me "holes" I want.
3) Maybe I'm wrong but I have seen (somwhere on the forums) developer saying that similar feature is on some kind of CNiGraph to-do-list. How long I'd have to wait for this feature? How about beta versions (I'd gladly become a betatester)?

Best regards and thank you for your time
Michal
0 Kudos
Message 1 of 5
(3,542 Views)
You can get holes in a plot by plotting NAN values. For example:


CNiReal64Vector data(5);
data[0] = 1;
data[1] = 2;
data[2] = std::numeric_limits::quiet_NaN();
data[3] = 4;
data[4] = 5;

m_graph.PlotY(data);


This example will result in a plot where a line is drawn from 1 to 2 and another line is drawn from 4 to 5, and the area between 2 and 4 is a hole. It sounds like plotting NAN values where the status is a failure would give you what you're looking for.

- Elton
Message 2 of 5
(3,537 Views)
The code above got a little messed up due to being displayed in HTML. The line that used numeric_limits should have been std::numeric_limits::quiet_NaN.

- Elton
0 Kudos
Message 3 of 5
(3,536 Views)
It looked correct in the preview, but it still got messed up again when I submitted it. numeric_limits is a template, so it's std::numeric_limits, then the less than symbol, then double, then the greater than symbol, then ::quiet_NaN. The forums seem to be taking out the less than and greater than symbols, even though I entered them as lt and gt HTML entities.

- Elton
0 Kudos
Message 4 of 5
(3,533 Views)
Hello

You gave me precisely the answer I was looking for, big thanks. It's a pity that I could not find this info on my own...either I not looked well enough or documentation is not precise...but that is not important. What is important to me is the fact that I'm looking on beautiful "plot with holes". Thanks again.

Michal
0 Kudos
Message 5 of 5
(3,527 Views)