dojox/charting/plot2d/Base.js

  • Provides:

    • dojox.charting.plot2d.Base
  • Requires:

    • dojox.charting.scaler.primitive in common
    • dojox.charting.Element in common
    • dojox.charting.plot2d.common in common
    • dojox.charting.plot2d._PlotEvents in common
  • dojox.charting.plot2d.Base

    • type
      Function
    • chains:
      • dojox.charting.Element: (prototype)
      • dojox.charting.Element: (call)
      • dojox.charting.plot2d._PlotEvents: (call)
    • mixins:
      • dojox.charting.plot2d._PlotEvents.prototype: (prototype)
    • parameters:
      • chart: (typeof dojox.chart.Chart2D)
        The chart this plot belongs to.
      • kwArgs: (typeof dojox.charting.plot2d.__PlotCtorArgs)
        An optional arguments object to help define the plot.
    • source: [view]
        this.zoom = null,
        this.zoomQueue = []; // zooming action task queue
        this.lastWindow = {vscale: 1, hscale: 1, xoffset: 0, yoffset: 0};
    • summary
      Create a base plot for charting.
  • dojox.charting.plot2d.Base.clear

    • type
      Function
    • source: [view]
        this.series = [];
        this._hAxis = null;
        this._vAxis = null;
        this.dirty = true;
        return this; // dojox.charting.plot2d.Base
    • summary
      Clear out all of the information tied to this plot.
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.setAxis

    • type
      Function
    • parameters:
      • axis: (typeof dojox.charting.axis2d.Base)
        The axis to set.
    • source: [view]
        if(axis){
         this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
        }
        return this; // dojox.charting.plot2d.Base
    • summary
      Set an axis for this plot.
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.addSeries

    • type
      Function
    • parameters:
      • run: (typeof dojox.charting.Series)
        The series to be added.
    • source: [view]
        this.series.push(run);
        return this; // dojox.charting.plot2d.Base
    • summary
      Add a data series to this plot.
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.getSeriesStats

    • type
      Function
    • source: [view]
        return dojox.charting.plot2d.common.collectSimpleStats(this.series);
    • summary
      Calculate the min/max on all attached series in both directions.
    • return_summary
      Object
      {hmin, hmax, vmin, vmax} min/max in both directions.
  • dojox.charting.plot2d.Base.calculateAxes

    • type
      Function
    • parameters:
      • dim: (typeof Object)
        An object of the form { width, height }
    • source: [view]
        this.initializeScalers(dim, this.getSeriesStats());
        return this; // dojox.charting.plot2d.Base
    • summary
      Stub function for running the axis calculations (depricated).
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.isDirty

    • type
      Function
    • source: [view]
        return this.dirty || this._hAxis && this._hAxis.dirty || this._vAxis && this._vAxis.dirty; // Boolean
    • summary
      Returns whether or not this plot needs to be rendered.
    • return_summary
      Boolean
      The state of the plot.
    • returns
      Boolean
  • dojox.charting.plot2d.Base.isDataDirty

    • type
      Function
    • source: [view]
        return dojo.some(this.series, function(item){ return item.dirty; }); // Boolean
    • summary
      Returns whether or not any of this plot's data series need to be rendered.
    • return_summary
      Boolean
      Flag indicating if any of this plot's series are invalid and need rendering.
    • returns
      Boolean
  • dojox.charting.plot2d.Base.performZoom

    • type
      Function
    • parameters:
      • dim: (typeof Object)
        An object of the form { width, height }.
      • offsets: (typeof Object)
        An object of the form { l, r, t, b }.
    • source: [view]
      dojo.provide("dojox.charting.plot2d.Base");


      dojo.require("dojox.charting.scaler.primitive");
      dojo.require("dojox.charting.Element");
      dojo.require("dojox.charting.plot2d.common");
      dojo.require("dojox.charting.plot2d._PlotEvents");




      dojox.charting.plot2d.__PlotCtorArgs = function(){
       // summary:
       //  The base keyword arguments object for plot constructors.
       //  Note that the parameters for this may change based on the
       //  specific plot type (see the corresponding plot type for
       //  details).
      }


      dojo.declare("dojox.charting.plot2d.Base", [dojox.charting.Element, dojox.charting.plot2d._PlotEvents], {
       constructor: function(chart, kwArgs){
        // summary:
        //  Create a base plot for charting.
        // chart: dojox.chart.Chart2D
        //  The chart this plot belongs to.
        // kwArgs: dojox.charting.plot2d.__PlotCtorArgs?
        //  An optional arguments object to help define the plot.
        this.zoom = null,
        this.zoomQueue = []; // zooming action task queue
        this.lastWindow = {vscale: 1, hscale: 1, xoffset: 0, yoffset: 0};
       },
       clear: function(){
        // summary:
        //  Clear out all of the information tied to this plot.
        // returns: dojox.charting.plot2d.Base
        //  A reference to this plot for functional chaining.
        this.series = [];
        this._hAxis = null;
        this._vAxis = null;
        this.dirty = true;
        return this; // dojox.charting.plot2d.Base
       },
       setAxis: function(axis){
        // summary:
        //  Set an axis for this plot.
        // axis: dojox.charting.axis2d.Base
        //  The axis to set.
        // returns: dojox.charting.plot2d.Base
        //  A reference to this plot for functional chaining.
        if(axis){
         this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
        }
        return this; // dojox.charting.plot2d.Base
       },
       addSeries: function(run){
        // summary:
        //  Add a data series to this plot.
        // run: dojox.charting.Series
        //  The series to be added.
        // returns: dojox.charting.plot2d.Base
        //  A reference to this plot for functional chaining.
        this.series.push(run);
        return this; // dojox.charting.plot2d.Base
       },
       getSeriesStats: function(){
        // summary:
        //  Calculate the min/max on all attached series in both directions.
        // returns: Object
        //  {hmin, hmax, vmin, vmax} min/max in both directions.
        return dojox.charting.plot2d.common.collectSimpleStats(this.series);
       },
       calculateAxes: function(dim){
        // summary:
        //  Stub function for running the axis calculations (depricated).
        // dim: Object
        //  An object of the form { width, height }
        // returns: dojox.charting.plot2d.Base
        //  A reference to this plot for functional chaining.
        this.initializeScalers(dim, this.getSeriesStats());
        return this; // dojox.charting.plot2d.Base
       },
       isDirty: function(){
        // summary:
        //  Returns whether or not this plot needs to be rendered.
        // returns: Boolean
        //  The state of the plot.
        return this.dirty || this._hAxis && this._hAxis.dirty || this._vAxis && this._vAxis.dirty; // Boolean
       },
       isDataDirty: function(){
        // summary:
        //  Returns whether or not any of this plot's data series need to be rendered.
        // returns: Boolean
        //  Flag indicating if any of this plot's series are invalid and need rendering.
        return dojo.some(this.series, function(item){ return item.dirty; }); // Boolean
       },
       performZoom: function(dim, offsets){
        // summary:
        //  Create/alter any zooming windows on this plot.
        // dim: Object
        //  An object of the form { width, height }.
        // offsets: Object
        //  An object of the form { l, r, t, b }.
        // returns: dojox.charting.plot2d.Base
        //  A reference to this plot for functional chaining.


        // get current zooming various
        var vs = this._vAxis.scale || 1,
         hs = this._hAxis.scale || 1,
         vOffset = dim.height - offsets.b,
         hBounds = this._hScaler.bounds,
         xOffset = (hBounds.from - hBounds.lower) * hBounds.scale,
         vBounds = this._vScaler.bounds,
         yOffset = (vBounds.from - vBounds.lower) * vBounds.scale;
         // get incremental zooming various
         rVScale = vs / this.lastWindow.vscale,
         rHScale = hs / this.lastWindow.hscale,
         rXOffset = (this.lastWindow.xoffset - xOffset)/
          ((this.lastWindow.hscale == 1)? hs : this.lastWindow.hscale),
         rYOffset = (yOffset - this.lastWindow.yoffset)/
          ((this.lastWindow.vscale == 1)? vs : this.lastWindow.vscale),


         shape = this.group,
         anim = dojox.gfx.fx.animateTransform(dojo.delegate({
          shape: shape,
          duration: 1200,
          transform:[
           {name:"translate", start:[0, 0], end: [offsets.l * (1 - rHScale), vOffset * (1 - rVScale)]},
           {name:"scale", start:[1, 1], end: [rHScale, rVScale]},
           {name:"original"},
           {name:"translate", start: [0, 0], end: [rXOffset, rYOffset]}
          ]}, this.zoom));


        dojo.mixin(this.lastWindow, {vscale: vs, hscale: hs, xoffset: xOffset, yoffset: yOffset});
        //add anim to zooming action queue,
        //in order to avoid several zooming action happened at the same time
        this.zoomQueue.push(anim);
        //perform each anim one by one in zoomQueue
        dojo.connect(anim, "onEnd", this, function(){
         this.zoom = null;
         this.zoomQueue.shift();
         if(this.zoomQueue.length > 0){
          this.zoomQueue[0].play();
         }
        });
        if(this.zoomQueue.length == 1){
         this.zoomQueue[0].play();
        }
        return this; // dojox.charting.plot2d.Base
    • summary
      Create/alter any zooming windows on this plot.
    • returns
      dojox.charting.plot2d.Base|Boolean
  • dojox.charting.plot2d.Base.render

    • type
      Function
    • parameters:
      • dim: (typeof Object)
        An object of the form { width, height }.
      • offsets: (typeof Object)
        An object of the form { l, r, t, b }.
    • source: [view]
        return this; // dojox.charting.plot2d.Base
    • summary
      Render the plot on the chart.
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.getRequiredColors

    • type
      Function
    • source: [view]
        return this.series.length; // Number
    • summary
      Get how many data series we have, so we know how many colors to use.
    • return_summary
      Number
      The number of colors needed.
    • returns
      Number
  • dojox.charting.plot2d.Base.initializeScalers

    • type
      Function
    • parameters:
      • dim: (typeof Object)
        Size of a plot area in pixels as {width, height}.
      • stats: (typeof Object)
        Min/max of data in both directions as {hmin, hmax, vmin, vmax}.
    • source: [view]
        if(this._hAxis){
         if(!this._hAxis.initialized()){
          this._hAxis.calculate(stats.hmin, stats.hmax, dim.width);
         }
         this._hScaler = this._hAxis.getScaler();
        }else{
         this._hScaler = dojox.charting.scaler.primitive.buildScaler(stats.hmin, stats.hmax, dim.width);
        }
        if(this._vAxis){
         if(!this._vAxis.initialized()){
          this._vAxis.calculate(stats.vmin, stats.vmax, dim.height);
         }
         this._vScaler = this._vAxis.getScaler();
        }else{
         this._vScaler = dojox.charting.scaler.primitive.buildScaler(stats.vmin, stats.vmax, dim.height);
        }
        return this; // dojox.charting.plot2d.Base
    • summary
      Initializes scalers using attached axes.
    • return_summary
      dojox.charting.plot2d.Base
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.Base
  • dojox.charting.plot2d.Base.series

    • summary
  • dojox.charting.plot2d.Base._hAxis

    • summary
  • dojox.charting.plot2d.Base._vAxis

    • summary
  • dojox.charting.plot2d.Base.dirty

    • summary
  • dojox.charting.plot2d.Base.lastWindow.hscale

    • summary
  • dojox.charting.plot2d.Base.lastWindow.vscale

    • summary
  • dojox.charting.plot2d.Base.zoom

    • summary
  • dojox.charting.plot2d.Base.zoomQueue.length

    • summary
  • dojox.charting.plot2d.Base._hScaler

    • summary
  • dojox.charting.plot2d.Base._vScaler

    • summary
  • dojox.charting.plot2d.Base.zoomQueue

    • summary
  • dojox.charting.plot2d.Base.lastWindow

    • summary
  • dojox.charting.plot2d.__PlotCtorArgs

    • type
      Function
    • source: [view]
       // summary:
       //  The base keyword arguments object for plot constructors.
       //  Note that the parameters for this may change based on the
       //  specific plot type (see the corresponding plot type for
       //  details).
    • summary
      The base keyword arguments object for plot constructors.
      Note that the parameters for this may change based on the
      specific plot type (see the corresponding plot type for
      details).
  • this.lastWindow.vscale

    • summary
  • this.lastWindow.hscale

    • summary
  • this.lastWindow.xoffset

    • summary
  • this.lastWindow.yoffset

    • summary
  • dojox.charting.plot2d

    • type
      Object
    • summary
  • dojox.charting

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary