0 Replies Latest reply on Mar 4, 2008 9:26 AM by jwbates

    Doing weird things with dataTipFormatFunction

      OK, so here's my little problem:

      I need to have a slider that spans a significant range of values. The range (if we're talking units of time) goes from one year all the way down to one second, with the difference between, say, five and ten seconds being about as significant as the difference between five and ten months.

      "Aha!" I cried to myself. "That just means that I need to use some of that fancy-dancy mathematics stuff that I learned in that big brick building I went to once!"

      And indeed, that's what I did: I put together a new component by just inheriting from VSlider and tacking on some methods to process slider.value as the input to a logarithmic scale. It's pretty cool, too. All I do is bind to my slider.time property and boom! I've got a slider that goes from a year to a second, with the user being able to make fine-grained adjustments easily.

      The only snafu popped up (quite literally) with the data tip, which still showed slider.value. Kinda broke the illusion. No problem: I just replaced dataTipFormatFunction with a function that discarded the old slider.value-based string and returned a new one based on my slider.time property. It even formatted it nicely, switching units from seconds to minutes to hours to days to months.

      But there's one last niggling problem. If I'm dragging the slider along with the data tip showing and a neighboring text field bound to slider.time, I get two different outputs. Dragging up the scale, for example, my bound text field will say six seconds, while the data tip still shows five. Releasing the thumb and clicking on it again at that point will show the data tip at six seconds, leading me to believe the following:

      1) The string with which dataTipFormatFunction() is called is based on the change event, *not* the slider.value, and
      2) dataTipFormatFunction() is getting called *before* the slider.value is assigned the new value.

      So first, is that a fair conclusion? Since my custom data tip function discards the old string and builds the new one based on a function that accesses slider.value, it seems like a reasonable guess.

      Second, anybody have any suggestions? I see two alternatives right now: disable data tips, or extract the number from the original string and pass it into a method that will re-scale it. The second option is just kinda kludgy, so I'll probably just kill the data tips, but I do like having the pop-up feedback available while the user is making fine-grained adjustments.

      Any other approaches? Am I missing something? Should I have gone into podiatry like my mother wanted?