Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

how to set the ChartLength in a multiplot graph

I have a multiplot chart and I need to set the total number of visible points in the graph. The CNiGraph::ChartLength() sets the total number of points for each plot, not for the whole graph. How can I do that ?
0 Kudos
Message 1 of 8
(4,674 Views)
The ChartLength property is the only way to influence the number of points in CNiGraph, so unfortunately, there is not a way to do what you're looking for with CNiGraph. If you use the Measurement Studio .NET graph in the future, you can do this on a plot-by-plot basis via the plot's HistoryCapacity property.

- Elton
0 Kudos
Message 2 of 8
(4,670 Views)
The number of visible points on the graph is determined by the axis ranges. The number of points that the graph holds in memory is determined by CNiGraph::ChartLength() and, as Elton indicated, is not configurable on a plot-by-plot basis in CNiGraph.

If you want to be able to determine the total number of visible points, you would need to analyze your data to determine how to set the axis ranges so that the graph shows the number of points you are interested in. There is nothing built into the graph that allows you to specify the total number of points and have the graph adjust the axis ranges accordingly.

Could you give more detail on what exactly you are trying to do?
0 Kudos
Message 3 of 8
(4,668 Views)
My problem is that I want to put a symbol for each point in my multiplot chart. I have many points and CNiAnnotations::Add() is very slow when I add many annotations; so I've decided to add annotations in design-time by the Graph property dialog : in this way my program is fast enough but I've a fixed number of annotations, so I must have a fixed maximum number of points. I thought CNiGraph::ChartLength() set the total number of points in the graph history but in reality it sets the maximum number of points for each plot. My data are generated in real-time and I don't know how much points there will be for each plot so I can't use the ChartLength function. The only solution I've found is to use the CNiGraph::ChartXY(double x, double y) function (I cannot use the other Chart functions because the X coordinates are random for each plot) : however, in this way I have only one plot. My question is : can I set the maximum total number of points in the graph history using a multiplot chart ?
0 Kudos
Message 4 of 8
(4,656 Views)
There is no way to do this automatically with CNiGraph. You should be able to do it manually, but it will require some work. The best way I can think to do this would be to create an array of CNiReal64Matrix instances. Each instance in the array corresponds to one of the plots that you have now. When a new data point is available, add it to the appropriate CNiReal64Matrix instance (instead of calling ChartXY). Then, call CNiPlot::PlotXY and pass it the CNiReal64Matrix instance that contains the data. You could keep a running count of the total number of points that are in all of the CNiReal64Matrix instances in the array. When you reach the total number of annotations that you have, you will have to shift the data in one of the matrices. Unfortunately, there is not an easy way to do this with CNiMatrix alone. When it is time to shift the data, the easiest way I see to do it would be to call CNiMatrixT<>::CopyRow to extract CNiReal64Vector instances for each row in the matrix, call CNiVectorT<>::SubSet to shift the data, and call CNiMatrixT<>::AssignRow to put the data back into the matrix, and then plot.

Will this approach work for you?
0 Kudos
Message 5 of 8
(4,648 Views)
It's a good answer, but I think it doesen't work in my case because I'd have to shift the oldest data keeping only the newest, so I'd have to search the oldest points in each matrix.
0 Kudos
Message 6 of 8
(4,642 Views)
This should still work. The oldest points will be at the beginning of the matrix and the newest points will be at the end of the matrix. The first row in the matrix contains the X values. The second row in the matrix contains the Y values. I have attached an example program that shows the shifting concept working (though only for one plot; not your exact use case). Build the program, click the Plot button a few times, then click the Shift button.

Let me know if this will work for you; perhaps I'm misunderstanding your problem.
0 Kudos
Message 7 of 8
(4,635 Views)
It works good. The only difference with my problem is that I need to make a search in all the matrix instances for finding the oldest points : you are right when you say that the oldest points are at the beginning of each matrix but I don't know how many points in a matrix are older than the points in the other matrix instances. However I can make a search in each matrix and then remove the oldest points I found.
Thank you very much for the great idea.
0 Kudos
Message 8 of 8
(4,618 Views)