Change pivot point on needle

Gauge for WPF Forum

The latest build of this product (v21.1.3) was released 3 months ago, which was before this thread was created.
Posted 12 days ago by Brian Post
Version: 19.1.0687
Avatar

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

Comments (3)

Posted 9 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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">
	<gauge:CircularPointerNeedle.RenderTransform>
		<TranslateTransform X="25" Y="0" />
	</gauge:CircularPointerNeedle.RenderTransform>
</gauge:CircularPointerNeedle>


Actipro Software Support

Posted 9 days ago by Brian Post
Avatar

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 9 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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

Add Comment

Please log in to a validated account to post comments.