PlotAction.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. define("dojox/charting/action2d/PlotAction", ["dojo/_base/connect", "dojo/_base/declare", "./Base", "dojo/fx/easing", "dojox/lang/functional",
  2. "dojox/lang/functional/object"],
  3. function(hub, declare, Base, dfe, df, dlfo){
  4. /*=====
  5. dojox.charting.action2d.__PlotActionCtorArgs = function(duration, easing){
  6. // summary:
  7. // The base keyword arguments object for creating an action2d.
  8. // duration: Number?
  9. // The amount of time in milliseconds for an animation to last. Default is 400.
  10. // easing: dojo.fx.easing.*?
  11. // An easing object (see dojo.fx.easing) for use in an animation. The
  12. // default is dojo.fx.easing.backOut.
  13. this.duration = duration;
  14. this.easing = easing;
  15. }
  16. var Base = dojox.charting.action2d.Base;
  17. =====*/
  18. var DEFAULT_DURATION = 400, // ms
  19. DEFAULT_EASING = dfe.backOut;
  20. return declare("dojox.charting.action2d.PlotAction", Base, {
  21. // summary:
  22. // Base action class for plot actions.
  23. overOutEvents: {onmouseover: 1, onmouseout: 1},
  24. constructor: function(chart, plot, kwargs){
  25. // summary:
  26. // Create a new base PlotAction.
  27. // chart: dojox.charting.Chart
  28. // The chart this action applies to.
  29. // plot: String?
  30. // The name of the plot this action belongs to. If none is passed "default" is assumed.
  31. // kwargs: dojox.charting.action2d.__PlotActionCtorArgs?
  32. // Optional arguments for the action.
  33. this.anim = {};
  34. // process common optional named parameters
  35. if(!kwargs){ kwargs = {}; }
  36. this.duration = kwargs.duration ? kwargs.duration : DEFAULT_DURATION;
  37. this.easing = kwargs.easing ? kwargs.easing : DEFAULT_EASING;
  38. },
  39. connect: function(){
  40. // summary:
  41. // Connect this action to the given plot.
  42. this.handle = this.chart.connectToPlot(this.plot.name, this, "process");
  43. },
  44. disconnect: function(){
  45. // summary:
  46. // Disconnect this action from the given plot, if connected.
  47. if(this.handle){
  48. hub.disconnect(this.handle);
  49. this.handle = null;
  50. }
  51. },
  52. reset: function(){
  53. // summary:
  54. // Reset the action.
  55. },
  56. destroy: function(){
  57. // summary:
  58. // Do any cleanup needed when destroying parent elements.
  59. this.inherited(arguments);
  60. df.forIn(this.anim, function(o){
  61. df.forIn(o, function(anim){
  62. anim.action.stop(true);
  63. });
  64. });
  65. this.anim = {};
  66. }
  67. });
  68. });