03-06-2015 09:15 PM
I need to figure out how to draw text onto a waveform chart at runtime. This could be a text box, a label, an image of text, an additional plot with text .... etc.
Yes, I know a graph would be better for this, but I have to use a chart for my application.
The chart updates every second, and the new data is added to the chart history. (Meaning the chart grows larger every second) So If I draw the text over top, or behind the chart, I will have to update their location every second. I will have to use Map Coords to XY in a mousedown (or mouseup) event to place the text (or image of text) onto the plot where the user clicks it.
Step 1 to solving this problem is figuring out first, how to draw or place text on the chart plot area.
Does anyone have any ideas how this could be accomplished, or some ideas of a sneaky work around to make this work?
Example:
Solved! Go to Solution.
03-06-2015 09:34 PM - edited 03-06-2015 09:35 PM
Unfortunately, Graphs (Waveform Graph and XY Graph) have Annotation and Cursor support, exposed programmatically via Properties, but the Waveform Chart does not.
What you could do is place a 2D Picture indicator that matches the size of the chart over it. Then make the value of the picture that you draw there be all transparent and just draw text with transparent backgrounds. However, I do not know the performance considerations of this - many times, UI elements overlapping each other (even transparent portions) can cause performance issues due to forcing redraws ... then again maybe a graph is always being redrawn anyway.
03-06-2015 10:17 PM
If I place something over the chart, I will be unable to use the "Value at Cursor" feature that I have written. (see below)
So I will need to find a solution that doesn't involve covering up the chart. There has to be a way to draw directly on to the chart, or behind it, or add additional plots that contain text.....
03-06-2015 10:43 PM - edited 03-06-2015 10:44 PM
Step 1 to solving this problem is figuring out first, how to draw or place text on the chart plot area.
But all I was asked was for a solution to Step 1!
As for getting the location to draw at when you click:
03-06-2015 10:56 PM
hah I should have been more specific....when drawing on the chart plot area....i don't mean covering the whole thing up...I mean add small text labels or small images of text at certian coords on the plot area!
I suppose the reverse would also be true......
If I placed the image behind a transparent chart (as long as the image and chart plot area are the same dimensions) I could use the existing mouse down xy function to place the text.
I guess my next question would be how does one go about programatically drawing text on to an image?
03-06-2015 11:06 PM
hah I should have been more specific....when drawing on the chart plot area....i don't mean covering the whole thing up...I mean add small text labels or small images of text at certian coords on the plot area!
I suppose the reverse would also be true......
If I placed the image behind a transparent chart (as long as the image and chart plot area are the same dimensions) I could use the existing mouse down xy function to place the text.
I would leave the chart as it is and have the picture be the transparent one.
I guess my next question would be how does one go about programatically drawing text on to an image?
Take a look at the Programming -> Graphics & Sound -> Picture Functions palette.
03-06-2015 11:13 PM
Thanks for the suggestion...I'll give that a go.....
Hopefully someone sees this post and has another Idea I can try if this doesn't work out.
03-06-2015 11:31 PM
Attached is an example VI.
Note that there is a Picture Indicator on top of the Waveform Chart's plot area. The picture is entirely transparent by default (and it is reinitialized to be a transparent picture every time you run).
Note that the coordinates should be as you expect them for your use before; however, when specifying where to draw items on the picture, you have to specify in picture coordinates and not in pane coordinates, as you can see I did by subtracting the Picture's position (pane coordinates) from the mouse event position (pane coordinates) to get the relative position (picture coordinates).
03-07-2015 12:18 AM
Thanks this is very helpfull start.
03-07-2015 08:55 AM