ArrowIndicator Event Handling in Dojo

Go To StackoverFlow.com

1

I have a gauge chart which has one arrowIndicator. Im trying to capture the value change event on the arrowIndicator. I tried dojo.connect() and on() methods to set the event handler for my gauge but failed both times. This is what I did...

var arrow = new dojox.gauges.AnalogArrowIndicator({....});

dojo.connect(arrow, 'change', handlerFunction);

AND

var arrow = new dojox.gauges.AnalogArrowIndicator({....});
define(["dojo/on"], function(on){
on(arrow, "change", myHandleFunction);
});

I don't get any error message or anything... How should I go about this?

2012-04-05 00:05
by lascort


2

the valuechange event is exposed at the guage chart level:

dojo.connect(gauge.indicators[0], "valueChanged", dojo.hitch(gauge, function(){
  //new value is in this.indicators[0].value
}));

where, gauge is the jsid or js variable holding the gauge dijit

depending on how you are adding the indicators, it might be indicators[1] or similar

2012-04-05 00:21
by Vijay Agrawal
Awesome!! This are my first steps in Dojo and its kinda confusing. THANKS - lascort 2012-04-06 15:01
Great - happy to help. Yes, there is lots in there and though the dojo developers try to document things, there are hidden features/gems still there to be discovered :-).. A combination of dojo nightly tests, looking into the source code and the wiki/docs will equip you with all you need - also dojo is completely extensible, so you can override portions of the widgets and extend them. - Vijay Agrawal 2012-04-06 16:32
Since we're on the subject. How do I go about changing the gauge value programmatically? I tried both gauge.indicators[0].set('value', myValue) and gauge.set('value', myValue - lascort 2012-04-06 20:15
also tried 'currentValue' instead of 'value - lascort 2012-04-06 20:15
actually the indicator seems to expose an update() method. See http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/gauges/tests/test_AnalogGaugeWidget.html for an example of setting a value. Also the tests at: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/gauges/tests/ is a good place to look for features and example - Vijay Agrawal 2012-04-06 20:23
nothing... I mean maybe I'm missing some update on rendering or something. I debugged and I see value = myValue on the indicator object but the gauge chart doesn't move to myValue at all. Maybe some refresh or update missing - lascort 2012-04-06 20:27
i just edited my answer - Vijay Agrawal 2012-04-06 20:28
thanks again!! - lascort 2012-04-06 20:34
Ads