11-03-2010 12:00 PM
In my windows application using Measurement Studio I retrieve different signals which are inserted in a scattergraph using PlotXYAppend().
What possibilities do I have to adjust the data within the plot, i.e. the data retrievable by GetYData() and GetXData(), for presentation?
What I would like is to scale all points and or adding an offset, etc.
I can see two options:
1. For every signal use two plots, one (hidden) original/raw data plot and one (displayed) and adjusted plot. Every time I modify scale/offset I need to dispose the adjusted plot and create a new one based on the original data.
2. Is is possible to override the Paint-function used to draw a plot? To adjust the data just before it is drawn on the screen?
Any comments?
Best regards, Björn Nilsson
11-05-2010 10:48 AM - edited 11-05-2010 10:48 AM
Hi there,
Option1
The DefaultOffset and DefaultStart properties of WaveformPlot might be what you are looking for.
Option2
You can customize drawing plot in different ways, by hooking onto WaveformPlot.BeforeDraw or by hooking onto WaveformGraph.BeforeDrawPlot, or by deriving from WaveformPlot and overriding OnBeforeDraw event.
Inside the event handlers (or the overriden method if you choose to write a subclass of WaveformPlot), you can map the data points to the coordinates in pixels by using WaveformPlot.MapDataPoints(....) method.
This method will return an array of points that you can use to manipulate/draw.
Once you are done drawing, you can cancel the default drawing by setting BeforeDrawXYPlotEventArgs.Cancel to true.
The second option (i.e. customizing drawing) involves a bit of coding, but with option2 you can customize the graph to look the way you want.
Reply if you need more help.
Hope this helps,
Vijet Patankar,
National Instruments