I wrote the following code:

Manipulate[HorizontalGauge[Dynamic[x], {0, range}], {range, 5, 10}]

I want to plot a HorizontalGauge with dynamic range, but the marker of the HorizontalGauge does not respond to dragging, I could only click on the axis to change value of x, how to fix it? enter image description here

  • 1
    $\begingroup$ TrackedSymbols :> {range} will fix the problem with dragging it, but it is unlikely to work for what you want to do. $\endgroup$
    – C. E.
    Sep 14, 2020 at 8:30
  • $\begingroup$ Thanks, it works if it's wrapped with Manipulate[], but what if there is no Manipulate, just HorizontalGauge[], and "range" is a value varying with another function, i wrote "Dynamic[range]", but it didn't work. $\endgroup$
    – DORA
    Sep 14, 2020 at 8:59
  • $\begingroup$ i add a picture to explain what i meant, if i change the value of "range" by the Slider[], the HorizontalGauge dosn't work when i drag it. $\endgroup$
    – DORA
    Sep 14, 2020 at 9:08

1 Answer 1

Dynamic[HorizontalGauge[Dynamic[x], {0, range}], TrackedSymbols :> {range}]

Slider[Dynamic[range], {5, 50}]

enter image description here

  • $\begingroup$ Thanks, TrackedSymbols is one of my problems, i found out another, i put the calculation of "range" in the Graphics[] which controlled by Dynamic[x], now it's solved. $\endgroup$
    – DORA
    Sep 15, 2020 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.