dojox/charting/action2d/Tooltip.js

  • Provides:

    • dojox.charting.action2d.Tooltip
  • Requires:

    • dijit.Tooltip in common in project dijit
    • dojox.charting.action2d.Base in common
    • dojox.gfx.matrix in common
    • dojox.lang.functional in common
    • dojox.lang.functional.scan in common
    • dojox.lang.functional.fold in common
  • dojox.charting.action2d.__TooltipCtorArgs

    • type
      Function
    • chains:
      • dojox.charting.action2d.__BaseCtorArgs: (prototype)
      • dojox.charting.action2d.__BaseCtorArgs: (call)
    • summary
      Additional arguments for tooltip actions.
  • dojox.charting.action2d.__TooltipCtorArgs.text

    • type
      Function
    • summary
      The function that produces the text to be shown within a tooltip.  By default this will be
      set by the plot in question, by returning the value of the element.
  • dojox.charting.action2d.Tooltip

    • type
      Function
    • chains:
      • dojox.charting.action2d.Base: (prototype)
      • dojox.charting.action2d.Base: (call)
    • parameters:
      • chart: (typeof dojox.charting.Chart2D)
        The chart this action belongs to.
      • plot: (typeof String)
        The plot this action is attached to.  If not passed, "default" is assumed.
      • kwArgs: (typeof dojox.charting.action2d.__TooltipCtorArgs)
        Optional keyword arguments object for setting parameters.
    • source: [view]
         this.text = kwArgs && kwArgs.text ? kwArgs.text : DEFAULT_TEXT;

         
         this.connect();
    • summary
      Create the tooltip action and connect it to the plot.
  • dojox.charting.action2d.Tooltip.defaultParams

    • type
      Object
    • summary
  • dojox.charting.action2d.Tooltip.optionalParams

    • type
      Object
    • summary
  • dojox.charting.action2d.Tooltip.process

    • type
      Function
    • parameters:
      • o: (typeof dojox.gfx.Shape)
        The object on which to process the highlighting action.
    • source: [view]
         if(o.type === "onplotreset" || o.type === "onmouseout"){
      dijit.hideTooltip(this.aroundRect);
          this.aroundRect = null;
          if(o.type === "onplotreset"){
           delete this.angles;
          }
          return;
         }

         
         if(!o.shape || o.type !== "onmouseover"){ return; }

         
         // calculate relative coordinates and the position
         var aroundRect = {type: "rect"}, position = ["after", "before"];
         switch(o.element){
          case "marker":
           aroundRect.x = o.cx;
           aroundRect.y = o.cy;
           aroundRect.width = aroundRect.height = 1;
           break;
          case "circle":
           aroundRect.x = o.cx - o.cr;
           aroundRect.y = o.cy - o.cr;
           aroundRect.width = aroundRect.height = 2 * o.cr;
           break;
          case "column":
           position = ["above", "below"];
           // intentional fall down
          case "bar":
           aroundRect = dojo.clone(o.shape.getShape());
           break;
          case "candlestick":
           aroundRect.x = o.x;
           aroundRect.y = o.y;
           aroundRect.width = o.width;
           aroundRect.height = o.height;
           break;
          default:
          //case "slice":
           if(!this.angles){
            // calculate the running total of slice angles
            if(typeof o.run.data[0] == "number"){
             this.angles = df.map(df.scanl(o.run.data, "+", 0),
              "* 2 * Math.PI / this", df.foldl(o.run.data, "+", 0));
            }else{
             this.angles = df.map(df.scanl(o.run.data, "a + b.y", 0),
              "* 2 * Math.PI / this", df.foldl(o.run.data, "a + b.y", 0));
            }
           }
           var startAngle = m._degToRad(o.plot.opt.startAngle),
            angle = (this.angles[o.index] + this.angles[o.index + 1]) / 2 + startAngle;
           aroundRect.x = o.cx + o.cr * Math.cos(angle);
           aroundRect.y = o.cy + o.cr * Math.sin(angle);
           aroundRect.width = aroundRect.height = 1;
           // calculate the position
           if(angle < pi4){
            // do nothing: the position is right
           }else if(angle < pi2 + pi4){
            position = ["below", "above"];
           }else if(angle < Math.PI + pi4){
            position = ["before", "after"];
           }else if(angle < 2 * Math.PI - pi4){
            position = ["above", "below"];
           }
           /*
           else{
            // do nothing: the position is right
           }
           */
           break;
         }

         
         // adjust relative coordinates to absolute, and remove fractions
         var lt = dojo.coords(this.chart.node, true);
         aroundRect.x += lt.x;
         aroundRect.y += lt.y;
         aroundRect.x = Math.round(aroundRect.x);
         aroundRect.y = Math.round(aroundRect.y);
         aroundRect.width = Math.ceil(aroundRect.width);
         aroundRect.height = Math.ceil(aroundRect.height);
         this.aroundRect = aroundRect;


         var tooltip = this.text(o);
         if(tooltip){
      dijit.showTooltip(tooltip, this.aroundRect, position);
         }
    • summary
      Process the action on the given object.
  • dojox.charting.action2d.Tooltip.defaultParams.text

    • summary
  • dojox.charting.action2d.Tooltip.aroundRect

    • summary
  • dojox.charting.action2d.Tooltip.angles

    • summary
  • dojox.charting.action2d.Tooltip.text

    • summary
  • dojox.charting.action2d

    • type
      Object
    • summary
  • dojox.charting

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary