Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scatter Graph, Hex Display?

Is it possible to display the numbers on an axis as hexadecimal?

Thanks in advance for the help,
Dennis
0 Kudos
Message 1 of 5
(3,634 Views)
It is possible, but unfortunately it is not as easy as you might expect. The problem is that ScatterGraph uses the .NET Framework NumberFormatInfo class to format the axis labels. This gives you the ability to leverage all of the .NET Framework's formatting capabilities in formatting your axis, but NumberFormatInfo throws a FormatException if you try to use it to format a double into a hexadecimal formatted string. The axis values are doubles, therefore, you can not simple create a FormatString with a hexadecimal format specifier.

You can work around this by creating a class that derives from FormatString, override FormatDouble, and format the value yourself. For example, you could cast the double value to an integer and format it into a hexadecimal formatted string, like this:


class HexLabelFormat : FormatString
{
public override string FormatDouble(double value)
{
return String.Format("0x{0:X2}", (int)value);
}
}


You could then specify this as your axis label format like this:


xAxis1.MajorDivisions.LabelFormat = new HexLabelFormat();


Once the label format has been set to the custom FormatString implementation, the labels on the axis will be displayed in hexadecimal.

- Elton
0 Kudos
Message 2 of 5
(3,632 Views)
Hello Elton,
Thank you for your excellent response to this question!
I am very pleased to see that it's possible. I'll try it out tomorrow.
Best regards,
Dennis
0 Kudos
Message 3 of 5
(3,628 Views)
Hello Elton,
Sorry, but I'm having trouble getting this to work. FormatDouble() does not seem to be a method in the FormatString class.
Also, because FormatString has only one constructor,
public FormatString(FormatStringMode mode,string format);
then I would need to implement a similar constructor for my derived class. Right? When instantiating my derived class, are both
constructor arguments significant?

Thanks again for your help,
Dennis

Note: I'm using C#, MS V7.0
0 Kudos
Message 4 of 5
(3,627 Views)
Sorry, I was assuming that you were using Measurement Studio 7.1. A protected default constructor and the virtual FormatDouble method were added to the public API in Measurement Studio 7.1. There's not a way to do this in Measurement Studio 7.0.

- Elton
0 Kudos
Message 5 of 5
(3,621 Views)