Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the labeling of Major divisions on the XAxis of a Measurement Studio .NET WaveformGraph inconsistent between Log mode and Linear mode?

On an XAxis scale of range 30 to 300, in Linear mode the labels appear at every other major division. In Log mode, only one label appears (at 100) on the entire axis. Have tried various property settings, but same result. How can I make them consistent and can I specify the pattern in which they appear, e.g. on every 3rd line?
Using Measurement Studio .NET, C#.
Solutions please?
Thanks.
0 Kudos
Message 1 of 2
(4,141 Views)
You can see more minor division ticks if you set the XAxis.MinorDivisions.TickVisible property to true. Major division labels are shown for powers of 10 (actually, the value of the LogBase property, which is 10 by default), which is why you only see 100 for your current range. This is the most common use case for a log scale axis. Also, depending on what your range is, major divisions at larger intervals can be displayed closer together than with a linear scale, which could result in the labels overlapping.

You can explicitly setup divisions to display wherever you like by setting the XAxis.MajorDivisions.TickVisible property to false and the XAxis.MajorDivisions.LabelVisible property to false, then add custom divisions to the CustomDivisions property. For example, check out the example GenerateCustomDivisions method below. To test it similar to how you specified with a major division interval of 100 and 3 minor divisions between each major division, you can drop a new graph on the form and use this code:

// Specify the range and a logarithmic scale as specified in your post.
Axis axis = xAxis1;
axis.ScaleType = ScaleType.Logarithmic;
axis.Range = new Range(30, 300);

// Generate a set of custom divisions with major division intervals at 100 and
// 3 minor divisions between each major division.
GenerateCustomDivisions(axis, 100, 3);

Here's the example code for the GenerateCustomDivisions method:

static void GenerateCustomDivisions(Axis axis, double majorInterval, int minorCount)
{
if (axis == null)
throw new ArgumentNullException("axis");

if (minorCount <= 0)
throw new ArgumentOutOfRangeException("minorCount");

// Define some constants that will be used for creating the custom divisions.
const float MajorDivisionTickLength = 5.0f;
const float MinorDivisionTickLength = 3.0f;
Color tickColor = Color.Black;

XYGraph graph = axis.Owner as XYGraph;
try
{
// Call BeginUpdate so the graph will only redraw once instead of for
// every property that's changed and every division that's added.
if (graph != null)
graph.BeginUpdate();

// Reset the divisions to a default known state.
axis.MajorDivisions.LabelVisible = false;
axis.MajorDivisions.TickVisible = axis.MinorDivisions.TickVisible = false;
axis.CustomDivisions.Clear();

Range range = axis.Range;
double lowerBound = range.Minimum;
double upperBound = range.Maximum;

double minorInterval = majorInterval / (minorCount + 1);
for (double major = lowerBound; major <= upperBound; major += majorInterval)
{
// Add the major custom divisions.
AxisCustomDivision majorDivision = new AxisCustomDivision(major);
majorDivision.TickColor = tickColor;
majorDivision.TickLength = MajorDivisionTickLength;
axis.CustomDivisions.Add(majorDivision);

// Add the minor custom divisions.
double minor = major + minorInterval;
for (int i = 0; i < minorCount; ++i, minor += minorInterval)
{
AxisCustomDivision minorDivision = new AxisCustomDivision(minor, String.Empty);
minorDivision.TickColor = tickColor;
minorDivision.TickLength = MinorDivisionTickLength;
axis.CustomDivisions.Add(minorDivision);
}
}
}
finally
{
if (graph != null)
graph.EndUpdate();
}
}

Please try this out and see if this does what you're looking for.

- Elton
0 Kudos
Message 2 of 2
(4,141 Views)