11-12-2012 04:31 AM
I would like to hide the default first and last major division marker in an axes of a WPF graph. I tried to extend RangeDivisionsMode and set my own class object to the MajorDivisions.Mode property on the axis. But even when I return an empty list in RangeDivisionsMode.GetDivisions<TData>(...), the first and last marker is drawn.
Thanks in advance, Jonas
Solved! Go to Solution.
11-12-2012 01:33 PM
The minimum and maximum labels are handeled separately when displaying a scale (though the custom RangeDivisionsMode
technique can be used for the minor divisions).
There is no direct configuration option to hide the extreme labels, but you can achieve this effect by initializing the LabelPresenter
property on MajorDivisions
with a custom implementation:
class CustomFormatter : GeneralValueFormatter {
protected override UIElement VisualizeCore<TData>( TData value, ValuePresenterArgs args, UIElement existingVisual ) {
UIElement element = base.VisualizeCore<TData>( value, args, existingVisual );
var axis = (Axis<TData>)args.Context;
Range<TData> range = axis.Range;
var comparer = range.Comparer;
bool isExtreme =
comparer.Compare( range.Minimum, value ) == 0
|| comparer.Compare( range.Maximum, value ) == 0;
element.Opacity = isExtreme ? 0.0 : 1.0;
return element;
}
}
11-13-2012 10:01 AM
Thank you
11-15-2012 03:28 AM - edited 11-15-2012 03:37 AM
Hi Paul,
just another question concerning RangeDivisionsMode. In VisualizeCore I may create a TextBlock and apply some styling on it. But I can't figure out where the positioning is done. Is there any documentation about extending the default classes? I want to achieve a right-aligned maximum label and a left-aligned minimum label. The width of the axis should equal the window width and should not depend on the min/max label size.
Thanks, Jonas
11-15-2012 09:56 AM
The short answer to your question is to replace the opacity setting with this:
RelativeAlignment alignment =
comparer.Compare( range.Minimum, value ) == 0 ? RelativeAlignment.Near :
comparer.Compare( range.Maximum, value ) == 0 ? RelativeAlignment.Far :
RelativeAlignment.Center;
RegionPanel.SetRelativeHorizontalAlignment( element, alignment );
The longer answer is that, for the first version of the WPF controls, we intentionally left many of the underlying primitive types with minimal documentation, as we may change them in the future. In the current implementation, we use RegionPanel
and attached properties like RelativeHorizontalAlignment
to perform the layout for many of our controls. Although these exact members may be removed in a later release, we do plan to provide equivalent functionality and stabilize the primitive API over time.
Besides that caveat, I hope you find this answer useful 🙂
08-11-2015 10:52 AM
Just wanted to let you know we have added new MinimumLabelAlignment
and MaximumLabelAlignment
properties in the Measurement Studio 2015 release.