Change pivot point on needle

Gauge for WPF Forum

Posted 3 years ago by Brian Post
Version: 19.1.0687

Is there a way to change the pivot point on a gauge needle?

Comments (3)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Brian,

The pivot point for the CircularPointerNeedle is fixed at the center of the guage element (based on actual width/height). If you want to move the pivot point, you could apply a TranslateTransform to the needle element.  For example, the following modification was made to our Circular Gauge Dampening QuickStart in our Sample Browser to move the needle 25 pixels to the right of center.

<gauge:CircularPointerNeedle x:Name="needle" NeedleType="PivotTriangleBlunt"
		PointerExtent="80" PointerAscent="10"
		Background="{shared:LinearGradientBrush #3E3D48, #1B193E, GradientType=LeftToRight}"
		BorderBrush="#9D9CAF" BorderWidth="1">
		<TranslateTransform X="25" Y="0" />

Actipro Software Support

Posted 3 years ago by Brian Post

I've tried that and it's not really what I'm looking for. That just shifts the needle basically. The needle is still pivoting from it's end point. I'm trying to move the pivot point let's say to the center of the needle and have it rotate around that. I've also tried shifting the transform origin. There exist some sample needles with pivot in the name. I basically want it like that, just without want the dot in the middle. Will I have to create a custom image or something?

Answer - Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA

Thank you for the follow up. I didn't fully understand the original question, but do now. The needles you mention with "Pivot" in the name are all rendered with a fixed pivot point. You would need to use a custom image or geometry to have a needle pivot at a different location.

Any custom image/geometry is going to render in the center of the gauge and is then rotated to match the current value. It will always pivot in the middle of the image/geometry. But you can still provide the illusion of a different pivot point.

Assume you had an image that was 1 pixel high and 20 pixels wide. If you used that as a needle, it would always pivot in the middle where 10 pixels appeared to the right of the pivot point and 10 pixels appeared to the left of the pivot point. Now imagine you keep the image 20 pixels wide, but the left-most 10 pixels are transparent and only the right-most pixels have color. The image will still technically pivot in the middle, but you won't see the 10 transparent pixels to the left of the pivot... only the 10 pixels to the right of the pivot. So now your image looks like it is pivoting on edge of the visible image.  If you use different amounts of padding on the image you can alter where you image appears to be pivoting. Same concept can be applied to a custom geometry.

Another option would be to create your own class that derives from "CircularPointerBase" and override "OnRender" to draw the needle any way you desire. If you do this, you will have to not only draw the needle but also make sure it is rotated to the correct position.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.