Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically assign tooltip for data points in run chart

I calculate the RMS value for every waveform acquired, then plot the RMS value using

waveformPlotRMS.PlotYAppend(valueRMS);

I set the tooltip property to be TRUE so that the X and Y values are displayed when I move the mouse over the data point in the plot area.

My question is:

How can I replace the X value string with waveform file name in C#?
0 Kudos
Message 1 of 9
(5,749 Views)
Hi JSlnc,
 
Unfortunately, the Tooltip object used by Plot is not exposed.
 
However, the quickest and easiest way to implement the feature you desire is by using a string literal in the ToolTipXFormat property. Normally, the value for this property is "F0" to represent a numeric, but you can certainly give it a string value to interpret literally.
 
You can do this by creating a custom FormatString class that overwrites the FormatDouble method. The FormatDouble method allows the user to change the return value that the tooltip displays for the X-axis. Assuming you know how your data is organized, you can place conditions in the method to return the correct information.
 
Shown below is a snippet of the custom class. Note that the variable value in FormatDouble() refers to the index of our data array. I have also attached a VStudio 2005 C# example using this class.
 
class CustomFormatString : FormatString
    {
        public override string FormatDouble(double value)
        {
            // The variable, value, refers to the index number of the data array
            if (value >= 2)
                return "Waveform 2"; //All data above index 1 is from Waveform 2
            else
                return "Waveform 1"; //All data below index 2 is from Waveform 1
        }
    }
 
Hope this helps!
Nestor
0 Kudos
Message 2 of 9
(5,717 Views)

Hello Nestor,

 

Thank you for your reply and the example.

 

I have a dumb question:

How can I pass the waveform file name through a string variable to the tooltip?

 

Best regards,

 

JSInc

 

 

0 Kudos
Message 3 of 9
(5,653 Views)
Because the process is automated regardless of the index or data, the easiest way would be to use a string global variable.
Nestor
0 Kudos
Message 4 of 9
(5,649 Views)

Hello Nestor,

 

Thank you for your quick response.

 

I tried using a string global variable as attached project.  The X tooltip for every data point seems the same. What did I do wrong?

 

Thanks,

 

JSInc

0 Kudos
Message 5 of 9
(5,642 Views)
HI JSInc,
 
Unfortunately, the tooltip cannot be used in the manner being used in your application. It seems that you are assuming that a tooltip object will be created for each data point; this is not true. The object, and hence the FormatDouble(), are only called when hovering above a data point. Recall that the tooltip is unaware of index specific information - it will only get the value for the respective data point while hovering.
 
Hence, in the example above, I made assumptions in the FormatDouble() that any X-value above a threshold belongs to a certain group and anything else belongs to another group.
Is it possible for you to make such assumptions?
Nestor
0 Kudos
Message 6 of 9
(5,618 Views)

Nestor,

 

Unfortunately, I can not make the assumption that any X-value belongs to a certain group.

 

Anyway, thank you for your time.

Have a great day!

 

 

JSInc

0 Kudos
Message 7 of 9
(5,616 Views)

Hello Nestor,

 

Thank you for your explaination. I do a little bit modification and solve the problem.

 

Since I only keep 1000 history data points in the run chart, I create a string array of 1000 length to store the waveform file name, I then use FormatDouble() to index the string array.

 

I am attaching my project to this post in case somebody has the same problem.

 

Thanks,

 

JSInc

0 Kudos
Message 8 of 9
(5,611 Views)

Nicely done JSInc! Good workaround.

Nestor
0 Kudos
Message 9 of 9
(5,605 Views)