Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

"FillAndBins" Color changes.

I would like to have the "FillAndBins" color of each bar in stripchart history maintained when I change the color of new bars. Is that possible?
0 Kudos
Message 1 of 7
(3,603 Views)
There is no built in functionality to keep the history of colors you have changed, but it seems you could just have a data type (an array or some other data type) of type Color and you could store the previous values as you change the color.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 2 of 7
(3,585 Views)

I would certainly like to do that, but once I change the color, the entire plot changes. How do I prevent the refresh

from changing the entire plot?

 

0 Kudos
Message 3 of 7
(3,583 Views)
Although there is no built-in functionality for achieving this, you can do this through extensibility. Measurement Studio controls provide extensibility points in the API that let you participate in the drawing of the control. In the case of the plot, you can attach an event handler to the BeforeDraw event of the plot to hook into one of these extensibility points. You will need to save the new data set (to be drawn in a different color), In the event handler:
 
1. Call DrawFillsToBase to let the plot draw the fills.
2. Get the new data set that you saved and use the MapDataPoints method to convert the new data set to screen points that you can draw.
3. Create a GraphicsPath with the mapped screen points and fill the GraphicsPath with the color of your choosing.
4. Call DrawLinesToBase to let the plot draw the bins.
5. Call DrawLines, DrawPoints (if you are using PointStyles), and DrawErrorBands (if you are using error bands, new in Measurement Studio 8.1) in that order.
6. Set the Cancel property of the event args to true to cancel the plot drawing.
 
Note that the above algorithm will draw bin lines in the same color, but the fill (inside the bars) in a different color.
 
For more information on extending the plot you can look up:
 
1. Concept topic - In Visual Studio, go to the Help menu and click on Contents and browse to NI Measurement Studio Help >> NI Measurement Studio .NET Class Library >> Using the Measurement Studio .NET Class Libraries >> Using the Measurement Studio Graph .NET Controls >> Extending the Measurement Studio Graph .NET Controls >> Creating a Custom Plot for the Measurement Studio Scatter and Waveform Graph .NET Controls.
2. Example - <Meausurement Studio Folder>\DotNET\Examples\UI\Graph\Extensibility
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 4 of 7
(3,577 Views)
I wil give that a try this afternoon...Thanks!
0 Kudos
Message 5 of 7
(3,571 Views)

Abhishek,

When I call DrawFillsToBase, all of the existing data in the waveformgraph converts to the same color. It appears that I need to have a hook into DrawFillsToBase

to apply my desired color for all the points in the history...

Am I missing something?

Thanks again.

Dave

0 Kudos
Message 6 of 7
(3,566 Views)
What you are experiencing is expected behavior. DrawFillsToBase drawn the fill as the plot would honoring the current settings. This is provided as a convenience method for users who want to extend the plot by drawing it themselves. We do not call this method to draw the fills and therefore it is not overridable as overriding it would not have any effect on the drawing of the plot.
 
The idea is for you to call DrawFillsToBase as the very first thing in your event handler so that all the data (old and new) can be drawn with the plot's current fill color. Once that is done, you will need to fill the new data that you have saved with another color so that you can differentiate between the old and new data. Additionally, you will need to call the other Draw___ methods in order to get the rest of the plot to draw. You will also need to cancel the drawing of the plot by setting the Cancel property of the event args to prevent the plot from drawing itself over your drawing implementation.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 7 of 7
(3,542 Views)